[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#71371] [PATCH v2] gnu: svn-fetch: Allow specifying revisions as str
From: |
Nicolas Goaziou |
Subject: |
[bug#71371] [PATCH v2] gnu: svn-fetch: Allow specifying revisions as strings. |
Date: |
Tue, 18 Jun 2024 10:30:10 +0200 |
* guix/svn-download.scm (<svn-reference>):
(svn-fetch):
(svn-multi-fetch):
* guix/build/svn.scm (svn-fetch): Revision can also be a string, not only
a number.
* doc/guix.texi (origin Reference): Document changes about REVISION field.
Change-Id: Ibb17b539575fdf3daf895bd1ce39a40dd9b495cb
---
v2: No longer ignore "-r" argument. Instead, allow strings, such as "HEAD".
Yes, in practice, it means this relies on the tag being stable, which is the
same assumption as for, e.g., tarballs. WDYT?
doc/guix.texi | 2 +-
guix/build/svn.scm | 7 ++++++-
guix/svn-download.scm | 20 ++++++++++++++------
3 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 0102fd0fad..0b30ed0a72 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -8283,7 +8283,7 @@ origin Reference
The URL of the Subversion repository to clone.
@item @code{revision}
-This string denotes revision to fetch specified as a number.
+This string or number denotes revision to fetch.
@item @code{recursive?} (default: @code{#f})
This Boolean indicates whether to recursively fetch Subversion
diff --git a/guix/build/svn.scm b/guix/build/svn.scm
index 875d3c50ca..58b74fd37a 100644
--- a/guix/build/svn.scm
+++ b/guix/build/svn.scm
@@ -46,7 +46,12 @@ (define* (svn-fetch url revision directory
;; Trust the server certificate. This is OK as we
;; verify the checksum later. This can be removed when
;; ca-certificates package is added.
- "--trust-server-cert" "-r" (number->string revision)
+ "--trust-server-cert"
+
+ ;; Revision. It can be a number or a string.
+ "-r" (if (number? revision)
+ (number->string revision)
+ revision) ;assume string
;; Disable keyword substitutions (keywords are CVS-like strings
;; like "$Date$", "$Id$", and so on) for two reasons: (1) some
diff --git a/guix/svn-download.scm b/guix/svn-download.scm
index 62649e4374..e21091defc 100644
--- a/guix/svn-download.scm
+++ b/guix/svn-download.scm
@@ -64,7 +64,7 @@ (define-record-type* <svn-reference>
svn-reference make-svn-reference
svn-reference?
(url svn-reference-url) ; string
- (revision svn-reference-revision) ; number
+ (revision svn-reference-revision) ; number|string
(recursive? svn-reference-recursive? (default #f))
(user-name svn-reference-user-name (default #f))
(password svn-reference-password (default #f)))
@@ -113,7 +113,8 @@ (define (svn-fetch-builder svn hash-algo)
(or (and (download-method-enabled? 'upstream)
(svn-fetch (getenv "svn url")
- (string->number (getenv "svn revision"))
+ (let ((r (getenv "svn revision")))
+ (or (string->number r) r))
#$output
#:svn-command #+(file-append svn "/bin/svn")
#:recursive? (match (getenv "svn recursive?")
@@ -152,7 +153,10 @@ (define* (svn-fetch ref hash-algo hash
#:env-vars
`(("svn url" . ,(svn-reference-url ref))
("svn revision"
- . ,(number->string (svn-reference-revision ref)))
+ . ,(let ((revision (svn-reference-revision ref)))
+ (if (number? revision)
+ (number->string revision)
+ revision)))
,@(if (svn-reference-recursive? ref)
`(("svn recursive?" . "yes"))
'())
@@ -187,7 +191,7 @@ (define-record-type* <svn-multi-reference>
svn-multi-reference make-svn-multi-reference
svn-multi-reference?
(url svn-multi-reference-url) ; string
- (revision svn-multi-reference-revision) ; number
+ (revision svn-multi-reference-revision) ; number|string
(locations svn-multi-reference-locations) ; list of strings
(recursive? svn-multi-reference-recursive? (default #f))
(user-name svn-multi-reference-user-name (default #f))
@@ -240,7 +244,8 @@ (define (svn-multi-fetch-builder svn hash-algo)
(mkdir-p (string-append #$output "/" (dirname location))))
(and (download-method-enabled? 'upstream)
(svn-fetch (string-append (getenv "svn url") "/"
location)
- (string->number (getenv "svn revision"))
+ (let ((r (getenv "svn revision")))
+ (or (string->number r) r))
(if (string-suffix? "/" location)
(string-append #$output "/" location)
(string-append #$output "/" (dirname
location)))
@@ -292,7 +297,10 @@ (define* (svn-multi-fetch ref hash-algo hash
("svn locations"
. ,(object->string (svn-multi-reference-locations
ref)))
("svn revision"
- . ,(number->string (svn-multi-reference-revision
ref)))
+ . ,(let ((revision (svn-multi-reference-revision
ref)))
+ (if (number? revision)
+ (number->string revision)
+ revision)))
,@(if (svn-multi-reference-recursive? ref)
`(("svn recursive?" . "yes"))
'())
base-commit: 30dbc8e7b0d94c0e38e8b7380260450e20035c58
--
2.45.1