From: Eric S. Raymond Date: Wed, 12 Nov 2014 20:24:11 +0000 (-0500) Subject: Traversal with either - or .. works and is regression-tested. X-Git-Tag: 0.6~18 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=a37afa810971d22c9fd21f792640f7c86d17b6f5;p=src.git Traversal with either - or .. works and is regression-tested. --- diff --git a/NEWS b/NEWS index e4d0d6e..ec2c5a1 100644 --- 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 f794c65..f5abb7f 100644 --- 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 1f51b63..4dcdc43 100755 --- 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 4177ff8..41dbec9 100644 --- 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 610b9fa..794d96e 100755 --- a/srctest +++ b/srctest @@ -143,7 +143,7 @@ cat >testfile8 <testfile9 -diff testfile8 testfile9 +diff -u testfile8 testfile9 check "tag list check" src $TESTOPTS tag basetag 1 @@ -155,7 +155,7 @@ cat >testfile10 <testfile11 -diff testfile10 testfile11 +diff -u testfile10 testfile11 check "second tag list check" src $TESTOPTS tag delete sampletag @@ -166,7 +166,7 @@ cat >testfile12 <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 <sample.seqlog <tryit +diff -u tryit sample.seqlog +check "traversal by -" + +cat >sample.branchlog <tryit +diff -u tryit sample.branchlog +check "traversal by .." + + rm -fr $SANDBOX # end