diff options
author | Felipe Contreras <felipe.contreras@gmail.com> | 2012-11-28 02:01:35 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-01-02 20:07:00 -0800 |
commit | 073c3ffa582a4d449b7088108a1e302c9169063b (patch) | |
tree | 19d6994c7a6cae351916484c300bdb9a81fdf86f | |
parent | remote-bzr: add support for older versions of bzr (diff) | |
download | tgif-073c3ffa582a4d449b7088108a1e302c9169063b.tar.xz |
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>
-rwxr-xr-x | contrib/remote-helpers/git-remote-bzr | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr index 6cdfac6dc6..c5822e4ac9 100755 --- a/contrib/remote-helpers/git-remote-bzr +++ b/contrib/remote-helpers/git-remote-bzr @@ -24,6 +24,7 @@ import bzrlib.plugin bzrlib.plugin.load_plugins() import bzrlib.generate_ids +import bzrlib.transport import sys import os @@ -613,11 +614,14 @@ def do_export(parser): if ref == 'refs/heads/master': repo.generate_revision_history(revid, marks.get_tip('master')) revno, revid = repo.last_revision_info() - if hasattr(peer, "import_last_revision_info_and_tags"): - peer.import_last_revision_info_and_tags(repo, revno, revid) + if peer: + if hasattr(peer, "import_last_revision_info_and_tags"): + peer.import_last_revision_info_and_tags(repo, revno, revid) + else: + peer.import_last_revision_info(repo.repository, revno, revid) + wt = peer.bzrdir.open_workingtree() else: - peer.import_last_revision_info(repo.repository, revno, revid) - wt = peer.bzrdir.open_workingtree() + wt = repo.bzrdir.open_workingtree() wt.update() print "ok %s" % ref print @@ -649,24 +653,28 @@ def do_list(parser): def get_repo(url, alias): global dirname, peer - clone_path = os.path.join(dirname, 'clone') origin = bzrlib.bzrdir.BzrDir.open(url) - remote_branch = origin.open_branch() - - if os.path.exists(clone_path): - # pull - d = bzrlib.bzrdir.BzrDir.open(clone_path) - branch = d.open_branch() - result = branch.pull(remote_branch, [], None, False) + 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): + # pull + d = bzrlib.bzrdir.BzrDir.open(clone_path) + branch = d.open_branch() + result = branch.pull(remote_branch, [], None, False) + else: + # clone + d = origin.sprout(clone_path, None, + hardlink=True, create_tree_if_local=False, + source_branch=remote_branch) + branch = d.open_branch() + branch.bind(remote_branch) + + peer = remote_branch else: - # clone - d = origin.sprout(clone_path, None, - hardlink=True, create_tree_if_local=False, - source_branch=remote_branch) - branch = d.open_branch() - branch.bind(remote_branch) - - peer = remote_branch + peer = None return branch |