summaryrefslogtreecommitdiff
path: root/contrib/remote-helpers/git-remote-bzr
diff options
context:
space:
mode:
authorLibravatar Felipe Contreras <felipe.contreras@gmail.com>2013-04-30 20:10:05 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-04-30 22:06:47 -0700
commit850dd25c9a245da0e6b23c36cf9f45d6ee08b237 (patch)
treed533649d864f9abbc9cb788acb68da72226b5694 /contrib/remote-helpers/git-remote-bzr
parentremote-bzr: improve author sanitazion (diff)
downloadtgif-850dd25c9a245da0e6b23c36cf9f45d6ee08b237.tar.xz
remote-bzr: add custom method to find branches
The official method is incredibly inefficient and slow. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/remote-helpers/git-remote-bzr')
-rwxr-xr-xcontrib/remote-helpers/git-remote-bzr25
1 files changed, 20 insertions, 5 deletions
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index af46016dc9..11f24152bf 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -756,6 +756,25 @@ def get_remote_branch(origin, remote_branch, name):
return branch
+def find_branches(repo):
+ transport = repo.user_transport
+
+ for fn in transport.iter_files_recursive():
+ if not fn.endswith('.bzr/branch-format'):
+ continue
+
+ name = subdir = fn[:-len('/.bzr/branch-format')]
+ name = name if name != '' else 'master'
+ name = name.replace('/', '+')
+
+ try:
+ cur = transport.clone(subdir)
+ branch = bzrlib.branch.Branch.open_from_transport(cur)
+ except bzrlib.errors.NotBranchError:
+ continue
+ else:
+ yield name, branch
+
def get_repo(url, alias):
global dirname, peer, branches
@@ -796,11 +815,7 @@ def get_repo(url, alias):
else:
# repository
- for branch in repo.find_branches():
-
- name = repo.user_transport.relpath(branch.base)
- name = name if name != '' else 'master'
- name = name.replace('/', '+')
+ for name, branch in find_branches(repo):
if not is_local:
peers[name] = branch