# thus, to distinguish between U and M status all we need to do is compare
# modtimes.
#
+# This code uses magic tags with a 0 in the second-to-last slot to designate
+# branches. It's the same format as CVS sticky tags.
+#
import sys, os, subprocess, time, calendar, stat, glob
version=0.3
def set_branch(self, name, revision, metadata, arg):
"Set the specified branch to be default, creating it if required."
if name in metadata.symbols:
- base = metadata.symbols[name]
+ # Must unstickify...
+ base = metadata.symbols[name].split(".")
+ base = base[:-2] + base[-1:]
+ base = ".".join(base)
else:
def branchfrom(c, p):
"Is c a branch child (not direct descendant) of parent p?"
p = p.split(".")
return len(c) == len(p) + 2 and c[len(p):] == p
baserev = metadata.current()
- print "Beginning branch computation from", baserev
newsib = len([item for item in metadata.revlist \
if branchfrom(item.revision, baserev)])
- print "Continuing branch computation"
- # Use CVS sticky-tag format here? If so, we'd have to do
- # some unscrambling just above in the non-new case
base = baserev + "." + str(newsib)
- print "New branch", base
- do_or_die("rcs -n{0}:{1} {2}".format(name, base, arg), loud=True)
+ sticky = baserev + ".0." + str(newsib)
+ do_or_die("rcs -n{0}:{1} {2}".format(name, sticky, arg), loud=True)
do_or_die("rcs -b%s %s" % (base, arg), loud=True)
def move(self, source, target):
"Move a file and its history."
state = "symbols"
elif line.startswith("branch:"):
branch = line.split(":")[1].strip()
- if not branch:
+ # Undocumented fact about RCS: The branch "1" is
+ # the same as the blank branch. Significant because
+ # you can't reset to the blank branch using rcs -b,
+ # that resets to the dynamically hhighest branch.
+ if not branch or branch == "1":
metadata.branch = "trunk"
elif line.startswith("----------------------------"):
if debug >= DEBUG_PARSE:
print "\tlockrevs:", metadata.lockrevs
print "\tsymbols:", metadata.symbols
def branch_to_base(self, revid):
- "Go from a branch ID to the revision it was based on."
- return ".".join(revid.split(".")[:-1])
+ "Go from a branch ID sticky tag to the revision it was based on."
+ return ".".join(revid.split(".")[:-2])
if __name__ == "__main__":
try: