# HG changeset patch # User Durham Goode # Date 1435610345 25200 # Node ID 1538e72209fddbf88148de23669e55969d4bd8bc # Parent c1cac25ad1a6be304406d2ec884d82679d4f9897 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(). diff -r c1cac25ad1a6 -r 1538e72209fd hgext/convert/hg.py --- 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 diff -r c1cac25ad1a6 -r 1538e72209fd tests/test-convert-hg-source.t --- 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