From: Eric S. Raymond Date: Sun, 14 Nov 2010 05:36:46 +0000 (-0500) Subject: Write tags. Still have to do lightweight tags from resets. X-Git-Tag: 0.1~13 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=fc7f085f7fd294cfc65021e01bbda47d77c2b343;p=rcs-fast-import.git Write tags. Still have to do lightweight tags from resets. --- diff --git a/rcs-fast-import b/rcs-fast-import index a081c88..988b08d 100755 --- a/rcs-fast-import +++ b/rcs-fast-import @@ -608,9 +608,12 @@ class GenericRev: 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 branch(self, branchnum=None): + "With arg, return ID for the tip of a new branch." + if branchnum is None: + return GenericRev(self.rev[:-1]) + else: + return GenericRev(self.rev + [branchnum, 1]) def __str__(self): return ".".join(map(str, self.rev)) @@ -699,8 +702,11 @@ class Generic: comment = event.email_out() else: comment = event.comment - do_or_die(self.checkin(commit, comment, op, path), legend) + rev = self.make_tip(commit, path) + do_or_die(self.checkin(commit, comment, op, path, rev), legend) loud_remove(path) + if commit.is_tip(): + self.maketag(commit.branch, str(rev.branch()), path) def modify(self, event, path, mode, copyfile): "Perform file checkins and modifications," sanecheck(event, path, mode, copyfile) @@ -734,9 +740,9 @@ class RCS(Generic): mastertemplate = "%s,v" def __init__(self): Generic.__init__(self) - def checkin(self, commit, comment, op, path): + def checkin(self, commit, comment, op, path, rev): "Check in a new revision - also used to create new masters." - command = "ci -l%s" % self.make_tip(commit, path) + command = "ci -l%s" % rev if op == "D": command += " -sDeleted" command += " -d'%s'" % commit.committer.date.rfc822() @@ -746,6 +752,9 @@ class RCS(Generic): def checkout(self, path, 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 maketag(self, name, rev, path): + "Attach a tag to a file, overwriting any previous." + do_or_die("rcs -N'%s':%s %s" % (name, rev, self.master(path))) def postcommit(self, event): "Save annotated tags for round-tripping." for tag in event.taglist: