Skip to content

Commit 850dd25

Browse files
felipecgitster
authored andcommitted
remote-bzr: add custom method to find branches
The official method is incredibly inefficient and slow. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3f6e7c0 commit 850dd25

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

contrib/remote-helpers/git-remote-bzr

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,25 @@ def get_remote_branch(origin, remote_branch, name):
756756

757757
return branch
758758

759+
def find_branches(repo):
760+
transport = repo.user_transport
761+
762+
for fn in transport.iter_files_recursive():
763+
if not fn.endswith('.bzr/branch-format'):
764+
continue
765+
766+
name = subdir = fn[:-len('/.bzr/branch-format')]
767+
name = name if name != '' else 'master'
768+
name = name.replace('/', '+')
769+
770+
try:
771+
cur = transport.clone(subdir)
772+
branch = bzrlib.branch.Branch.open_from_transport(cur)
773+
except bzrlib.errors.NotBranchError:
774+
continue
775+
else:
776+
yield name, branch
777+
759778
def get_repo(url, alias):
760779
global dirname, peer, branches
761780

@@ -796,11 +815,7 @@ def get_repo(url, alias):
796815
else:
797816
# repository
798817

799-
for branch in repo.find_branches():
800-
801-
name = repo.user_transport.relpath(branch.base)
802-
name = name if name != '' else 'master'
803-
name = name.replace('/', '+')
818+
for name, branch in find_branches(repo):
804819

805820
if not is_local:
806821
peers[name] = branch

0 commit comments

Comments
 (0)