Mercurial Remote Subrepos

I am trying to configure my Mercurial repository system to work with multiple subrepos. I basically followed these instructions to set up a client repo with the Mercurial v1.5 client, and I use HgWebDir to host my several projects.

I have an HgWebDir with the following structure:

http://myserver/hg |-- fooproj |-- mylib 

where mylib is some collection of a common template library that fooproj should use. The fooproj structure is as follows:

  fooproj |-- doc/ | `-- readme |-- src/ | `-- main.cpp |-- .hgignore |-- .hgsub `-- .hgsubstate 

And .hgsub looks like this:

 src/mylib = http://myserver/hg/mylib 

This should work according to my interpretation of the documentation:

The first "nested" is the path to our working directory, and the second is the URL or path to go from.

In addition, the directory structure of the mylib project is as follows:

 mylib |-- .hg | |-- 00changelog.i | |-- dirstate | |-- requires | |-- store | | |-- 00changelog.i | | |-- 00manifest.i | | | |-- data | | | | ` magic.hi | | |-- fncache | | `-- undo | |-- undo.branch | `-- undo.dirstate `-- magic.h 

So let's say I pull fooproj to my home folder with:

 ~$ hg clone http://myserver/hg/fooproj foo 

It touches the directory structure properly and adds the ~/foo/src/mylib folder, which is the local Mercurial repository. Problems arise here: the mylib folder is empty, except for the elements in .hg . Messages from Mercurial:

 requesting all changes adding changesets adding manifests adding file changes added 1 changesets with 5 changes to 5 files updating working directory 5 files updated, 0 files merged, 0 files removed, 0 files unresolved 

With 2 seconds of research, you can see that src/mylib/.hg/hgrc :

 [paths] default = http://myserver/hg/fooproj/src/mylib 

which is completely wrong (trying to pull this repo will give 404 because, well, this url doesn't make any sense).

 foo |-- .hg | |-- 00changelog.i | |-- branch | |-- branchheads.cache | |-- dirstate | |-- hgrc | |-- requires | |-- store | | |-- 00changelog.i | | |-- 00manifest.i | | |-- data | | | |-- .hgignore.i | | | |-- .hgsub.i | | | |-- .hgsubstate.i | | | |-- doc | | | | `-- readme.i | | | `-- src | | | `-- main.cpp.i | | |-- fncache | | `-- undo | |-- tags.cache | |-- undo.branch | `-- undo.dirstate |-- .hgignore |-- .hgsub |-- .hgsubstate |-- doc | `-- readme `-- src |-- main.cpp `-- mylib `-- .hg |-- 00changelog.i |-- branch |-- dirstate |-- hgrc |-- requires `-- store 

Logically, the default value should be what I specified in .hgsub , or in any way received files from the repository. Of course, changing src/mylib/.hg/hgrc to:

 [paths] default = http://myserver/hg/mylib 

and it works hg pull && hg update works fine. Of course, this is basically the same as not using subrepos in the first place.

None of the Mercurial commands return error codes (except pull from inside src/mylib ), so it clearly believes that it behaves correctly (and maybe only), although this does not seem logical at all.

What am I doing wrong?

The final problem might be that .hgsubstate would look like this:

 0000000000000000000000000000000000000000 src/mylib 

But I don’t know how to fix it ...

+4
source share
1 answer

The left path in your .hgsub file refers to its location in your tree. It is already in src , so src does not need to be in the path. I think if you make the .hgsub file .hgsub like:

 mylib = http://myserver/hg/mylib 

and leave it where it is, you will get what you want. Alternatively, you can move the .hgsub location up the directory (outside the src in the root directory) and then it will be correct as it is now.

I just confirmed this interpretation with this setting:

 . |-- .hg | |-- 00changelog.i | |-- branch | |-- branchheads.cache | |-- dirstate | |-- last-message.txt | |-- requires | |-- store | | |-- 00changelog.i | | |-- 00manifest.i | | |-- data | | | |-- .hgsub.i | | | `-- .hgsubstate.i | | |-- fncache | | `-- undo | |-- undo.branch | `-- undo.dirstate |-- .hgsub |-- .hgsubstate `-- src `-- mylib |-- .hg | |-- 00changelog.i | |-- branch | |-- branchheads.cache | |-- dirstate | |-- hgrc | |-- last-message.txt | |-- requires | |-- store | | |-- 00changelog.i | | |-- 00manifest.i | | |-- data | | | |-- .hgignore.i | | | |-- _p_k_g-_i_n_f_o.i | | | |-- _r_e_a_d_m_e.i | | | |-- hgext | | | | `-- chart.py.i | | | `-- setup.py.i | | |-- fncache | | `-- undo | |-- tags.cache | |-- undo.branch | `-- undo.dirstate |-- .hgignore |-- PKG-INFO |-- README |-- hgext | `-- chart.py `-- setup.py 

If this top level .hgsub contains:

 $ cat .hgsub src/mylib = https:// Ry4an@bitbucket.org /Ry4an/hg-chart-extension/ 

and the cone made by the parent shows that he also clones the child:

 $ hg clone parent parent-clone updating to branch default pulling subrepo src/mylib requesting all changes adding changesets adding manifests adding file changes added 8 changesets with 14 changes to 5 files 
+3
source

Source: https://habr.com/ru/post/1305915/


All Articles