summaryrefslogtreecommitdiff
path: root/contrib/remote-helpers/git-remote-bzr
diff options
context:
space:
mode:
authorLibravatar Felipe Contreras <felipe.contreras@gmail.com>2013-05-24 21:24:21 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2013-05-28 07:43:18 -0700
commit1bf09d4fbf402e42b3a0be2411a9c4feb1ba8d25 (patch)
treed1b7b81ff5f877fe9237c14eeb78699573e7b62c /contrib/remote-helpers/git-remote-bzr
parentremote-bzr: fix for files with spaces (diff)
downloadtgif-1bf09d4fbf402e42b3a0be2411a9c4feb1ba8d25.tar.xz
remote-bzr: simplify get_remote_branch()
No need for 'origin', it's only needed for the bzrdir 'sprout' method, which can be greatly simplified. 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-bzr23
1 files changed, 12 insertions, 11 deletions
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index 35664c6523..5c4201ac31 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -765,25 +765,26 @@ def do_list(parser):
print "@refs/heads/%s HEAD" % master_branch
print
-def get_remote_branch(origin, remote_branch, name):
+def clone(path, remote_branch):
+ bdir = bzrlib.bzrdir.BzrDir.create(path)
+ repo = bdir.find_repository()
+ repo.fetch(remote_branch.repository)
+ return remote_branch.sprout(bdir, repository=repo)
+
+def get_remote_branch(remote_branch, name):
global dirname, peers
branch_path = os.path.join(dirname, 'clone', name)
try:
- d = bzrlib.bzrdir.BzrDir.open(branch_path)
- branch = d.open_branch()
+ branch = bzrlib.branch.Branch.open(branch_path)
except bzrlib.errors.NotBranchError:
# clone
- d = origin.sprout(branch_path, None,
- hardlink=True, create_tree_if_local=False,
- force_new_repo=False,
- source_branch=remote_branch)
- branch = d.open_branch()
+ branch = clone(branch_path, remote_branch)
else:
# pull
try:
- branch.pull(remote_branch, [], None, False)
+ branch.pull(remote_branch, overwrite=True)
except bzrlib.errors.DivergedBranches:
# use remote branch for now
return remote_branch
@@ -856,7 +857,7 @@ def get_repo(url, alias):
if not is_local:
peers[name] = remote_branch.base
- branch = get_remote_branch(origin, remote_branch, name)
+ branch = get_remote_branch(remote_branch, name)
else:
branch = remote_branch
@@ -874,7 +875,7 @@ def get_repo(url, alias):
if not is_local:
peers[name] = remote_branch.base
- branch = get_remote_branch(origin, remote_branch, name)
+ branch = get_remote_branch(remote_branch, name)
else:
branch = remote_branch