Skip to content

Commit

Permalink
remote-bzr: avoid bad refs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Felipe Contreras authored and Junio C Hamano committed May 7, 2013
1 parent 0818112 commit 4c00819
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions contrib/remote-helpers/git-remote-bzr
Original file line number Diff line number Diff line change
Expand Up @@ -682,23 +682,31 @@ def do_export(parser):
die('unhandled export command: %s' % line)

for ref, revid in parsed_refs.iteritems():
name = ref[len('refs/heads/'):]
branch = bzrlib.branch.Branch.open(branches[name])
branch.generate_revision_history(revid, marks.get_tip(name))
if ref.startswith('refs/heads/'):
name = ref[len('refs/heads/'):]
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:
peer.bzrdir.push_branch(branch, revision_id=revid)
except bzrlib.errors.DivergedBranches:
print "error %s non-fast forward" % ref
continue

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

print "ok %s" % ref

Expand Down

0 comments on commit 4c00819

Please sign in to comment.