{"thread":{"id":"35394","subject":"[PATCH] remote-hg: fix hg sharedpath when git clone is moved","startedAt":"2013-11-23T12:38:22Z","lastAt":"2013-11-23T16:35:29Z","messageCount":4,"participants":["Antoine Pelisse","Felipe Contreras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"230989","messageId":"1385210302-25518-1-git-send-email-apelisse@gmail.com","threadId":"35394","inReplyTo":null,"subject":"[PATCH] remote-hg: fix hg sharedpath when git clone is moved","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2013-11-23T12:38:22Z","receivedAt":"2013-11-23T12:38:22Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"remote-hg is using a mercurial shared clone to store all remotes objects\nin one place. Unfortunately, the sharedpath is stored as an absolute\npath by mercurial, creating a dependency on the location of the git\nrepository. Whenever the git repository is moved, the sharedpath must\nbe updated to reflect the new absolute path.\n\nCheck mercurial sharedpath file when getting the local hg repository,\nand update it manually with the new path if necessary.\n\nSigned-off-by: Antoine Pelisse <apelisse@gmail.com>\n---\n contrib/remote-helpers/git-remote-hg |  4 ++++\n contrib/remote-helpers/test-hg.sh    | 11 +++++++++++\n 2 files changed, 15 insertions(+)\n\ndiff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg\nindex c6026b9..576f094 100755\n--- a/contrib/remote-helpers/git-remote-hg\n+++ b/contrib/remote-helpers/git-remote-hg\n@@ -416,6 +416,10 @@ def get_repo(url, alias):\n         local_path = os.path.join(dirname, 'clone')\n         if not os.path.exists(local_path):\n             hg.share(myui, shared_path, local_path, update=False)\n+        else:\n+            sharedpath_file = os.path.join(local_path, '.hg', 'sharedpath')\n+            if hg_path != open(sharedpath_file, 'r').read():\n+                open(sharedpath_file, 'w').write(hg_path)\n \n         repo = hg.repository(myui, local_path)\n         try:\ndiff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh\nindex 72f745d..2477540 100755\n--- a/contrib/remote-helpers/test-hg.sh\n+++ b/contrib/remote-helpers/test-hg.sh\n@@ -335,6 +335,17 @@ test_expect_success 'remote cloning' '\n \tcheck gitrepo HEAD zero\n '\n \n+test_expect_success 'moving remote clone' '\n+\ttest_when_finished \"rm -rf gitrepo*\" &&\n+\n+\t(\n+\tgit clone \"hg::hgrepo\" gitrepo &&\n+\tmv gitrepo gitrepo2 &&\n+\tcd gitrepo2 &&\n+\tgit fetch\n+\t)\n+'\n+\n test_expect_success 'remote update bookmark' '\n \ttest_when_finished \"rm -rf gitrepo*\" &&\n \n-- \n1.8.5.rc1.30.g02973b8.dirty\n"},{"id":"230990","messageId":"CALWbr2zkiBS3zvcu8skrtn5tK8XMyQy8Nv1r1h+zowkgpWKYKw@mail.gmail.com","threadId":"35394","inReplyTo":"1385210302-25518-1-git-send-email-apelisse@gmail.com","subject":"Re: [PATCH] remote-hg: fix hg sharedpath when git clone is moved","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2013-11-23T12:46:13Z","receivedAt":"2013-11-23T12:46:13Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"On Sat, Nov 23, 2013 at 1:38 PM, Antoine Pelisse <apelisse@gmail.com> wrote:\n> remote-hg is using a mercurial shared clone to store all remotes objects\n> in one place. Unfortunately, the sharedpath is stored as an absolute\n> path by mercurial, creating a dependency on the location of the git\n> repository. Whenever the git repository is moved, the sharedpath must\n> be updated to reflect the new absolute path.\n>\n> Check mercurial sharedpath file when getting the local hg repository,\n> and update it manually with the new path if necessary.\n>\n> Signed-off-by: Antoine Pelisse <apelisse@gmail.com>\n> ---\n\nBy the way, this is the only link [1] I found about both relative path\nand updating the file. So it looks like there is no other way to\nupdate the path but to write the file manually.\n\n[1]: http://bz.selenic.com/show_bug.cgi?id=2006\n"},{"id":"230997","messageId":"CAMP44s2=b+7cFbRK-NFPU-myT8JtaSsrKut4AbvjOAQe0OCxDg@mail.gmail.com","threadId":"35394","inReplyTo":"1385210302-25518-1-git-send-email-apelisse@gmail.com","subject":"Re: [PATCH] remote-hg: fix hg sharedpath when git clone is moved","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2013-11-23T16:32:12Z","receivedAt":"2013-11-23T16:32:12Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"On Sat, Nov 23, 2013 at 6:38 AM, Antoine Pelisse <apelisse@gmail.com> wrote:\n> remote-hg is using a mercurial shared clone to store all remotes objects\n> in one place. Unfortunately, the sharedpath is stored as an absolute\n> path by mercurial, creating a dependency on the location of the git\n> repository. Whenever the git repository is moved, the sharedpath must\n> be updated to reflect the new absolute path.\n>\n> Check mercurial sharedpath file when getting the local hg repository,\n> and update it manually with the new path if necessary.\n>\n> Signed-off-by: Antoine Pelisse <apelisse@gmail.com>\n\nhttps://github.com/felipec/git/commit/270e7ff91a4a34e8bc27edb6bd7d7473b886f568\n\n-- \nFelipe Contreras\n"},{"id":"230998","messageId":"CALWbr2wE=6yR70tdBqf6dcdSv6mXE9vaPxg32OEGtL89+Kc_fA@mail.gmail.com","threadId":"35394","inReplyTo":"CAMP44s2=b+7cFbRK-NFPU-myT8JtaSsrKut4AbvjOAQe0OCxDg@mail.gmail.com","subject":"Re: [PATCH] remote-hg: fix hg sharedpath when git clone is moved","fromName":"Antoine Pelisse","fromEmail":"apelisse@gmail.com","sentAt":"2013-11-23T16:35:29Z","receivedAt":"2013-11-23T16:35:29Z","isPatch":true,"sender":{"key":"apelisse@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1929644?v=4"},"body":"On Sat, Nov 23, 2013 at 5:32 PM, Felipe Contreras\n<felipe.contreras@gmail.com> wrote:\n> On Sat, Nov 23, 2013 at 6:38 AM, Antoine Pelisse <apelisse@gmail.com> wrote:\n>> remote-hg is using a mercurial shared clone to store all remotes objects\n>> in one place. Unfortunately, the sharedpath is stored as an absolute\n>> path by mercurial, creating a dependency on the location of the git\n>> repository. Whenever the git repository is moved, the sharedpath must\n>> be updated to reflect the new absolute path.\n>>\n>> Check mercurial sharedpath file when getting the local hg repository,\n>> and update it manually with the new path if necessary.\n>>\n>> Signed-off-by: Antoine Pelisse <apelisse@gmail.com>\n>\n> https://github.com/felipec/git/commit/270e7ff91a4a34e8bc27edb6bd7d7473b886f568\n\nOr that, indeed :-)\n"}]}