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 <felipe.contreras@gmail.com> Reviewed-by: Antoine Pelisse <apelisse@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Felipe Contreras committed
Aug 9, 2013 at 17:38 UTC
3baacc5cc6e4c2ed6184a7c5d9e10299999498dd
1 file changed
+12
contrib/remote-helpers/git-remote-hg
+12
@@ -392,6 +392,18 @@ def get_repo(url, alias):
392
else:
393
shared_path = os.path.join(gitdir, 'hg')
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)