From e467b22dd36ddf8aa8f9c9f49d3937080128af62 Mon Sep 17 00:00:00 2001 From: David Turner Date: Fri, 21 Apr 2017 16:37:10 -0400 Subject: [PATCH] Fix obscure bug with multiple independent histories If you have a repository with multiple independent histories (perhaps that get merged later), under some circumstances revision 0 can get imported *after* some other revision. "Independent histories" are those that start from different zero-parent commits. I have thus far failed to get a local reproduction on this, in part because I don't understand how git-remote-hg choses the order in which to import branches. But we did notice this in our production system. If revision 0 is imported late, a reset would not be issued, and it would be wrongly re-parented on top of whatever previous history existed, instead of being a root-level commit. Fix this by always issuing a reset for a parentless commit, even on revision 0. --- git-remote-hg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-remote-hg b/git-remote-hg index 13ef9c2..bf37ac6 100755 --- a/git-remote-hg +++ b/git-remote-hg @@ -581,7 +581,7 @@ def export_ref(repo, name, kind, head): if extra_msg: desc += '\n--HG--\n' + extra_msg - if len(parents) == 0 and rev: + if len(parents) == 0: print 'reset %s/%s' % (prefix, ename) modified_final = export_files(c.filectx(f) for f in modified)