git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antoine Pelisse <apelisse@gmail.com>
To: git@vger.kernel.org
Cc: Felipe Contreras <felipe.contreras@gmail.com>,
	Antoine Pelisse <apelisse@gmail.com>
Subject: [PATCH] remote-hg: fix hg sharedpath when git clone is moved
Date: Sat, 23 Nov 2013 13:38:22 +0100	[thread overview]
Message-ID: <1385210302-25518-1-git-send-email-apelisse@gmail.com> (raw)

remote-hg is using a mercurial shared clone to store all remotes objects
in one place. Unfortunately, the sharedpath is stored as an absolute
path by mercurial, creating a dependency on the location of the git
repository. Whenever the git repository is moved, the sharedpath must
be updated to reflect the new absolute path.

Check mercurial sharedpath file when getting the local hg repository,
and update it manually with the new path if necessary.

Signed-off-by: Antoine Pelisse <apelisse@gmail.com>
---
 contrib/remote-helpers/git-remote-hg |  4 ++++
 contrib/remote-helpers/test-hg.sh    | 11 +++++++++++
 2 files changed, 15 insertions(+)

diff --git a/contrib/remote-helpers/git-remote-hg b/contrib/remote-helpers/git-remote-hg
index c6026b9..576f094 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -416,6 +416,10 @@ def get_repo(url, alias):
         local_path = os.path.join(dirname, 'clone')
         if not os.path.exists(local_path):
             hg.share(myui, shared_path, local_path, update=False)
+        else:
+            sharedpath_file = os.path.join(local_path, '.hg', 'sharedpath')
+            if hg_path != open(sharedpath_file, 'r').read():
+                open(sharedpath_file, 'w').write(hg_path)
 
         repo = hg.repository(myui, local_path)
         try:
diff --git a/contrib/remote-helpers/test-hg.sh b/contrib/remote-helpers/test-hg.sh
index 72f745d..2477540 100755
--- a/contrib/remote-helpers/test-hg.sh
+++ b/contrib/remote-helpers/test-hg.sh
@@ -335,6 +335,17 @@ test_expect_success 'remote cloning' '
 	check gitrepo HEAD zero
 '
 
+test_expect_success 'moving remote clone' '
+	test_when_finished "rm -rf gitrepo*" &&
+
+	(
+	git clone "hg::hgrepo" gitrepo &&
+	mv gitrepo gitrepo2 &&
+	cd gitrepo2 &&
+	git fetch
+	)
+'
+
 test_expect_success 'remote update bookmark' '
 	test_when_finished "rm -rf gitrepo*" &&
 
-- 
1.8.5.rc1.30.g02973b8.dirty

             reply	other threads:[~2013-11-23 12:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-23 12:38 Antoine Pelisse [this message]
2013-11-23 12:46 ` [PATCH] remote-hg: fix hg sharedpath when git clone is moved Antoine Pelisse
2013-11-23 16:32 ` Felipe Contreras
2013-11-23 16:35   ` Antoine Pelisse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1385210302-25518-1-git-send-email-apelisse@gmail.com \
    --to=apelisse@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).