]> thyrsus.com Git - src.git/commitdiff
Traversal with either - or .. works and is regression-tested.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 12 Nov 2014 20:24:11 +0000 (15:24 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 12 Nov 2014 20:24:11 +0000 (15:24 -0500)
NEWS
TODO
src
src.asc
srctest

diff --git a/NEWS b/NEWS
index e4d0d6e30963a47382c2f86bb0856075248e5a27..ec2c5a15bcdfafb32b3661edf9eac9a47504a678 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 `                      src project news
 
 Repository head:
+   Branch-sensitive traversal with .. is working.
    Fixed yet another fast-export bug.
 
 0.5: 2014-11-11
diff --git a/TODO b/TODO
index f794c652c3b454fac07a32163293154fab3c3140..f5abb7f764c8c3b624e66aea8d09b9d0017e9d40 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
                        SRC TODO list
 
-* branch-restricted ranges in revision specifications.
-
 * tag and branch names as revision-spec parts
 
 * revert?  reset?
diff --git a/src b/src
index 1f51b639f449ae0d98c03286791d06b21e3b371f..4dcdc438733d54b6a6b490829b517dc39fa66078 100755 (executable)
--- a/src
+++ b/src
@@ -258,11 +258,13 @@ def help_method(*_args):
     "Summarize src commands, or (with argument) show help for a single command."
     print("""
 A 'revision' is a 1-origin integer, or a tag name designating an
-integer revision.  A revision range is a single revision or a pair of
-revisions separated by"-" or "..". Unless otherwise noted under
-individual commands, the default revision is the tip revision on the
-current branch and the default range is all revisions on the current
-branch.
+integer revision.  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 ancestots of N and branch successors of M).
+
+Unless otherwise noted under individual commands, the default revision
+is the tip revision on the current branch and the default range is all
+revisions on the current branch.
 
 The token "--" tells the command-line interpreter that revision-specs
 and subcommands are done - everything after it is a filename, even
@@ -433,7 +435,7 @@ class CommandContext:
         if self.seq is None:
             croak("revision spec hasn't been resolved")
         return i in self.seq
-    def resolve(self, metadata):
+    def resolve(self, metadata, reversed=True):
         "Resolve a revision spec that may contain tags into revnos."
         if self.is_empty():
             if self.default_to == "branch":
@@ -473,6 +475,9 @@ class CommandContext:
             sys.stderr.write("selection: %s, branchwise is %s\n" % (self.seq, "on" if self.branchwise else "off"))
             for item in metadata.revlist:
                 sys.stdout.write("%s\t%s\t%s\n" % (item.revno, item.date, item.revision))
+        # Because in the branchwise case the seqence is generated in reverse 
+        if reversed != self.branchwise:
+            self.seq.reverse()
         return [metadata.by_revno(s) for s in self.seq]
 
 class CommentContext:
@@ -576,7 +581,7 @@ def list_method(*args):
     width = screenwidth()
     for arg in ctx.args:
         sys.stdout.write("= %s %s\n" % (arg, ((width - len(arg) - 5) * "=")))
-        for item in ctx.resolve(History(arg)):
+        for item in ctx.resolve(History(arg), reversed=True):
             # Must allow enough room for revno and date
             summary = item.log.strip()[:width - 34]
             if item.selected():
@@ -592,7 +597,7 @@ def log_method(*args):
     width = screenwidth()
     for arg in ctx.args:
         sys.stdout.write("= %s %s\n" % (arg, ((width - len(arg) - 5) * "=")))
-        for item in ctx.resolve(History(arg)):
+        for item in ctx.resolve(History(arg), reversed=True):
             sys.stdout.write("%-4d | %s\n%s" % (item.revno,item.date,item.log))
             sys.stdout.write(("-" * (width - 1)) + "\n")
 
diff --git a/src.asc b/src.asc
index 4177ff8b6dae558e59278efaf588817581ed6f71..41dbec9556cd7ebd725ece89ac3cfb28d26b678c 100644 (file)
--- a/src.asc
+++ b/src.asc
@@ -31,11 +31,13 @@ an editor instance when you perform a commit.
 == COMMAND SUMMARY ==
 
 A 'revision' is a 1-origin integer, or a tag name designating an
-integer revision.  A revision range is a single revision or a pair of
-revisions separated by "-" or "..". Unless otherwise noted under
-individual commands, the default revision is the tip revision on the
-current branch and the default range is all revisions on the current
-branch.
+integer revision.  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).
+
+Unless otherwise noted under individual commands, the default revision
+is the tip revision on the current branch and the default range is all
+revisions on the current branch.
 
 The token "--" tells the command-line interpreter that revision-specs
 and subcommands are done - everything after it is a filename, even
diff --git a/srctest b/srctest
index 610b9fa992c09e179a48703f359d1e7002511157..794d96ec4a30811783ab8ee261818d8615a3fa09 100755 (executable)
--- a/srctest
+++ b/srctest
@@ -143,7 +143,7 @@ cat >testfile8 <<EOF
    3   sampletag
 EOF
 src $TESTOPTS tag >testfile9
-diff testfile8 testfile9
+diff -u testfile8 testfile9
 check "tag list check"
 
 src $TESTOPTS tag basetag 1
@@ -155,7 +155,7 @@ cat >testfile10 <<EOF
    3   sampletag
 EOF
 src $TESTOPTS tag >testfile11
-diff testfile10 testfile11
+diff -u testfile10 testfile11
 check "second tag list check"
 
 src $TESTOPTS tag delete sampletag
@@ -166,7 +166,7 @@ cat >testfile12 <<EOF
    1   basetag
 EOF
 src $TESTOPTS tag >testfile13
-diff testfile12 testfile13
+diff -u testfile12 testfile13
 check "tag list check after deletion"
 
 # Alas, we have to do this or the fast-export regression will fail.
@@ -241,6 +241,196 @@ check "amend"
 src $TESTOPTS list 3 newname1 | grep "Amended comment" >/dev/null
 check "amended comment content"
 
+# Introduce a test history with some branchiness, so
+# we can test traversal across branch joins.
+cat >.src/sample,v <<EOF
+head   1.4;
+branch 1.3.1.4.1;
+access;
+symbols
+       sample:1.3.1.4.0.1
+       muggle:1.3.0.1;
+locks
+       esr:1.3.1.4;
+comment        @# @;
+expand @b@;
+
+
+1.4
+date   2014.11.11.03.26.53;    author esr;     state Exp;
+branches;
+next   1.3;
+
+1.3
+date   2014.11.10.23.48.49;    author esr;     state Exp;
+branches
+       1.3.1.1;
+next   1.2;
+
+1.2
+date   2014.11.10.23.48.11;    author esr;     state Exp;
+branches;
+next   1.1;
+
+1.1
+date   2014.11.10.23.47.08;    author esr;     state Exp;
+branches;
+next   ;
+
+1.3.1.1
+date   2014.11.11.04.23.47;    author esr;     state Exp;
+branches;
+next   1.3.1.2;
+
+1.3.1.2
+date   2014.11.11.06.39.47;    author esr;     state Exp;
+branches;
+next   1.3.1.3;
+
+1.3.1.3
+date   2014.11.11.06.48.00;    author esr;     state Exp;
+branches;
+next   1.3.1.4;
+
+1.3.1.4
+date   2014.11.12.03.36.45;    author esr;     state Exp;
+branches;
+next   ;
+
+
+desc
+@@
+
+
+1.4
+log
+@On a branch?
+@
+text
+@Now is the time
+For all good men.
+To come to the aid of foo.
+This should be branch text.
+@
+
+
+1.3
+log
+@Third comment.
+@
+text
+@d4 1
+@
+
+
+1.3.1.1
+log
+@On a branch 2?
+@
+text
+@a3 2
+
+Again, this should be branch text.
+@
+
+
+1.3.1.2
+log
+@Let's see if this commend has a sepaeator before it.
+@
+text
+@d5 1
+a5 1
+Yet again, this should be branch text.
+@
+
+
+1.3.1.3
+log
+@Totally chenille.
+@
+text
+@a5 2
+
+Revision 7.
+@
+
+
+1.3.1.4
+log
+@foo-bar
+@
+text
+@d4 4
+a7 2
+This should be branch text.
+Try a comment with a hyphen.
+@
+
+
+1.2
+log
+@Second comment.
+@
+text
+@d3 1
+@
+
+
+1.1
+log
+@First comment.
+@
+text
+@d2 1
+@
+
+EOF
+
+cat >sample.seqlog <<EOF
+= sample ====================================================================
+6    | 1970-01-02T00:05:00Z
+Let's see if this commend has a sepaeator before it.
+------------------------------------------------------------------------------
+5    | 1970-01-02T00:04:00Z
+On a branch 2?
+------------------------------------------------------------------------------
+4    | 1970-01-02T00:03:00Z
+On a branch?
+------------------------------------------------------------------------------
+3    | 1970-01-02T00:02:00Z
+Third comment.
+------------------------------------------------------------------------------
+2    | 1970-01-02T00:01:00Z
+Second comment.
+------------------------------------------------------------------------------
+EOF
+
+src $TESTOPTS log 2-6 sample >tryit
+diff -u tryit sample.seqlog
+check "traversal by -"
+
+cat >sample.branchlog <<EOF
+= sample ====================================================================
+6    | 1970-01-02T00:05:00Z
+Let's see if this commend has a sepaeator before it.
+------------------------------------------------------------------------------
+5    | 1970-01-02T00:04:00Z
+On a branch 2?
+------------------------------------------------------------------------------
+3    | 1970-01-02T00:02:00Z
+Third comment.
+------------------------------------------------------------------------------
+2    | 1970-01-02T00:01:00Z
+Second comment.
+------------------------------------------------------------------------------
+EOF
+
+src $TESTOPTS log 2..6 sample >tryit
+diff -u tryit sample.branchlog
+check "traversal by .."
+
+
 rm -fr $SANDBOX
 
 # end