From 4191dca62bd8c8cbab071c2fd261498f22a48dfe Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 13 Nov 2014 09:59:43 -0500 Subject: [PATCH] Branch names are no meaningful in revisions. --- NEWS | 5 ++++- TODO | 2 -- src | 36 +++++++++++++++++++++++++++--------- src.asc | 10 +++++++--- 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index e9329f5..e6ad872 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,7 @@ -` src project news + src project news + +Repository head: + A branch label names the tip revision of its branch. 0.7: 2014-11-13 Bugfix release: fix initial file commit. There was a bug in my tests... diff --git a/TODO b/TODO index a6d06ff..e94335b 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,5 @@ SRC TODO list -* Branch names are not yet resolved in revspecs. - * src branch delete. Should branch_delete really obsolesce branches or just mark them dead? diff --git a/src b/src index 92df602..035cd3c 100755 --- a/src +++ b/src @@ -245,9 +245,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 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). +integer revision, or a branch name esignatingthe tip revision of its +branch. Revision 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). + If src complains that your revision spec looks like a nonexistent filename, you can prefix it with @ (this is always allowed). @@ -458,7 +462,7 @@ class CommandContext: else: part = metadata.symbols[part] if backend.isbranch(part): - part = backend.branch_to_tip(part) + part = backend.branch_to_tip(part, metadata) return metadata.native_to_revno(part) self.start = subresolve(self.start) self.end = subresolve(self.end) @@ -1082,9 +1086,12 @@ class RCS: return rev def succ(self, rev): "Our successor." - n = self.splitrev(rev) - n[-1] += 1 - return self.joinrev(n) + if rev: + n = self.splitrev(rev) + n[-1] += 1 + return self.joinrev(n) + else: + return "1.1" def isbranch(self, symbol): "Is this a branch symbol?" return "0." in symbol @@ -1092,9 +1099,20 @@ class RCS: "Go from a branch ID sticky tag to the revision it was based on." # Must return an emptry string for the fake root sticky tag. return self.joinrev(self.splitrev(revid)[:-2]) - def branch_to_tip(self, revid): + def branch_to_tip(self, revid, metadata): "Go from a branch ID sticky tag to the tip revision of its base." - croak("branch_to_tip() is not yet implemented") + rev = self.branch_to_base(revid) + if rev: + rev += ".1.1" + else: + rev = "1.1" + while True: + nxt = self.succ(rev) + if metadata.native_to_revno(nxt) is None: + return rev + else: + rev = nxt + croak("internal error: couldn't find branch tip of %s" % rev) def add(self, arg): "Register a file" # Key choices here: -b suppresses all keyword expansion, -U sets diff --git a/src.asc b/src.asc index 7bcae0c..7809842 100644 --- a/src.asc +++ b/src.asc @@ -31,9 +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 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). +integer revision, or a branch name esignatingthe tip revision of its +branch. Revision 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). + If src complains that your revision spec looks like a nonexistent filename, you can prefix it with @ (this is always allowed). -- 2.43.0