guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/02: profiles: 'manifest-add' truly deletes duplicate entries.


From: Ludovic Courtès
Subject: 01/02: profiles: 'manifest-add' truly deletes duplicate entries.
Date: Thu, 1 Mar 2018 08:00:27 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 435603a1d6106b535cf143d17cb030b2d0795b54
Author: Ludovic Courtès <address@hidden>
Date:   Thu Mar 1 11:37:36 2018 +0100

    profiles: 'manifest-add' truly deletes duplicate entries.
    
    Fixes <https://bugs.gnu.org/30569>.
    Reported by Andreas Enge <address@hidden>.
    
    * guix/profiles.scm (manifest-add): Don't append ENTRIES as is.
    Instead, cons each element of ENTRIES as we fold over it.
    Remove unneeded ellispes in 'match' patterns.
---
 guix/profiles.scm  | 20 ++++++++++----------
 tests/profiles.scm |  7 ++++++-
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/guix/profiles.scm b/guix/profiles.scm
index 8e3e49e..95dc974 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <address@hidden>
+;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès 
<address@hidden>
 ;;; Copyright © 2013 Nikita Karetnikov <address@hidden>
 ;;; Copyright © 2014, 2016 Alex Kost <address@hidden>
 ;;; Copyright © 2015 Mark H Weaver <address@hidden>
@@ -494,19 +494,19 @@ must be a manifest-pattern."
 Remove MANIFEST entries that have the same name and output as ENTRIES."
   (define (same-entry? entry name output)
     (match entry
-      (($ <manifest-entry> entry-name _ entry-output _ ...)
+      (($ <manifest-entry> entry-name _ entry-output _)
        (and (equal? name entry-name)
             (equal? output entry-output)))))
 
   (make-manifest
-   (append entries
-           (fold (lambda (entry result)
-                   (match entry
-                     (($ <manifest-entry> name _ out _ ...)
-                      (filter (negate (cut same-entry? <> name out))
-                              result))))
-                 (manifest-entries manifest)
-                 entries))))
+   (fold (lambda (entry result)                   ;XXX: quadratic
+           (match entry
+             (($ <manifest-entry> name _ out _)
+              (cons entry
+                    (remove (cut same-entry? <> name out)
+                            result)))))
+         (manifest-entries manifest)
+         entries)))
 
 (define (manifest-lookup manifest pattern)
   "Return the first item of MANIFEST that matches PATTERN, or #f if there is
diff --git a/tests/profiles.scm b/tests/profiles.scm
index 469dde2..92eb08c 100644
--- a/tests/profiles.scm
+++ b/tests/profiles.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <address@hidden>
+;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès 
<address@hidden>
 ;;; Copyright © 2014 Alex Kost <address@hidden>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -148,6 +148,11 @@
            (_ #f))
          (equal? m3 m4))))
 
+(test-equal "manifest-add removes duplicates"    ;<https://bugs.gnu.org/30569>
+  (list guile-2.0.9)
+  (manifest-entries (manifest-add (manifest '())
+                                  (list guile-2.0.9 guile-2.0.9))))
+
 (test-assert "manifest-perform-transaction"
   (let* ((m0 (manifest (list guile-2.0.9 guile-2.0.9:debug)))
          (t1 (manifest-transaction



reply via email to

[Prev in Thread] Current Thread [Next in Thread]