From: Eric S. Raymond Date: Sat, 20 Dec 2014 12:12:43 +0000 (-0500) Subject: Support for reversed ranges. X-Git-Tag: 0.18~3 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=02dfebc7694168d14f0e7bf3d41ba4838fa0192f;p=src.git Support for reversed ranges. --- diff --git a/NEWS b/NEWS index d1254fb..c748885 100644 --- 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 ab2f72b..3028045 100755 --- 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: