remote-bzr: recover from failed clones
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
edca415256
commit
99a4fdb950
@ -769,22 +769,24 @@ def get_remote_branch(origin, remote_branch, name):
|
|||||||
global dirname, peers
|
global dirname, peers
|
||||||
|
|
||||||
branch_path = os.path.join(dirname, 'clone', name)
|
branch_path = os.path.join(dirname, 'clone', name)
|
||||||
if os.path.exists(branch_path):
|
|
||||||
# pull
|
try:
|
||||||
d = bzrlib.bzrdir.BzrDir.open(branch_path)
|
d = bzrlib.bzrdir.BzrDir.open(branch_path)
|
||||||
branch = d.open_branch()
|
branch = d.open_branch()
|
||||||
try:
|
except bzrlib.errors.NotBranchError:
|
||||||
branch.pull(remote_branch, [], None, False)
|
|
||||||
except bzrlib.errors.DivergedBranches:
|
|
||||||
# use remote branch for now
|
|
||||||
return remote_branch
|
|
||||||
else:
|
|
||||||
# clone
|
# clone
|
||||||
d = origin.sprout(branch_path, None,
|
d = origin.sprout(branch_path, None,
|
||||||
hardlink=True, create_tree_if_local=False,
|
hardlink=True, create_tree_if_local=False,
|
||||||
force_new_repo=False,
|
force_new_repo=False,
|
||||||
source_branch=remote_branch)
|
source_branch=remote_branch)
|
||||||
branch = d.open_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
|
return branch
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user