summaryrefslogtreecommitdiff
path: root/guix/hg-download.scm
diff options
context:
space:
mode:
authorMarius Bakke <marius@gnu.org>2021-06-06 21:16:32 +0200
committerMarius Bakke <marius@gnu.org>2021-06-06 21:16:32 +0200
commit8d59c262ada2e2167196a8fb8cbebd9c329a79dd (patch)
tree85a74de8cc23a2f0179c0b9f0adfa4c274449a0c /guix/hg-download.scm
parente7f0835b07d868fd447aa64c873174fa385e1699 (diff)
parenta068ed6a5f5b3535fce49ac4eca1fec82edd6fdc (diff)
downloadguix-patches-8d59c262ada2e2167196a8fb8cbebd9c329a79dd.tar
guix-patches-8d59c262ada2e2167196a8fb8cbebd9c329a79dd.tar.gz
Merge branch 'master' into core-updates
Conflicts: gnu/local.mk gnu/packages/algebra.scm gnu/packages/bioinformatics.scm gnu/packages/curl.scm gnu/packages/docbook.scm gnu/packages/emacs-xyz.scm gnu/packages/maths.scm gnu/packages/plotutils.scm gnu/packages/python-web.scm gnu/packages/python-xyz.scm gnu/packages/radio.scm gnu/packages/readline.scm gnu/packages/tls.scm gnu/packages/xml.scm gnu/packages/xorg.scm
Diffstat (limited to 'guix/hg-download.scm')
-rw-r--r--guix/hg-download.scm24
1 files changed, 23 insertions, 1 deletions
diff --git a/guix/hg-download.scm b/guix/hg-download.scm
index c6cee2dbb8..eb7c345489 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.
;;;
@@ -25,6 +26,8 @@
#:use-module (guix modules)
#:use-module (guix packages)
#:autoload (guix build-system gnu) (standard-packages)
+ #:use-module (srfi srfi-34)
+ #:use-module (srfi srfi-35)
#:use-module (ice-9 match)
#:use-module (ice-9 popen)
#:use-module (ice-9 rdelim)
@@ -34,7 +37,9 @@
hg-reference-changeset
hg-reference-recursive?
hg-predicate
- hg-fetch))
+ hg-fetch
+ hg-version
+ hg-file-name))
;;; Commentary:
;;;
@@ -102,6 +107,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}"