From: Eric S. Raymond Date: Fri, 12 Nov 2010 20:10:39 +0000 (-0500) Subject: Improved tag and branch resolution - handles forwards. X-Git-Tag: 0.1~39 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=3e50ae9f6c2f60e21695778958018154ec543192;p=rcs-fast-import.git Improved tag and branch resolution - handles forwards. --- diff --git a/rcs-fast-import b/rcs-fast-import index 4f7668c..396c2c1 100755 --- a/rcs-fast-import +++ b/rcs-fast-import @@ -212,6 +212,7 @@ class Commit: self.fileops = [] # blob and file operation list self.properties = {} # commit properties (extension) self.taglist = [] # Tags that point at this commit + self.branchlist = [] # Branches that point at this commit def children(self): "Get a list of this commit's children." return filter(lambda e:self.mark in e.parent_marks,self.repo.commits()) @@ -493,15 +494,31 @@ class Repository: dp = read_data(cStringIO.StringIO()) 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. self.events.append(line) self.import_line = 0 self.readtime = time.time() + # Resolve tags and branches + for event in self.events: + if isinstance(event, Tag): + for commit in self.commits(): + if commit.mark == event.committish: + commit.taglist.append(tag) + break + else: + raise FatalException("tag points at nonexistent %s" + % event.committish) + elif isinstance(event, Reset) and event.committish is not None: + for commit in self.commits(): + if commit.mark == event.committish: + commit.branchlist.append(tag) + break + else: + raise FatalException("reset points at nonexistent %s" + % event.committish) + except KeyboardInterrupt: nuke(self.subdir(), "rcs-fast-import: import interrupted, removing %s" % self.subdir()) raise KeyboardInterrupt