# our working-file paths. It also assumes that we have to stuff
# commit metadata in comments as RFC822 headers if we want to keep it.
+class GenericRev:
+ "Encapsulate operations on an RCS/SCCS ID."
+ def __init__(self, rev=None):
+ if rev is None:
+ self.rev = [1, 1]
+ else:
+ self.rev = rev
+ def __hash__(self):
+ "Make these valid dictionary keys,"
+ return hash(tuple(self.rev))
+ def successor(self):
+ "Return the successor of this ID."
+ s = GenericRev(self.rev)
+ s.rev[-1] += 1
+ return s
+ def branch(self, branchnum):
+ "Return ID for the tip of a new branch."
+ return GenericRev(self.rev + [branchnum, 1])
+ def __str__(self):
+ return ".".join(map(str, self.rev))
+
class Generic:
"Generic file-oriented VCS - could be used for, say. SCCS as well as RCS."
+ revfactory = GenericRev
def __init__(self):
self.roundtrip = False
if not os.path.exists(self.__class__.repodirectory):
self.copy(commit, source, target, legend="Rename")
self.delete(commit, source, legend="Rename")
-class RCSRev:
- "Encapsulate operations on an RCS ID."
- def __init__(self, rev=None):
- if rev is None:
- self.rev = [1, 1]
- else:
- self.rev = rev
- def __hash__(self):
- "Make these valid dictionary keys,"
- return hash(tuple(self.rev))
- def successor(self):
- "Return the successor of this ID."
- s = RCSRev(self.rev)
- s.rev[-1] += 1
- return s
- def branch(self, branchnum):
- "Return ID for the tip of a new branch."
- return RCSRev(self.rev + [branchnum, 1])
- def __str__(self):
- return ".".join(map(str, self.rev))
-
class RCS(Generic):
"Class encapsulating RCS version-control operations."
repodirectory = "RCS"
mastertemplate = "%s,v"
- revfactory = RCSRev
def __init__(self):
Generic.__init__(self)
def checkin(self, commit, comment, op, path):
command = "ci -l%s" % self.make_tip(commit, path)
if op == "D":
command += " -sDeleted"
- command += " -d'%s'" % event.committer.date.rfc822()
+ command += " -d'%s'" % commit.committer.date.rfc822()
command += ' -m"%s"' % comment.replace('"', '\\"')
command += " " + path + " " + self.master(path)
return command
def checkout(self, path, branch):
- "Check out the latest revision corresponding to path and branch"
+ "Check out the latest revision corresponding to path and branch."
return "co -r%s %s" % (self.get_tip(path, branch), self.master(path))
def postcommit(self, event):
- # Save annotated tags for round-tripping
+ "Save annotated tags for round-tripping."
for tag in event.taglist:
with file("ANNOTATED-TAGS", "w") as fp:
fp.write(tag.email_out())