Skip to content

Commit 4f5e972

Browse files
committed
Merge branch 'fc/remote-hg-shared-setup'
* fc/remote-hg-shared-setup: remote-hg: add shared repo upgrade remote-hg: ensure shared repo is initialized
2 parents 2bdd872 + 3baacc5 commit 4f5e972

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

contrib/remote-helpers/git-remote-hg

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,11 +391,24 @@ def get_repo(url, alias):
391391
os.makedirs(dirname)
392392
else:
393393
shared_path = os.path.join(gitdir, 'hg')
394-
if not os.path.exists(shared_path):
395-
try:
396-
hg.clone(myui, {}, url, shared_path, update=False, pull=True)
397-
except:
398-
die('Repository error')
394+
395+
# check and upgrade old organization
396+
hg_path = os.path.join(shared_path, '.hg')
397+
if os.path.exists(shared_path) and not os.path.exists(hg_path):
398+
repos = os.listdir(shared_path)
399+
for x in repos:
400+
local_hg = os.path.join(shared_path, x, 'clone', '.hg')
401+
if not os.path.exists(local_hg):
402+
continue
403+
if not os.path.exists(hg_path):
404+
shutil.move(local_hg, hg_path)
405+
shutil.rmtree(os.path.join(shared_path, x, 'clone'))
406+
407+
# setup shared repo (if not there)
408+
try:
409+
hg.peer(myui, {}, shared_path, create=True)
410+
except error.RepoError:
411+
pass
399412

400413
if not os.path.exists(dirname):
401414
os.makedirs(dirname)

0 commit comments

Comments
 (0)