[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
202/285: git: 'commit-difference' takes a list of excluded commits.
From: |
guix-commits |
Subject: |
202/285: git: 'commit-difference' takes a list of excluded commits. |
Date: |
Sun, 29 Dec 2019 20:44:30 -0500 (EST) |
kkebreau pushed a commit to branch wip-gnome3.34
in repository guix.
commit a17273d76948317910eb4da36c1fa9464edf76b3
Author: Ludovic Courtès <address@hidden>
Date: Fri Dec 27 13:15:00 2019 +0100
git: 'commit-difference' takes a list of excluded commits.
* guix/git.scm (commit-closure): Add 'visited' optional parameter.
(commit-difference): Add 'excluded' optional parameter; pass second
argument to 'commit-closure'.
* tests/git.scm ("commit-difference, excluded commits"): New test.
---
guix/git.scm | 14 ++++++++------
tests/git.scm | 26 ++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/guix/git.scm b/guix/git.scm
index d7dddde..83af596 100644
--- a/guix/git.scm
+++ b/guix/git.scm
@@ -347,10 +347,11 @@ Log progress and checkout info to LOG-PORT."
;;; Commit difference.
;;;
-(define (commit-closure commit)
- "Return the closure of COMMIT as a set."
+(define* (commit-closure commit #:optional (visited (setq)))
+ "Return the closure of COMMIT as a set. Skip commits contained in VISITED,
+a set, and adjoin VISITED to the result."
(let loop ((commits (list commit))
- (visited (setq)))
+ (visited visited))
(match commits
(()
visited)
@@ -360,15 +361,16 @@ Log progress and checkout info to LOG-PORT."
(loop (append (commit-parents head) tail)
(set-insert head visited)))))))
-(define (commit-difference new old)
+(define* (commit-difference new old #:optional (excluded '()))
"Return the list of commits between NEW and OLD, where OLD is assumed to be
-an ancestor of NEW.
+an ancestor of NEW. Exclude all the commits listed in EXCLUDED along with
+their ancestors.
Essentially, this computes the set difference between the closure of NEW and
that of OLD."
(let loop ((commits (list new))
(result '())
- (visited (commit-closure old)))
+ (visited (commit-closure old (list->setq excluded))))
(match commits
(()
(reverse result))
diff --git a/tests/git.scm b/tests/git.scm
index 8ba10ec..052f8a7 100644
--- a/tests/git.scm
+++ b/tests/git.scm
@@ -96,4 +96,30 @@
(lset= eq? (commit-difference master4 master2)
(list master4 merge master3 devel1 devel2)))))))
+(unless (which (git-command)) (test-skip 1))
+(test-assert "commit-difference, excluded commits"
+ (with-temporary-git-repository directory
+ '((add "a.txt" "A")
+ (commit "first commit")
+ (add "b.txt" "B")
+ (commit "second commit")
+ (add "c.txt" "C")
+ (commit "third commit")
+ (add "d.txt" "D")
+ (commit "fourth commit")
+ (add "e.txt" "E")
+ (commit "fifth commit"))
+ (with-repository directory repository
+ (let ((commit1 (find-commit repository "first"))
+ (commit2 (find-commit repository "second"))
+ (commit3 (find-commit repository "third"))
+ (commit4 (find-commit repository "fourth"))
+ (commit5 (find-commit repository "fifth")))
+ (and (lset= eq? (commit-difference commit4 commit1 (list commit2))
+ (list commit3 commit4))
+ (lset= eq? (commit-difference commit4 commit1 (list commit3))
+ (list commit4))
+ (lset= eq? (commit-difference commit4 commit1 (list commit5))
+ (list commit2 commit3 commit4)))))))
+
(test-end "git")
- 155/285: gnu: nethack: Update to 3.6.4., (continued)
- 155/285: gnu: nethack: Update to 3.6.4., guix-commits, 2019/12/29
- 163/285: gnu: Add zfs., guix-commits, 2019/12/29
- 160/285: gnu: python-pathos: Run test suite., guix-commits, 2019/12/29
- 167/285: gnu: guix-data-service: Update to 0.0.1-11.7342280., guix-commits, 2019/12/29
- 171/285: gnu: geos: Update to 3.8.0., guix-commits, 2019/12/29
- 181/285: download: Enable TLS 1.3., guix-commits, 2019/12/29
- 144/285: gnu: libdvbpsi: Update to 1.3.3., guix-commits, 2019/12/29
- 172/285: gnu: Add proj., guix-commits, 2019/12/29
- 179/285: gnu: gdal: Enable netCDF format driver., guix-commits, 2019/12/29
- 177/285: gnu: gdal: Enable ODS format driver., guix-commits, 2019/12/29
- 202/285: git: 'commit-difference' takes a list of excluded commits.,
guix-commits <=
- 184/285: gnu: Add audiofile., guix-commits, 2019/12/29
- 200/285: gnu: emacs-org-contrib: Update to 20191226., guix-commits, 2019/12/29
- 225/285: gnu: emacs-doom-themes: Only disable breaking compilations., guix-commits, 2019/12/29
- 223/285: gnu: r-inspect: Update to 1.16.1., guix-commits, 2019/12/29
- 183/285: gnu: python-fonttools: Update home-page., guix-commits, 2019/12/29
- 180/285: gnu: gdal: Use HTTPS home page URI., guix-commits, 2019/12/29
- 178/285: gnu: gdal: Enable GPKG format driver., guix-commits, 2019/12/29
- 173/285: gnu: libgeotiff: Update to 1.5.1., guix-commits, 2019/12/29
- 185/285: gnu: Add dragon., guix-commits, 2019/12/29
- 188/285: gnu: Add libkcddb., guix-commits, 2019/12/29