remote-bzr: add support for remote repositories
Strictly speaking bzr doesn't need any changes to interact with remote repositories, but it's dead slow. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Nov 11, 2012 at 15:19 UTC
dc2177c21c249460bf9c809ac248ca588bc3b988
1 file changed
+24
-2
contrib/remote-helpers/git-remote-bzr
+24
-2
@@ -546,7 +546,7 @@ def parse_reset(parser):
546
parsed_refs[ref] = mark_to_rev(from_mark)
547
548
def do_export(parser):
549
- global parsed_refs, dirname
549
+ global parsed_refs, dirname, peer
550
551
parser.next()
552
@@ -569,6 +569,8 @@ def do_export(parser):
569
for ref, revid in parsed_refs.iteritems():
570
if ref == 'refs/heads/master':
571
repo.generate_revision_history(revid, marks.get_tip('master'))
572
+ revno, revid = repo.last_revision_info()
573
+ peer.import_last_revision_info_and_tags(repo, revno, revid)
574
print "ok %s" % ref
575
print
576
@@ -597,8 +599,28 @@ def do_list(parser):
599
print
600
601
def get_repo(url, alias):
602
+ global dirname, peer
603
+
604
+ clone_path = os.path.join(dirname, 'clone')
605
origin = bzrlib.controldir.ControlDir.open(url)
601
- return origin.open_branch()
606
+ remote_branch = origin.open_branch()
607
+
608
+ if os.path.exists(clone_path):
609
+ # pull
610
+ d = bzrlib.controldir.ControlDir.open(clone_path)
611
+ branch = d.open_branch()
612
+ result = branch.pull(remote_branch, [], None, False)
613
+ else:
614
+ # clone
615
+ d = origin.sprout(clone_path, None,
616
+ hardlink=True, create_tree_if_local=False,
617
+ source_branch=remote_branch)
618
+ branch = d.open_branch()
619
+ branch.bind(remote_branch)
620
+
621
+ peer = remote_branch
622
+
623
+ return branch
624
625
def main(args):
626
global marks, prefix, dirname