Skip to content

Commit 3baacc5

Browse files
felipecgitster
authored andcommitted
remote-hg: add shared repo upgrade
If we have an old organization (v1.8.3), and want to upgrade to a newer one (v1.8.4), the user would have to fetch the whole repository, instead we can just move the repository, so the user would not notice any difference. Also, remove other clones, so in time they get set up as shared. Signed-off-by: Felipe Contreras <[email protected]> Reviewed-by: Antoine Pelisse <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 52f0856 commit 3baacc5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

contrib/remote-helpers/git-remote-hg

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,18 @@ def get_repo(url, alias):
392392
else:
393393
shared_path = os.path.join(gitdir, 'hg')
394394

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+
395407
# setup shared repo (if not there)
396408
try:
397409
hg.peer(myui, {}, shared_path, create=True)

0 commit comments

Comments
 (0)