changeset 25697:1538e72209fd

convert: fix bug with converting the same commit twice Convert had a bug where it relied on repo.tip() to be the newly committed commit. This was not the case if the commit already existed in the repository (since repo.commitctx() did nothing, the tip() referenced some random other commit and the revmap got corrupted). This fixes it by using the node returned by repo.commitctx().
author Durham Goode <durham@fb.com>
date Mon, 29 Jun 2015 13:39:05 -0700
parents c1cac25ad1a6
children 307370c2dda2
files hgext/convert/hg.py tests/test-convert-hg-source.t
diffstat 2 files changed, 40 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/hg.py	Sat Jun 27 15:28:46 2015 +0900
+++ b/hgext/convert/hg.py	Mon Jun 29 13:39:05 2015 -0700
@@ -284,7 +284,7 @@
                 tr.release()
 
             text = "(octopus merge fixup)\n"
-            p2 = hex(self.repo.changelog.tip())
+            p2 = node
 
         if self.filemapmode and nparents == 1:
             man = self.repo.manifest
@@ -344,8 +344,8 @@
         ctx = context.memctx(self.repo, (tagparent, None), "update tags",
                              [".hgtags"], getfilectx, "convert-repo", date,
                              extra)
-        self.repo.commitctx(ctx)
-        return hex(self.repo.changelog.tip()), hex(tagparent)
+        node = self.repo.commitctx(ctx)
+        return hex(node), hex(tagparent)
 
     def setfilemapmode(self, active):
         self.filemapmode = active
--- a/tests/test-convert-hg-source.t	Sat Jun 27 15:28:46 2015 +0900
+++ b/tests/test-convert-hg-source.t	Mon Jun 29 13:39:05 2015 -0700
@@ -83,7 +83,43 @@
      premerge1                 3:973ef48a98a4
      premerge2                 8:3537b15eaaca
 #endif
-  $ cd ..
+
+Test that redoing a convert results in an identical graph
+  $ cd ../
+  $ rm new/.hg/shamap
+  $ hg convert --datesort orig new 2>&1 | grep -v 'subversion python bindings could not be loaded'
+  scanning source...
+  sorting...
+  converting...
+  8 add foo bar
+  7 change foo
+  6 make bar and baz copies of foo
+  5 merge local copy
+  4 merge remote copy
+  3 Added tag that for changeset 88586c4e9f02
+  2 Removed tag that
+  1 Added tag this for changeset c56a7f387039
+  0 mark baz executable
+  updating bookmarks
+  $ hg -R new log -G -T '{rev} {desc}'
+  o  8 mark baz executable
+  |
+  o  7 Added tag this for changeset c56a7f387039
+  |
+  o  6 Removed tag that
+  |
+  o  5 Added tag that for changeset 88586c4e9f02
+  |
+  o    4 merge remote copy
+  |\
+  +---o  3 merge local copy
+  | |/
+  | o  2 make bar and baz copies of foo
+  | |
+  o |  1 change foo
+  |/
+  o  0 add foo bar
+  
 
 check shamap LF and CRLF handling