unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou via Guix-patches via <guix-patches@gnu.org>
To: 71371@debbugs.gnu.org
Cc: "Nicolas Goaziou" <mail@nicolasgoaziou.fr>,
	"Christopher Baines" <guix@cbaines.net>,
	"Florian Pelz" <pelzflorian@pelzflorian.de>,
	"Josselin Poiret" <dev@jpoiret.xyz>,
	"Ludovic Courtès" <ludo@gnu.org>,
	"Mathieu Othacehe" <othacehe@gnu.org>,
	"Matthew Trzcinski" <matt@excalamus.com>,
	"Maxim Cournoyer" <maxim.cournoyer@gmail.com>,
	"Simon Tournier" <zimon.toutoune@gmail.com>,
	"Tobias Geerinckx-Rice" <me@tobias.gr>
Subject: [bug#71371] [PATCH v2] gnu: svn-fetch: Allow specifying revisions as strings.
Date: Tue, 18 Jun 2024 10:30:10 +0200	[thread overview]
Message-ID: <4885bc5c95529991846db147ca58f7445d3cd864.1718699410.git.mail@nicolasgoaziou.fr> (raw)
In-Reply-To: <d811c6461c7d653834c6a04290cacda5a72680b2.1717566375.git.mail@nicolasgoaziou.fr>

* 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







  parent reply	other threads:[~2024-06-18  8:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05  5:52 [bug#71371] [PATCH] gnu: svn-fetch: Make revision field optional Nicolas Goaziou via Guix-patches via
2024-06-05 16:09 ` Ludovic Courtès
2024-06-05 20:44   ` Nicolas Goaziou via Guix-patches via
2024-06-05 16:32 ` Simon Tournier
2024-06-18  8:30 ` Nicolas Goaziou via Guix-patches via [this message]
2024-06-18 12:11   ` [bug#71371] [PATCH v2] gnu: svn-fetch: Allow specifying revisions as strings Maxim Cournoyer
2024-06-18 13:26     ` Nicolas Goaziou via Guix-patches via
2024-06-18 18:26       ` Maxim Cournoyer
2024-06-19  7:27         ` bug#71371: " Nicolas Goaziou via Guix-patches via
2024-06-25 15:19         ` [bug#71371] " Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4885bc5c95529991846db147ca58f7445d3cd864.1718699410.git.mail@nicolasgoaziou.fr \
    --to=guix-patches@gnu.org \
    --cc=71371@debbugs.gnu.org \
    --cc=dev@jpoiret.xyz \
    --cc=guix@cbaines.net \
    --cc=ludo@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    --cc=matt@excalamus.com \
    --cc=maxim.cournoyer@gmail.com \
    --cc=me@tobias.gr \
    --cc=othacehe@gnu.org \
    --cc=pelzflorian@pelzflorian.de \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).