From e24fa42b87455a541947bc64ffb68c2fdbbea8d1 Mon Sep 17 00:00:00 2001 From: Barry Wardell Date: Mon, 5 Dec 2011 23:13:57 +0000 Subject: [PATCH] Commits with no parent need a reset command. This fixes a problem where a repository is imported incorrectly when there is a merge between two branches with no common history. --- hg-fast-export.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hg-fast-export.py b/hg-fast-export.py index 519b556..2da0289 100755 --- a/hg-fast-export.py +++ b/hg-fast-export.py @@ -161,6 +161,11 @@ def export_commit(ui,repo,revision,old_marks,max,count,authors,sob,brmap): branch=get_branchname(branch) + parents = [p for p in repo.changelog.parentrevs(revision) if p >= 0] + + if len(parents)==0 and revision != 0: + wr('reset refs/heads/%s' % branch) + wr('commit refs/heads/%s' % branch) wr('mark :%d' % (revision+1)) if sob: @@ -170,7 +175,6 @@ def export_commit(ui,repo,revision,old_marks,max,count,authors,sob,brmap): wr(desc) wr() - parents = [p for p in repo.changelog.parentrevs(revision) if p >= 0] # Sort the parents based on revision ids so that we always get the # same resulting git repo, no matter how the revisions were -- 2.11.4.GIT