From: Eric S. Raymond Date: Sun, 14 Nov 2010 04:44:15 +0000 (-0500) Subject: RCS *and* SCCS ids, not that we support SCCS yet. X-Git-Tag: 0.1~15 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=1e310a0e8f6e72b4decd799890a0a1989c3b6bdf;p=rcs-fast-import.git RCS *and* SCCS ids, not that we support SCCS yet. --- diff --git a/rcs-fast-import b/rcs-fast-import index cdf03f6..5f11bce 100755 --- a/rcs-fast-import +++ b/rcs-fast-import @@ -593,8 +593,30 @@ def loud_rename(source, target): # 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): @@ -706,32 +728,10 @@ class Generic: 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): @@ -739,15 +739,15 @@ class RCS(Generic): 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())