]> thyrsus.com Git - src.git/commitdiff
Support for reversed ranges.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 20 Dec 2014 12:12:43 +0000 (07:12 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Sat, 20 Dec 2014 12:12:43 +0000 (07:12 -0500)
NEWS
src

diff --git a/NEWS b/NEWS
index d1254fbb4d4358e5c0ffe59264fba4f800cc3223..c748885ccdfebd7cec630a176530689fc530f01e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
                        src project news
 
+Repository headL
+   Reversed range expressons are now supported.
+
 0.17: 2014-12-19
    Undocumented 'add' command abolished; Emacs VC will use 'commit -a' instead.
 
diff --git a/src b/src
index ab2f72ba29b5ad64c248f9d54168ceaf6b2d4a16..30280451a27285a36eed165241bd6b2a5e8b6563 100755 (executable)
--- a/src
+++ b/src
@@ -419,7 +419,8 @@ numbers always increase in commit-date order.
 
 A revision range is a single revision, or a pair of revisions M-N (all
 revisions numerically from M to N) or M..N (all revisions that are
-branch ancestors of N and branch successors of M).
+branch ancestors of N and branch successors of M).  If N is less than
+M, the range is generated as if N >= M then reversed.
 
 If src complains that your revision spec looks like a nonexistent
 filename, you can prefix it with @ (this is always allowed).
@@ -956,6 +957,11 @@ class CommandContext:
             return metadata.native_to_revno(part)
         self.start = subresolve(self.start)
         self.end = subresolve(self.end)
+        reversed = (self.start > self.end)
+        if reversed:
+            swapme = self.end
+            self.end = self.start
+            self.start = swapme
         if self.end > len(metadata):
             croak("{0} has no {1} revision".format(metadata.name, self.end))
         if not self.branchwise:
@@ -978,6 +984,9 @@ class CommandContext:
         # Because in the branchwise case the sequence is generated in reverse
         if backwards != self.branchwise:
             self.seq.reverse()
+        # Range might have been reversed
+        if reversed:
+            self.seq.reverse()
         return self.seq
 
 class CommentContext: