Skip to content

Commit 248663c

Browse files
felipecgitster
authored andcommitted
remote-bzr: add option to specify branches
We might not want all the branches. And branch handling in bazaar is rather tricky, so it's safer to simply specify them. Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 850dd25 commit 248663c

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

contrib/remote-helpers/git-remote-bzr

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# or
1414
# % git clone bzr::lp:myrepo
1515
#
16+
# If you want to specify which branches you want track (per repo):
17+
# git config remote-bzr.branches 'trunk, devel, test'
18+
#
1619

1720
import sys
1821

@@ -51,6 +54,12 @@ def warn(msg, *args):
5154
def gittz(tz):
5255
return '%+03d%02d' % (tz / 3600, tz % 3600 / 60)
5356

57+
def get_config(config):
58+
cmd = ['git', 'config', '--get', config]
59+
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
60+
output, _ = process.communicate()
61+
return output
62+
5463
class Marks:
5564

5665
def __init__(self, path):
@@ -756,7 +765,7 @@ def get_remote_branch(origin, remote_branch, name):
756765

757766
return branch
758767

759-
def find_branches(repo):
768+
def find_branches(repo, wanted):
760769
transport = repo.user_transport
761770

762771
for fn in transport.iter_files_recursive():
@@ -767,6 +776,9 @@ def find_branches(repo):
767776
name = name if name != '' else 'master'
768777
name = name.replace('/', '+')
769778

779+
if wanted and not name in wanted:
780+
continue
781+
770782
try:
771783
cur = transport.clone(subdir)
772784
branch = bzrlib.branch.Branch.open_from_transport(cur)
@@ -815,7 +827,11 @@ def get_repo(url, alias):
815827
else:
816828
# repository
817829

818-
for name, branch in find_branches(repo):
830+
wanted = get_config('remote-bzr.branches').rstrip().split(', ')
831+
# stupid python
832+
wanted = [e for e in wanted if e]
833+
834+
for name, branch in find_branches(repo, wanted):
819835

820836
if not is_local:
821837
peers[name] = branch

0 commit comments

Comments
 (0)