From c39fa81875595232baaa6551bb2cdc7ccda2c586 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 11 Nov 2010 09:05:27 -0500 Subject: [PATCH] Tags are working. --- rcs-fast-import | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/rcs-fast-import b/rcs-fast-import index ea34859..cdc2840 100755 --- a/rcs-fast-import +++ b/rcs-fast-import @@ -6,10 +6,9 @@ # # Requires Python 2.5 or newer. # -# # TO DO: -# * Apply tags # * Branch structure! +# * Checkout options # """ Usage: rcs-fast-import [-v] [-u] [-l] [-d] [-n] [-V] @@ -216,6 +215,7 @@ class Commit: self.branch = None # branch name self.fileops = [] # blob and file operation list self.properties = {} # commit properties (extension) + self.taglist = [] # Tags that point at this commit class Passthrough: "Represents a passthrough line." @@ -270,6 +270,9 @@ class Repository: if hasattr(e, "mark") and mark == e.mark: return i return None + def commits(self): + "Return a list of the repository commit objects." + return filter(lambda e: isinstance(e, Commit), self.events) def fast_import(self, fp, progress=False): "Initialize repo object from fast-import stream." try: @@ -461,8 +464,11 @@ class Repository: self.warn("missing tagger after from in tag") pushback(line) dp = read_data(cStringIO.StringIO()) - self.events.append(Tag(tagname, - referent, tagger, dp.getvalue())) + tag = Tag(tagname, referent, tagger, dp.getvalue()) + self.events.append(tag) + for commit in self.commits(): + if commit.mark == referent: + commit.taglist.append(tag) baton.twirl() else: # Simply pass through any line we don't understand. @@ -550,6 +556,15 @@ class RCS: parts = list(os.path.split(filename)) parts.insert(-1, "RCS") return os.path.join(*parts) + @staticmethod + def rcsfiles(): + "List all masters." + res = [] + for root, dirs, files in os.walk(os.getcwd(), topdown=False): + if root.endswith("/RCS"): + for name in files: + res.append(os.path.join(root, name)) + return res def commit(self, event, committables): "Perform RCS file checkins and modifications," for (path, mode, copyfile) in committables: @@ -581,6 +596,8 @@ class RCS: announce("removing %s" % (path,)) if not dryrun: os.remove(path) + for tag in event.taglist: + do_or_die("rcs -n'%s': %s" % (tag.name, " ".join(RCS.rcsfiles()))) def rename(self, source, target): "Perform RCS renames." # Dodgy, but since user is more likely to be -- 2.43.0