Subject: [PATCH 1/1] packages: Add optional `for-ui` param to `package-full-name`.

From: Alex Sassmannshausen <[email-masked]>
Date: Sun, 26 Mar 2017 14:25:55 +0200

* guix/packages.scm (package-full-name): Add optional parameter `for-ui`.
* guix/scripts/refresh.scm (list-dependents): Use it.
* tests/packages.scm: Add tests for `package-full-name`.
---
 guix/packages.scm        | 9 +++++----
 guix/scripts/refresh.scm | 6 +++---
 tests/packages.scm       | 4 ++++
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/guix/packages.scm b/guix/packages.scm
index 4bc4b017f..5219b2acc 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -380,10 +380,11 @@ object."
 (define-condition-type &package-cross-build-system-error &package-error
   package-cross-build-system-error?)
 
-
-(define (package-full-name package)
-  "Return the full name of PACKAGE--i.e., `NAME-VERSION'."
-  (string-append (package-name package) "-" (package-version package)))
+(define* (package-full-name package #:optional for-ui)
+  "Return the full name of PACKAGE--i.e., `NAME-VERSION'.  If FOR-UI? is #t,
+return the full name of PACKAGE using \"@\" as the NAME, VERSION separator."
+  (string-append (package-name package) (if for-ui "@" "-")
+                 (package-version package)))
 
 (define (%standard-patch-inputs)
   (let* ((canonical (module-ref (resolve-interface '(gnu packages base))
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 4d3c695aa..14db7deb2 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -327,12 +327,12 @@ WARN? is true and no updater exists for PACKAGE, print a warning."
                  (N_ "No dependents other than itself: ~{~a~}~%"
                      "No dependents other than themselves: ~{~a~^ ~}~%"
                      (length packages))
-                 (map package-full-name packages)))
+                 (map (cut package-full-name <> #t) packages)))
 
         ((x)
          (format (current-output-port)
                  (_ "A single dependent package: ~a~%")
-                 (package-full-name x)))
+                 (package-full-name x #t)))
         (lst
          (format (current-output-port)
                  (N_ "Building the following package would ensure ~d \
@@ -341,7 +341,7 @@ dependent packages are rebuilt: ~*~{~a~^ ~}~%"
 dependent packages are rebuilt: ~{~a~^ ~}~%"
                      (length covering))
                  (length covering) (length dependents)
-                 (map package-full-name covering))))
+                 (map (cut package-full-name <> #t) covering))))
       (return #t))))
 
 
diff --git a/tests/packages.scm b/tests/packages.scm
index 247f75cc4..d19a44347 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -988,6 +988,10 @@
     (lambda (key . args)
       key)))
 
+(test-assert "package-full-name"
+  (and (string=? (package-full-name (dummy-package "foo")) "foo-0")
+       (string=? (package-full-name (dummy-package "foo") #t)  "foo@0")))
+
 (test-end "packages")
 
 ;;; Local Variables:
-- 
2.12.1