{"thread":{"id":"34662","subject":"[PATCH 0/2] remote-hg: shared repo upgrade fix","startedAt":"2013-08-09T20:02:59Z","lastAt":"2013-08-09T21:47:57Z","messageCount":6,"participants":["Felipe Contreras","Antoine Pelisse","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"224940","messageId":"1376078581-24766-1-git-send-email-felipe.contreras@gmail.com","threadId":"34662","inReplyTo":null,"subject":"[PATCH 0/2] remote-hg: shared repo upgrade fix","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-08-09T20:02:59Z","receivedAt":"2013-08-09T20:02:59Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Hi,\n\nHere's my proposal split into two patches, as I suggested. With the fix for\nwhen there's more than one shared repo.\n\nFelipe Contreras (2):\n  remote-hg: simplify share repo setup\n  remote-hg: add shared repo upgrade\n\n contrib/remote-helpers/git-remote-hg | 22 +++++++++++++++++-----\n 1 file changed, 17 insertions(+), 5 deletions(-)\n\n-- \n1.8.3.267.gbb4989f\n"},{"id":"224942","messageId":"1376078581-24766-2-git-send-email-felipe.contreras@gmail.com","threadId":"34662","inReplyTo":"1376078581-24766-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 1/2] remote-hg: simplify shared repo setup","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-08-09T20:03:00Z","receivedAt":"2013-08-09T20:03:00Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"We don't need the initial clone, if the repository is shared, pulling\nfrom the child updates the parent's storage; it's exactly the same as\ncloning.\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":"224941","messageId":"1376078581-24766-3-git-send-email-felipe.contreras@gmail.com","threadId":"34662","inReplyTo":"1376078581-24766-1-git-send-email-felipe.contreras@gmail.com","subject":"[PATCH 2/2] remote-hg: add shared repo upgrade","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-08-09T20:03:01Z","receivedAt":"2013-08-09T20:03:01Z","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\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\nSigned-off-by: Felipe Contreras <felipe.contreras@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg | 11 +++++++++++\n 1 file changed, 11 insertions(+)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex cfd4f53..9ec13da 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -392,6 +392,17 @@ 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+                shutil.copytree(local_hg, hg_path)\n+                break\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":"224946","messageId":"CALWbr2yAitLSNGj2qwz4C8Ugm8wHnGTf4ndZSbPcFToczWaWEA@mail.gmail.com","threadId":"34662","inReplyTo":"1376078581-24766-3-git-send-email-felipe.contreras@gmail.com","subject":"Re: [PATCH 2/2] remote-hg: add shared repo upgrade","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2013-08-09T20:19:56Z","receivedAt":"2013-08-09T20:19:56Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"On Fri, Aug 9, 2013 at 10:03 PM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n> 6796d49 (remote-hg: use a shared repository store) introduced a bug by\n> making the shared repository '.git/hg', which is already used before\n> that patch, so clones that happened before that patch, fail after that\n> patch, because there's no shared Mercurial repo.\n\nDoes that still hold ? You are creating the shared_path repository\njust below, so it should work without the patch.\nThe real reason for this patch is to avoid having to re-clone from a\npotential slow source, is it not ?\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> +                break\n> +\n\nBy the way, I liked my version better, that is:\n\nif os.path.exists(local_hg):\n    shutil.copytree(local_hg, hg_path)\n    break\n\nSimplifying the if not condition: continue else: break\n\n>          # setup shared repo (if not there)\n>          try:\n>              hg.peer(myui, {}, shared_path, create=True)\n"},{"id":"224948","messageId":"CAMP44s3KkwWnTb7=w-oviGRrsXk+g_L0yL9=xyywSpobmeExOw@mail.gmail.com","threadId":"34662","inReplyTo":"CALWbr2yAitLSNGj2qwz4C8Ugm8wHnGTf4ndZSbPcFToczWaWEA@mail.gmail.com","subject":"Re: [PATCH 2/2] remote-hg: add shared repo upgrade","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-08-09T20:24:10Z","receivedAt":"2013-08-09T20:24:10Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Fri, Aug 9, 2013 at 3:19 PM, Antoine Pelisse <apelisse@gmail.com> wrote:\n> On Fri, Aug 9, 2013 at 10:03 PM, Felipe Contreras\n> <felipe.contreras@gmail.com> wrote:\n>> 6796d49 (remote-hg: use a shared repository store) introduced a bug by\n>> making the shared repository '.git/hg', which is already used before\n>> that patch, so clones that happened before that patch, fail after that\n>> patch, because there's no shared Mercurial repo.\n>\n> Does that still hold ? You are creating the shared_path repository\n> just below, so it should work without the patch.\n> The real reason for this patch is to avoid having to re-clone from a\n> potential slow source, is it not ?\n\nYeah, that's true.\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>> +                break\n>> +\n>\n> By the way, I liked my version better, that is:\n>\n> if os.path.exists(local_hg):\n>     shutil.copytree(local_hg, hg_path)\n>     break\n>\n> Simplifying the if not condition: continue else: break\n\nI prefer my version because if there's any need to add more lines,\nthey don't have to be indented. That's why a lot of code ends up\nhaving unnecessary indentation.\n\n-- \nFelipe Contreras\n"},{"id":"224961","messageId":"7vbo564jua.fsf@alter.siamese.dyndns.org","threadId":"34662","inReplyTo":"CAMP44s3KkwWnTb7=w-oviGRrsXk+g_L0yL9=xyywSpobmeExOw@mail.gmail.com","subject":"Re: [PATCH 2/2] remote-hg: add shared repo upgrade","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-08-09T21:47:57Z","receivedAt":"2013-08-09T21:47:57Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Felipe Contreras <felipe.contreras@gmail.com> writes:\n\n> On Fri, Aug 9, 2013 at 3:19 PM, Antoine Pelisse <apelisse@gmail.com> wrote:\n>> On Fri, Aug 9, 2013 at 10:03 PM, Felipe Contreras\n>> <felipe.contreras@gmail.com> wrote:\n>>> 6796d49 (remote-hg: use a shared repository store) introduced a bug by\n>>> making the shared repository '.git/hg', which is already used before\n>>> that patch, so clones that happened before that patch, fail after that\n>>> patch, because there's no shared Mercurial repo.\n>>\n>> Does that still hold ? You are creating the shared_path repository\n>> just below, so it should work without the patch.\n>> The real reason for this patch is to avoid having to re-clone from a\n>> potential slow source, is it not ?\n>\n> Yeah, that's true.\n\nSo both of you are happy if we apply 1/2\n\nMessage-ID: <1376078581-24766-2-git-send-email-felipe.contreras@gmail.com>\n\nand this one with an updated log message?\n"}]}