remote-bzr: add support for older versions of bzr

At least as old as 2.0. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Nov 28, 2012 at 02:01 UTC 570e7ecd4a69609641a64eded872c166a37ef9c0
1 file changed +9 -5
contrib/remote-helpers/git-remote-bzr
+9 -5
@@ -17,7 +17,8 @@
17 import sys
18
19 import bzrlib
20 -bzrlib.initialize()
20 +if hasattr(bzrlib, "initialize"):
21 + bzrlib.initialize()
22
23 import bzrlib.plugin
24 bzrlib.plugin.load_plugins()
@@ -553,7 +554,7 @@ def parse_commit(parser):
554
555 repo.lock_write()
556 try:
556 - builder = repo.get_commit_builder(parents, None, date, tz, committer, props, revid, False)
557 + builder = repo.get_commit_builder(parents, None, date, tz, committer, props, revid)
558 try:
559 list(builder.record_iter_changes(mtree, mtree.last_revision(), changes))
560 builder.finish_inventory()
@@ -612,7 +613,10 @@ def do_export(parser):
613 if ref == 'refs/heads/master':
614 repo.generate_revision_history(revid, marks.get_tip('master'))
615 revno, revid = repo.last_revision_info()
615 - peer.import_last_revision_info_and_tags(repo, revno, revid)
616 + if hasattr(peer, "import_last_revision_info_and_tags"):
617 + peer.import_last_revision_info_and_tags(repo, revno, revid)
618 + else:
619 + peer.import_last_revision_info(repo.repository, revno, revid)
620 wt = peer.bzrdir.open_workingtree()
621 wt.update()
622 print "ok %s" % ref
@@ -646,12 +650,12 @@ def get_repo(url, alias):
650 global dirname, peer
651
652 clone_path = os.path.join(dirname, 'clone')
649 - origin = bzrlib.controldir.ControlDir.open(url)
653 + origin = bzrlib.bzrdir.BzrDir.open(url)
654 remote_branch = origin.open_branch()
655
656 if os.path.exists(clone_path):
657 # pull
654 - d = bzrlib.controldir.ControlDir.open(clone_path)
658 + d = bzrlib.bzrdir.BzrDir.open(clone_path)
659 branch = d.open_branch()
660 result = branch.pull(remote_branch, [], None, False)
661 else: