convert/hg: handle bogus copy records (issue1843)
authorPatrick Mezard <pmezard@gmail.com>
Wed, 07 Oct 2009 18:52:01 +0200
changeset 9532 989cb39d1df4
parent 9531 a2f36a082449
child 9533 e151b66bcf38
child 9546 4333b9744419
child 9572 1f665246dab3
convert/hg: handle bogus copy records (issue1843)
hgext/convert/hg.py
--- a/hgext/convert/hg.py	Wed Oct 07 10:13:04 2009 +0200
+++ b/hgext/convert/hg.py	Wed Oct 07 18:52:01 2009 +0200
@@ -274,7 +274,7 @@
             if self.ignoreerrors:
                 # calling getcopies() is a simple way to detect missing
                 # revlogs and populate self.ignored
-                self.getcopies(ctx, files)
+                self.getcopies(ctx, parents, files)
             return [(f, rev) for f in files if f not in self.ignored], {}
         if self._changescache and self._changescache[0] == rev:
             m, a, r = self._changescache[1]
@@ -282,12 +282,12 @@
             m, a, r = self.repo.status(parents[0].node(), ctx.node())[:3]
         # getcopies() detects missing revlogs early, run it before
         # filtering the changes.
-        copies = self.getcopies(ctx, m + a)
+        copies = self.getcopies(ctx, parents, m + a)
         changes = [(name, rev) for name in m + a + r
                    if name not in self.ignored]
         return sorted(changes), copies
 
-    def getcopies(self, ctx, files):
+    def getcopies(self, ctx, parents, files):
         copies = {}
         for name in files:
             if name in self.ignored:
@@ -296,6 +296,14 @@
                 copysource, copynode = ctx.filectx(name).renamed()
                 if copysource in self.ignored or not self.keep(copynode):
                     continue
+                # Ignore copy sources not in parent revisions
+                found = False
+                for p in parents:
+                    if copysource in p:
+                        found = True
+                        break
+                if not found:
+                    continue
                 copies[name] = copysource
             except TypeError:
                 pass