convert: fix crash when filemap filtering is changed
authorMads Kiilerich <madski@unity3d.com>
Wed, 02 Oct 2013 19:46:47 +0200
changeset 19862 42455ebbab9f
parent 19861 a69a77a80900
child 19863 daeab82fa644
convert: fix crash when filemap filtering is changed
hgext/convert/filemap.py
tests/test-convert-filemap.t
--- a/hgext/convert/filemap.py	Tue Oct 01 14:48:53 2013 -0400
+++ b/hgext/convert/filemap.py	Wed Oct 02 19:46:47 2013 +0200
@@ -231,8 +231,8 @@
                 continue
             self.seenchildren[r] = self.seenchildren.get(r, 0) + 1
             if self.seenchildren[r] == self.children[r]:
-                del self.wantedancestors[r]
-                del self.parentmap[r]
+                self.wantedancestors.pop(r, None)
+                self.parentmap.pop(r, None)
                 del self.seenchildren[r]
                 if self._rebuilt:
                     del self.children[r]
@@ -281,7 +281,11 @@
         # of wanted ancestors of its parents. Plus rev itself.
         wrev = set()
         for p in parents:
-            wrev.update(self.wantedancestors[p])
+            if p in self.wantedancestors:
+                wrev.update(self.wantedancestors[p])
+            else:
+                self.ui.warn(_('warning: %s parent %s is missing\n') %
+                             (rev, p))
         wrev.add(rev)
         self.wantedancestors[rev] = wrev
 
--- a/tests/test-convert-filemap.t	Tue Oct 01 14:48:53 2013 -0400
+++ b/tests/test-convert-filemap.t	Wed Oct 02 19:46:47 2013 +0200
@@ -88,6 +88,32 @@
   copied renamed from foo:2ed2a3912a0b24502043eae84ee4b279c18b90dd
 
   $ cd ..
+
+
+Test interaction with startrev and verify that changing it is handled properly:
+
+  $ > empty
+  $ hg convert --filemap empty source movingstart --config convert.hg.startrev=3 -r4
+  initializing destination movingstart repository
+  scanning source...
+  sorting...
+  converting...
+  1 3: change bar quux
+  0 4: first merge; change bar baz
+  $ hg convert --filemap empty source movingstart
+  scanning source...
+  sorting...
+  converting...
+  3 5: change bar baz quux
+  2 6: change foo baz
+  1 7: second merge; change bar
+  warning: af455ce4166b3c9c88e6309c2b9332171dcea595 parent 61e22ca76c3b3e93df20338c4e02ce286898e825 is missing
+  warning: cf908b3eeedc301c9272ebae931da966d5b326c7 parent 59e1ab45c888289513b7354484dac8a88217beab is missing
+  0 8: change foo
+
+
+splitrepo tests
+
   $ splitrepo()
   > {
   >     msg="$1"