diff options
author | Felipe Contreras <felipe.contreras@gmail.com> | 2013-05-24 21:24:25 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-05-28 07:43:25 -0700 |
commit | e56660a73f778546f7c40989d982ac2f21462975 (patch) | |
tree | adde8af52f5dda4d3122cc8a5b1f5d864ec5d182 /contrib | |
parent | remote-bzr: trivial cleanups (diff) | |
download | tgif-e56660a73f778546f7c40989d982ac2f21462975.tar.xz |
remote-bzr: reorganize the way 'wanted' works
If the user specified a list of branches, we ignore what the remote
repository lists, and simply use the branches directly. Since some
remotes don't report the branches correctly, this is useful.
Otherwise either fetch the repo, or the branch.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/remote-helpers/git-remote-bzr | 58 |
1 files changed, 26 insertions, 32 deletions
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr index 34025c3bea..3248586b13 100755 --- a/contrib/remote-helpers/git-remote-bzr +++ b/contrib/remote-helpers/git-remote-bzr @@ -795,7 +795,7 @@ def get_remote_branch(name): return branch -def find_branches(repo, wanted): +def find_branches(repo): transport = repo.bzrdir.root_transport for fn in transport.iter_files_recursive(): @@ -806,9 +806,6 @@ def find_branches(repo, wanted): 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) @@ -848,38 +845,35 @@ def get_repo(url, alias): except bzrlib.errors.NoRepositoryPresent: pass - try: - repo = origin.open_repository() - if not repo.user_transport.listable(): - # this repository is not usable for us - raise bzrlib.errors.NoRepositoryPresent(repo.bzrdir) - except bzrlib.errors.NoRepositoryPresent: - # branch - - name = 'master' - branch = origin.open_branch().base - - if not is_local: - peers[name] = branch + wanted = get_config('remote-bzr.branches').rstrip().split(', ') + # stupid python + wanted = [e for e in wanted if e] - branches[name] = branch - - return origin + if not wanted: + try: + repo = origin.open_repository() + if not repo.user_transport.listable(): + # this repository is not usable for us + raise bzrlib.errors.NoRepositoryPresent(repo.bzrdir) + except bzrlib.errors.NoRepositoryPresent: + wanted = ['master'] + + if wanted: + def list_wanted(url, wanted): + for name in wanted: + subdir = name if name != 'master' else '' + yield name, bzrlib.urlutils.join(url, subdir) + + branch_list = list_wanted(url, wanted) else: - # repository - - wanted = get_config('remote-bzr.branches').rstrip().split(', ') - # stupid python - wanted = [e for e in wanted if e] + branch_list = find_branches(repo) - for name, branch in find_branches(repo, wanted): - - if not is_local: - peers[name] = branch - - branches[name] = branch + for name, url in branch_list: + if not is_local: + peers[name] = url + branches[name] = url - return origin + return origin def fix_path(alias, orig_url): url = urlparse.urlparse(orig_url, 'file') |