remote-bzr: avoid bad refs

Versions of fast-export before v1.8.2 throws a bad 'reset' commands
because of a behavior in transport-helper that is not even needed.
We should ignore them, otherwise we will treat them as branches and
fail.

This was fixed in v1.8.2, but some people use this script in older
versions of git.

Also, check if the ref was a tag, and skip it for now.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Felipe Contreras 2013-05-03 19:31:07 -05:00 committed by Junio C Hamano
parent 081811216e
commit 4c00819910
1 changed files with 23 additions and 15 deletions

View File

@ -682,23 +682,31 @@ def do_export(parser):
die('unhandled export command: %s' % line) die('unhandled export command: %s' % line)


for ref, revid in parsed_refs.iteritems(): for ref, revid in parsed_refs.iteritems():
name = ref[len('refs/heads/'):] if ref.startswith('refs/heads/'):
branch = bzrlib.branch.Branch.open(branches[name]) name = ref[len('refs/heads/'):]
branch.generate_revision_history(revid, marks.get_tip(name)) branch = bzrlib.branch.Branch.open(branches[name])
branch.generate_revision_history(revid, marks.get_tip(name))

if name in peers:
peer = bzrlib.branch.Branch.open(peers[name])
try:
peer.bzrdir.push_branch(branch, revision_id=revid)
except bzrlib.errors.DivergedBranches:
print "error %s non-fast forward" % ref
continue


if name in peers:
peer = bzrlib.branch.Branch.open(peers[name])
try: try:
peer.bzrdir.push_branch(branch, revision_id=revid) wt = branch.bzrdir.open_workingtree()
except bzrlib.errors.DivergedBranches: wt.update()
print "error %s non-fast forward" % ref except bzrlib.errors.NoWorkingTree:
continue pass

elif ref.startswith('refs/tags/'):
try: # TODO: implement tag push
wt = branch.bzrdir.open_workingtree() print "error %s pushing tags not supported" % ref
wt.update() continue
except bzrlib.errors.NoWorkingTree: else:
pass # transport-helper/fast-export bugs
continue


print "ok %s" % ref print "ok %s" % ref