unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#48852] [PATCH] hg-download: Add helpers for defining packages.
@ 2021-06-05 19:18 Xinglu Chen
  2021-06-05 21:13 ` bug#48852: " Ludovic Courtès
  2021-06-05 21:17 ` [bug#48852] " Ludovic Courtès
  0 siblings, 2 replies; 3+ messages in thread
From: Xinglu Chen @ 2021-06-05 19:18 UTC (permalink / raw)
  To: 48852

Hg followup to commit ee17a9e06e636400e3354796a42ac445dbcc8f96.

* hg-download.scm (hg-version, hg-file-name): New procedures.
---
 guix/hg-download.scm | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/guix/hg-download.scm b/guix/hg-download.scm
index c6cee2dbb8..9f23e4c40d 100644
--- a/guix/hg-download.scm
+++ b/guix/hg-download.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2015, 2016, 2017, 2019 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -34,7 +35,9 @@
             hg-reference-changeset
             hg-reference-recursive?
             hg-predicate
-            hg-fetch))
+            hg-fetch
+            hg-version
+            hg-file-name))
 
 ;;; Commentary:
 ;;;
@@ -102,6 +105,23 @@ HASH-ALGO (a symbol).  Use NAME as the file name, or a generic name if #f."
                       #:recursive? #t
                       #:guile-for-build guile)))
 
+(define (hg-version version revision changeset)
+  "Return the version string for packages using hg-download."
+  ;; hg-version is almost exclusively executed while modules are being loaded.
+  ;; This makes any errors hide their backtrace. Avoid the mysterious error
+  ;; "Value out of range 0 to N: 7" when the commit ID is too short, which
+  ;; can happen, for example, when the user swapped the revision and commit
+  ;; arguments by mistake.
+  (when (< (string-length changeset) 7)
+    (raise
+     (condition
+      (&message (message "hg-version: changeset ID unexpectedly short")))))
+  (string-append version "-" revision "." (string-take changeset 7)))
+
+(define (hg-file-name name version)
+  "Return the file-name for packages using hg-download."
+  (string-append name "-" version "-checkout"))
+
 (define (hg-file-list directory)
   "Evaluates to a list of files contained in the repository at path
   @var{directory}"

base-commit: 9da90938c63208b7721276f8cefcdac82ba765f2
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#48852: [PATCH] hg-download: Add helpers for defining packages.
  2021-06-05 19:18 [bug#48852] [PATCH] hg-download: Add helpers for defining packages Xinglu Chen
@ 2021-06-05 21:13 ` Ludovic Courtès
  2021-06-05 21:17 ` [bug#48852] " Ludovic Courtès
  1 sibling, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2021-06-05 21:13 UTC (permalink / raw)
  To: Xinglu Chen; +Cc: 48852-done

Hi,

Xinglu Chen <public@yoctocell.xyz> skribis:

> Hg followup to commit ee17a9e06e636400e3354796a42ac445dbcc8f96.
>
> * hg-download.scm (hg-version, hg-file-name): New procedures.

Applied, thanks!

Ludo’.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* [bug#48852] [PATCH] hg-download: Add helpers for defining packages.
  2021-06-05 19:18 [bug#48852] [PATCH] hg-download: Add helpers for defining packages Xinglu Chen
  2021-06-05 21:13 ` bug#48852: " Ludovic Courtès
@ 2021-06-05 21:17 ` Ludovic Courtès
  1 sibling, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2021-06-05 21:17 UTC (permalink / raw)
  To: Xinglu Chen; +Cc: 48852

I added the missing srfi-3[45] imports too.

Ludo’.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-05 21:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-05 19:18 [bug#48852] [PATCH] hg-download: Add helpers for defining packages Xinglu Chen
2021-06-05 21:13 ` bug#48852: " Ludovic Courtès
2021-06-05 21:17 ` [bug#48852] " Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).