convert: fix crash when existing converted revision didn't come from source
authorMads Kiilerich <madski@unity3d.com>
Wed, 02 Oct 2013 19:46:48 +0200
changeset 19863 daeab82fa644
parent 19862 42455ebbab9f
child 19864 1ce3f56b879f
convert: fix crash when existing converted revision didn't come from source This case can happen when converting from multiple repositories with filemap.
hgext/convert/filemap.py
tests/test-convert-filemap.t
--- a/hgext/convert/filemap.py	Wed Oct 02 19:46:47 2013 +0200
+++ b/hgext/convert/filemap.py	Wed Oct 02 19:46:48 2013 +0200
@@ -7,7 +7,7 @@
 import posixpath
 import shlex
 from mercurial.i18n import _
-from mercurial import util
+from mercurial import util, error
 from common import SKIPREV, converter_source
 
 def rpairs(name):
@@ -195,12 +195,19 @@
         self.seenchildren.clear()
         for rev, wanted, arg in self.convertedorder:
             if rev not in self.origparents:
-                self.origparents[rev] = self.getcommit(rev).parents
+                try:
+                    self.origparents[rev] = self.getcommit(rev).parents
+                except error.RepoLookupError:
+                    self.ui.debug("unknown revmap source: %s\n" % rev)
+                    continue
             if arg is not None:
                 self.children[arg] = self.children.get(arg, 0) + 1
 
         for rev, wanted, arg in self.convertedorder:
-            parents = self.origparents[rev]
+            try:
+                parents = self.origparents[rev]
+            except KeyError:
+                continue # unknown revmap source
             if wanted:
                 self.mark_wanted(rev, parents)
             else:
--- a/tests/test-convert-filemap.t	Wed Oct 02 19:46:47 2013 +0200
+++ b/tests/test-convert-filemap.t	Wed Oct 02 19:46:48 2013 +0200
@@ -410,6 +410,32 @@
   o  0 "addb" files: b
   
 
+Test rebuilding of map with unknown revisions in shamap - it used to crash
+
+  $ cd branchpruning
+  $ hg up -r 2
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg merge 4
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg ci -m 'merging something'
+  $ cd ..
+  $ echo "53792d18237d2b64971fa571936869156655338d 6d955580116e82c4b029bd30f321323bae71a7f0" >> branchpruning-hg2/.hg/shamap
+  $ hg convert --filemap branchpruning/filemap branchpruning branchpruning-hg2 --debug
+  run hg source pre-conversion action
+  run hg sink pre-conversion action
+  scanning source...
+  scanning: 1 revisions
+  sorting...
+  converting...
+  0 merging something
+  source: 2503605b178fe50e8fbbb0e77b97939540aa8c87
+  converting: 0/1 revisions (0.00%)
+  unknown revmap source: 53792d18237d2b64971fa571936869156655338d
+  run hg sink post-conversion action
+  run hg source post-conversion action
+
+
 filemap rename undoing revision rename
 
   $ hg init renameundo