{"thread":{"id":"34618","subject":"[PATCH] remote-hg: add shared repo upgrade","startedAt":"2013-08-05T19:29:43Z","lastAt":"2013-08-05T19:29:43Z","messageCount":1,"participants":["Antoine Pelisse"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"224620","messageId":"1375730983-6620-1-git-send-email-apelisse@gmail.com","threadId":"34618","inReplyTo":null,"subject":"[PATCH] remote-hg: add shared repo upgrade","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2013-08-05T19:29:43Z","receivedAt":"2013-08-05T19:29:43Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"From: Felipe Contreras <felipe.contreras@gmail.com>\n\n6796d49 (remote-hg: use a shared repository store) introduced a bug by\nmaking the shared repository '.git/hg', which is already used before\nthat patch, so clones that happened before that patch, fail after that\npatch, because there's no shared Mercurial repo.\n\nIt's trivial to upgrade to the new organization by copying the Mercurial\nrepo from one of the remotes (e.g. 'origin'), so let's do so.\n\nReported-by: Joern Hees <dev@joernhees.de>\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\nSigned-off-by: Antoine Pelisse <apelisse@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg |   21 ++++++++++++++++-----\n 1 file changed, 16 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 0194c67..02404dc 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -391,11 +391,22 @@ def get_repo(url, alias):\n             os.makedirs(dirname)\n     else:\n         shared_path = os.path.join(gitdir, 'hg')\n-        if not os.path.exists(shared_path):\n-            try:\n-                hg.clone(myui, {}, url, shared_path, update=False, pull=True)\n-            except:\n-                die('Repository error')\n+\n+        # check and upgrade old organization\n+        hg_path = os.path.join(shared_path, '.hg')\n+        if os.path.exists(shared_path) and not os.path.exists(hg_path):\n+            repos = os.listdir(shared_path)\n+            for x in repos:\n+                local_hg = os.path.join(shared_path, x, 'clone', '.hg')\n+                if not os.path.exists(local_hg):\n+                    continue\n+                shutil.copytree(local_hg, hg_path)\n+\n+        # setup shared repo (if not there)\n+        try:\n+            hg.peer(myui, {}, shared_path, create=True)\n+        except error.RepoError:\n+            pass\n \n         if not os.path.exists(dirname):\n             os.makedirs(dirname)\n-- \n1.7.9.5\n"}]}