summaryrefslogtreecommitdiff
path: root/contrib/remote-helpers
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2013-05-24 21:24:19 -0500
committerJunio C Hamano <gitster@pobox.com>2013-05-28 07:43:18 -0700
commit99a4fdb950b214de3a0ad0ac255f6a2491f975d4 (patch)
treeeea8829c6931965e911d7b64c5c94fb2d3366890 /contrib/remote-helpers
parentedca4152560522a431a51fc0a06147fc680b5b18 (diff)
downloadgit-99a4fdb950b214de3a0ad0ac255f6a2491f975d4.tar.gz
remote-bzr: recover from failed clones
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/remote-helpers')
-rwxr-xr-xcontrib/remote-helpers/git-remote-bzr18
1 files changed, 10 insertions, 8 deletions
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index 10300c63d1..8a4df51fad 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -769,22 +769,24 @@ def get_remote_branch(origin, remote_branch, name):
global dirname, peers
branch_path = os.path.join(dirname, 'clone', name)
- if os.path.exists(branch_path):
- # pull
+
+ try:
d = bzrlib.bzrdir.BzrDir.open(branch_path)
branch = d.open_branch()
- try:
- branch.pull(remote_branch, [], None, False)
- except bzrlib.errors.DivergedBranches:
- # use remote branch for now
- return remote_branch
- else:
+ 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()
+ else:
+ # pull
+ try:
+ branch.pull(remote_branch, [], None, False)
+ except bzrlib.errors.DivergedBranches:
+ # use remote branch for now
+ return remote_branch
return branch