git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] [SIGNED-OFF] remotes-hg: bugfix for fetching non local remotes

From
Antoine Pelisse <apelisse@gmail.com>
Date
Jul 24, 2013, 08:52 UTC
Message-ID
<CALWbr2zRsCk1N5xUUDQeWX6CbvLHYWnxiYpea+etoWvXHNhPEA@mail.gmail.com>
In-Reply-To
<1374615616-4730-1-git-send-email-dev@joernhees.de>
On Tue, Jul 23, 2013 at 11:40 PM, Joern Hees <dev@joernhees.de> wrote:
> 6796d49 introduced a bug by making shared_path == ".git/hg' which
> will most likely exist already, causing a new remote never to be
> cloned and subsequently causing hg.share to fail with error msg:
> "mercurial.error.RepoError: repository .git/hg not found"

Indeed, no clone is performed if the .git/hg dir already exists. I think it assumes that it's already done. That will certainly lead to the failure you are reporting.

Also, the directory can be created to store marks for a local repository. remote-hg won't require nor do a local clone in .git/hg for local repositories.

It should also be noted that once .git/hg is not empty, it will no longer be possible to create a mercurial repository in there (it will die with "destination '.git/hg' is not empty")

I think the best way would be to create the shared repository in .git/hg/$share, with $share being a path that can't be a remote name (so that it doesn't conflict with remote directories), and then apply the following patch (copied in gmail)

diff --git a/contrib/remote-helpers/git-remote-hg
b/contrib/remote-helpers/git-remote-hg
index 0194c67..21c8091 100755
--- a/contrib/remote-helpers/git-remote-hg
+++ b/contrib/remote-helpers/git-remote-hg
@@ -390,7 +390,7 @@ def get_repo(url, alias):
         if not os.path.exists(dirname):
             os.makedirs(dirname)
     else:
-        shared_path = os.path.join(gitdir, 'hg')
+        shared_path = os.path.join(gitdir, 'hg', $share)
         if not os.path.exists(shared_path):
             try:
                 hg.clone(myui, {}, url, shared_path, update=False, pull=True)

That way, the share can be created even if .git/hg already exists
(because of a previous import, before the shared machinery existed, or
because you already have a local remote).

> Changing gitdir to dirname causes shared_path ==
> .git/hg/<remote_name>/hg. The call to hg.share with local_path ==
> .git/hg/<remote_name>/clone works again.

I think that will be a problem, because then the shared_path will no
longer be shared, will it ?
Previous: Joern HeesNext: Jörn Hees
Message 2 of 9 in “[SIGNED-OFF] remotes-hg: bugfix for fetching non local remotes”
  1. [SIGNED-OFF] remotes-hg: bugfix for fetching non local remotesJoern Hees, Jul 23, 2013
  2. Antoine PelisseJul 24, 2013
  3. Jörn HeesJul 24, 2013
  4. Antoine PelisseJul 24, 2013
  5. Jörn HeesJul 24, 2013
  6. Junio C HamanoJul 24, 2013
  7. Jörn HeesJul 24, 2013
  8. Junio C HamanoJul 24, 2013
  9. Felipe ContrerasJul 25, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.