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>
Felipe Contreras committed
May 3, 2013 at 19:31 UTC
4c00819910706aa8ae450292085e47e52c333440
1 file changed
+23
-15
contrib/remote-helpers/git-remote-bzr
+23
-15
@@ -682,23 +682,31 @@ def do_export(parser):
682
die('unhandled export command: %s' % line)
683
684
for ref, revid in parsed_refs.iteritems():
685
- name = ref[len('refs/heads/'):]
686
- branch = bzrlib.branch.Branch.open(branches[name])
687
- branch.generate_revision_history(revid, marks.get_tip(name))
685
+ if ref.startswith('refs/heads/'):
686
+ name = ref[len('refs/heads/'):]
687
+ branch = bzrlib.branch.Branch.open(branches[name])
688
+ branch.generate_revision_history(revid, marks.get_tip(name))
689
689
- if name in peers:
690
- peer = bzrlib.branch.Branch.open(peers[name])
691
- try:
692
- peer.bzrdir.push_branch(branch, revision_id=revid)
693
- except bzrlib.errors.DivergedBranches:
694
- print "error %s non-fast forward" % ref
695
- continue
690
+ if name in peers:
691
+ peer = bzrlib.branch.Branch.open(peers[name])
692
+ try:
693
+ peer.bzrdir.push_branch(branch, revision_id=revid)
694
+ except bzrlib.errors.DivergedBranches:
695
+ print "error %s non-fast forward" % ref
696
+ continue
697
697
- try:
698
- wt = branch.bzrdir.open_workingtree()
699
- wt.update()
700
- except bzrlib.errors.NoWorkingTree:
701
- pass
698
+ try:
699
+ wt = branch.bzrdir.open_workingtree()
700
+ wt.update()
701
+ except bzrlib.errors.NoWorkingTree:
702
+ pass
703
+ elif ref.startswith('refs/tags/'):
704
+ # TODO: implement tag push
705
+ print "error %s pushing tags not supported" % ref
706
+ continue
707
+ else:
708
+ # transport-helper/fast-export bugs
709
+ continue
710
711
print "ok %s" % ref
712