4
votes

I have a mercurial repository with a clone on several computers. In particular, I have a Ubuntu computer where the repository resides in ~/.vim and a Windows computer with a related repository in C:\Users\ben\vimfiles.

This repository contains subrepositories, some of them git subrepositories. For example, from .hgsub:

pack/thirdparty/start/signify           = [git]pack/thirdparty/start/signify

I wanted to merge changes made in each repository. So I cloned the repository from my Ubuntu computer to a USB stick, plugged it into my Windows computer, and pulled from the repository on the Windows computer into the clone on the USB stick. So far, so good.

Now I go to merge, or even just update to any of the versions coming from the Windows computer. I got an error like this:

pulling subrepo pack/thirdparty/start/signify from /home/ben/.vim/pack

/thirdparty/start/signify
fatal: 'C:/Program Files/Git/home/ben/.vim/pack/thirdparty/start/signify' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
abort: git fetch error 128 in pack/thirdparty/start/signify (in subrepo pack/thirdparty/start/signify)
[command returned code 255 Thu Dec 13 11:24:15 2018]

After a bunch of digging, I eventually solved the issue by manually editing the .git/config file in every single git subrepo to change the origin path from /home/ben/.vim to C:/Users/ben/vimfiles.

What's the correct way to do this using only Mercurial commands or configurations? Using TortoiseHg, when I update (but not merge!) I can select any of the saved paths to pull subrepos from. This seems to manually override the paths.default configuration for the pull operation. But, that setting seems to be ignored by the git subrepos.

1
What does your .hgsub look like in your 'main' repository?planetmaker
Added the relevant line from .hgsub to the question, from the "main" repo. There are a dozen or so more similar lines, plus a few that don't use git.Ben
Hm, that's odd. You've setup the subrepos as they're supposed to be setup in a way that repos can be easily cloned... I fear you stumbled over one of the rough stones of sub-repos, especially in the hg-git integrationplanetmaker

1 Answers

1
votes

From the mercurial's documentation on subrepositories (accessible on command line through hg help subrepos):

Subrepositories

...

Remapping Subrepositories Sources

A subrepository source location may change during a project life, invalidating references stored in the parent repository history. To fix this, rewriting rules can be defined in parent repository hgrc file or in Mercurial configuration. See the [subpaths] section in hgrc(5) for more details.

Documentation on subpaths:

subpaths

Subrepository source URLs can go stale if a remote server changes name or becomes temporarily unavailable. This section lets you define rewrite rules of the form:

<pattern> = <replacement>

where pattern is a regular expression matching a subrepository source URL and replacement is the replacement string used to rewrite it. Groups can be matched in pattern and referenced in replacements. For instance:

http://server/(.*)-hg/ = http://hg.server/\1/

rewrites http://server/foo-hg/ into http://hg.server/foo/.

Relative subrepository paths are first made absolute, and the rewrite rules are then applied on the full (absolute) path. If pattern doesn't match the full path, an attempt is made to apply it on the relative path alone. The rules are applied in definition order.