summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2013-05-01 01:10:06 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-05-01 05:06:47 (GMT)
commit248663c4ff931f1f42fb7f8233d0ae23f80c7835 (patch)
tree41c00c12dc00fbe528e4f8a57d83516a3d1a6352 /contrib
parent850dd25c9a245da0e6b23c36cf9f45d6ee08b237 (diff)
downloadgit-248663c4ff931f1f42fb7f8233d0ae23f80c7835.zip
git-248663c4ff931f1f42fb7f8233d0ae23f80c7835.tar.gz
git-248663c4ff931f1f42fb7f8233d0ae23f80c7835.tar.bz2
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 <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/remote-helpers/git-remote-bzr20
1 files changed, 18 insertions, 2 deletions
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index 11f2415..d284afc 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -13,6 +13,9 @@
# or
# % git clone bzr::lp:myrepo
#
+# If you want to specify which branches you want track (per repo):
+# git config remote-bzr.branches 'trunk, devel, test'
+#
import sys
@@ -51,6 +54,12 @@ def warn(msg, *args):
def gittz(tz):
return '%+03d%02d' % (tz / 3600, tz % 3600 / 60)
+def get_config(config):
+ cmd = ['git', 'config', '--get', config]
+ process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ output, _ = process.communicate()
+ return output
+
class Marks:
def __init__(self, path):
@@ -756,7 +765,7 @@ def get_remote_branch(origin, remote_branch, name):
return branch
-def find_branches(repo):
+def find_branches(repo, wanted):
transport = repo.user_transport
for fn in transport.iter_files_recursive():
@@ -767,6 +776,9 @@ def find_branches(repo):
name = name if name != '' else 'master'
name = name.replace('/', '+')
+ if wanted and not name in wanted:
+ continue
+
try:
cur = transport.clone(subdir)
branch = bzrlib.branch.Branch.open_from_transport(cur)
@@ -815,7 +827,11 @@ def get_repo(url, alias):
else:
# repository
- for name, branch in find_branches(repo):
+ wanted = get_config('remote-bzr.branches').rstrip().split(', ')
+ # stupid python
+ wanted = [e for e in wanted if e]
+
+ for name, branch in find_branches(repo, wanted):
if not is_local:
peers[name] = branch