{"thread":{"id":"34666","subject":"[PATCH v2 0/2] remote-hg: shared repo upgrade fix","startedAt":"2013-08-09T22:38:02Z","lastAt":"2013-08-10T15:18:11Z","messageCount":4,"participants":["Felipe Contreras","Antoine Pelisse"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"224970","messageId":"1376087884-32060-1-git-send-email-felipe.contreras@gmail.com","threadId":"34666","inReplyTo":null,"subject":"[PATCH v2 0/2] remote-hg: shared repo upgrade fix","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-08-09T22:38:02Z","receivedAt":"2013-08-09T22:38:02Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nSame as before, except with commit messages updated, and improved the second\npatch:\n\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -400,8 +400,9 @@ def get_repo(url, alias):\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-                break\n+                if not os.path.exists(hg_path):\n+                    shutil.move(local_hg, hg_path)\n+                shutil.rmtree(os.path.join(shared_path, x, 'clone'))\n \n         # setup shared repo (if not there)\n         try:\n\nFelipe Contreras (2):\n  remote-hg: ensure shared repo is initialized\n  remote-hg: add shared repo upgrade\n\n contrib/remote-helpers/git-remote-hg | 23 ++++++++++++++++++-----\n 1 file changed, 18 insertions(+), 5 deletions(-)\n\n-- \n1.8.3.267.gbb4989f\n"},{"id":"224971","messageId":"1376087884-32060-2-git-send-email-felipe.contreras@gmail.com","threadId":"34666","inReplyTo":"1376087884-32060-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 1/2] remote-hg: ensure shared repo is initialized","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-08-09T22:38:03Z","receivedAt":"2013-08-09T22:38:03Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"6796d49 (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\nSo, instead of simply checking if the directory exists, let's always try\nto create an empty shared repository to ensure it's there. This works\nbecause we don't need the initial clone, if the repository is shared,\npulling from the child updates the parent's storage; it's exactly the\nsame as cloning, so we can simplify the shared repo setup this way while\nat the same time fixing the problem.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 11 ++++++-----\n 1 file changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex 0194c67..cfd4f53 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -391,11 +391,12 @@ 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+        # 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.8.3.267.gbb4989f\n"},{"id":"224972","messageId":"1376087884-32060-3-git-send-email-felipe.contreras@gmail.com","threadId":"34666","inReplyTo":"1376087884-32060-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH v2 2/2] remote-hg: add shared repo upgrade","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-08-09T22:38:04Z","receivedAt":"2013-08-09T22:38:04Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"If we have an old organization (v1.8.3), and want to upgrade to a newer\none (v1.8.4), the user would have to fetch the whole repository, instead\nwe can just move the repository, so the user would not notice any\ndifference.\n\nAlso, remove other clones, so in time they get set up as shared.\n\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex cfd4f53..6c82b8d 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -392,6 +392,18 @@ def get_repo(url, alias):\n     else:\n         shared_path = os.path.join(gitdir, 'hg')\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+                if not os.path.exists(hg_path):\n+                    shutil.move(local_hg, hg_path)\n+                shutil.rmtree(os.path.join(shared_path, x, 'clone'))\n+\n         # setup shared repo (if not there)\n         try:\n             hg.peer(myui, {}, shared_path, create=True)\n-- \n1.8.3.267.gbb4989f\n"},{"id":"225023","messageId":"CALWbr2zKhvM_scRCER2GeBtRDF2=bvrDQWc+GZjDGExHeKRnQg@mail.gmail.com","threadId":"34666","inReplyTo":"1376087884-32060-1-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH v2 0/2] remote-hg: shared repo upgrade fix","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2013-08-10T15:18:11Z","receivedAt":"2013-08-10T15:18:11Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"On Sat, Aug 10, 2013 at 12:38 AM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n> Hi,\n>\n> Same as before, except with commit messages updated, and improved the second\n> patch:\n>\n> --- a/contrib/remote-helpers/git-remote-hg\n> +++ b/contrib/remote-helpers/git-remote-hg\n> @@ -400,8 +400,9 @@ def get_repo(url, alias):\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> -                break\n> +                if not os.path.exists(hg_path):\n> +                    shutil.move(local_hg, hg_path)\n> +                shutil.rmtree(os.path.join(shared_path, x, 'clone'))\n>\n>          # setup shared repo (if not there)\n>          try:\n\nFWIW,\nReviewed-by: Antoine Pelisse <apelisse@gmail.com>\n\nCheers,\n"}]}