From: Rocco Rutte Date: Tue, 27 Jan 2009 14:34:46 +0000 (+0100) Subject: hg-fast-export: Support branches without parents X-Git-Url: http://crossforests.com/gitweb?a=commitdiff_plain;h=688623f17e60e713ad687fee62cdbe3cecace3cd;p=python%2Ffast-export.git hg-fast-export: Support branches without parents Previously we fed the full revision only for the first one and deltas for all following including branches being forked off. This doesn't work with branches that are forked from revision 0. In case such a branch is found, we now also feed the full revision. Signed-off-by: Rocco Rutte --- diff --git a/hg-fast-export.py b/hg-fast-export.py index 2b61a0f..6de1e0a 100755 --- a/hg-fast-export.py +++ b/hg-fast-export.py @@ -183,6 +183,9 @@ def export_commit(ui,repo,revision,marks,mapping,heads,last,max,count,authors,so if parents[0] < parents[1]: pidx1, pidx2 = 1, 0 + full_rev=False + if revision==0: full_rev=True + src=heads.get(branch,'') link='' if src!='': @@ -194,12 +197,16 @@ def export_commit(ui,repo,revision,marks,mapping,heads,last,max,count,authors,so (branch,src)) link=src # avoid making a merge commit for incremental import elif link=='' and not heads.has_key(branch) and revision>0: - # newly created branch and not the first one: connect to parent - tmp=get_parent_mark(parents[0],marks) - wr('from %s' % tmp) - sys.stderr.write('%s: Link new branch to parent [%s]\n' % - (branch,tmp)) - link=tmp # avoid making a merge commit for branch fork + if parents[0]>=0: + # newly created branch with parent: connect to parent + tmp=get_parent_mark(parents[0],marks) + wr('from %s' % tmp) + sys.stderr.write('%s: Link new branch to parent [%s]\n' % + (branch,tmp)) + link=tmp # avoid making a merge commit for branch fork + else: + # newly created branch without parent: feed full revision + full_rev=True elif last.get(branch,revision) != parents[pidx1] and parents[pidx1] > 0 and revision > 0: pm=get_parent_mark(parents[pidx1],marks) sys.stderr.write('%s: Placing commit [r%d] in branch [%s] on top of [r%d]\n' % @@ -221,7 +228,7 @@ def export_commit(ui,repo,revision,marks,mapping,heads,last,max,count,authors,so man=ctx.manifest() added,changed,removed,type=[],[],[],'' - if revision==0: + if full_rev: # first revision: feed in full manifest added=man.keys() added.sort()