]> thyrsus.com Git - src.git/commitdiff
Branch names are no meaningful in revisions.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 13 Nov 2014 14:59:43 +0000 (09:59 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 13 Nov 2014 14:59:43 +0000 (09:59 -0500)
NEWS
TODO
src
src.asc

diff --git a/NEWS b/NEWS
index e9329f5cb99e8d3f7cc2734186cc71f3ad93df26..e6ad872c0eb60e6ef41de357a94ab5c06c9142ad 100644 (file)
--- 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 a6d06ff28172163b6660642cabb0cdb2107e88b7..e94335b62f7c8ca08e9923611db55fe4d6648a50 100644 (file)
--- 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 92df60275ba351a6f0564fb17bcb63258e31d5c8..035cd3c016c0edf12d0bcc2af385f4e267edd59b 100755 (executable)
--- 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 7bcae0c0d073e242ba1aa65ba4257a8c84453eea..7809842d81a776b3cdac7a1806a8727f2aa6e221 100644 (file)
--- 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).