From: Barry Wardell Date: Mon, 5 Dec 2011 23:13:57 +0000 (+0000) Subject: Commits with no parent need a reset command. X-Git-Tag: v160415~50 X-Git-Url: https://repo.or.cz/w/fast-export.git/commitdiff_plain/e24fa42b87455a541947bc64ffb68c2fdbbea8d1 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. --- 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