]> thyrsus.com Git - rcs-fast-import.git/commitdiff
Improved tag and branch resolution - handles forwards.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 12 Nov 2010 20:10:39 +0000 (15:10 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 12 Nov 2010 20:10:39 +0000 (15:10 -0500)
rcs-fast-import

index 4f7668cfeb4f5efc06dd0b1b08abaf77c255b1ce..396c2c1bc0a3bbb55e10db894b4068607c673026 100755 (executable)
@@ -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