1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-01 23:07:55 +01:00

remote-bzr: detect local repositories

So we don't create a clone unnecessarily.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Felipe Contreras 2012-11-28 02:01:35 +01:00 committed by Junio C Hamano
parent 570e7ecd4a
commit 073c3ffa58

View file

@ -24,6 +24,7 @@ import bzrlib.plugin
bzrlib.plugin.load_plugins() bzrlib.plugin.load_plugins()
import bzrlib.generate_ids import bzrlib.generate_ids
import bzrlib.transport
import sys import sys
import os import os
@ -613,11 +614,14 @@ def do_export(parser):
if ref == 'refs/heads/master': if ref == 'refs/heads/master':
repo.generate_revision_history(revid, marks.get_tip('master')) repo.generate_revision_history(revid, marks.get_tip('master'))
revno, revid = repo.last_revision_info() revno, revid = repo.last_revision_info()
if peer:
if hasattr(peer, "import_last_revision_info_and_tags"): if hasattr(peer, "import_last_revision_info_and_tags"):
peer.import_last_revision_info_and_tags(repo, revno, revid) peer.import_last_revision_info_and_tags(repo, revno, revid)
else: else:
peer.import_last_revision_info(repo.repository, revno, revid) peer.import_last_revision_info(repo.repository, revno, revid)
wt = peer.bzrdir.open_workingtree() wt = peer.bzrdir.open_workingtree()
else:
wt = repo.bzrdir.open_workingtree()
wt.update() wt.update()
print "ok %s" % ref print "ok %s" % ref
print print
@ -649,10 +653,12 @@ def do_list(parser):
def get_repo(url, alias): def get_repo(url, alias):
global dirname, peer global dirname, peer
clone_path = os.path.join(dirname, 'clone')
origin = bzrlib.bzrdir.BzrDir.open(url) origin = bzrlib.bzrdir.BzrDir.open(url)
remote_branch = origin.open_branch() branch = origin.open_branch()
if not isinstance(origin.transport, bzrlib.transport.local.LocalTransport):
clone_path = os.path.join(dirname, 'clone')
remote_branch = branch
if os.path.exists(clone_path): if os.path.exists(clone_path):
# pull # pull
d = bzrlib.bzrdir.BzrDir.open(clone_path) d = bzrlib.bzrdir.BzrDir.open(clone_path)
@ -667,6 +673,8 @@ def get_repo(url, alias):
branch.bind(remote_branch) branch.bind(remote_branch)
peer = remote_branch peer = remote_branch
else:
peer = None
return branch return branch