changeset 9532:989cb39d1df4

convert/hg: handle bogus copy records (issue1843)
author Patrick Mezard <pmezard@gmail.com>
date Wed, 07 Oct 2009 18:52:01 +0200
parents a2f36a082449
children e151b66bcf38 4333b9744419 1f665246dab3
files hgext/convert/hg.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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