Mercurial 远程子存储库
我正在尝试设置我的 Mercurial 存储库系统以与多个子存储库一起使用。我基本上按照这些说明使用 Mercurial 客户端 v1.5 设置客户端存储库,并且我正在使用 HgWebDir 来托管我的多个项目。
我有一个具有以下结构的 HgWebDir:
http://myserver/hg
|-- fooproj
|-- mylib
其中 mylib
是由 fooproj
使用的一些通用模板库的集合。 fooproj
的结构如下所示:
fooproj
|-- doc/
| `-- readme
|-- src/
| `-- main.cpp
|-- .hgignore
|-- .hgsub
`-- .hgsubstate
.hgsub
如下所示:
src/mylib = http://myserver/hg/mylib
根据我对文档的解释,这应该可行:
第一个“嵌套”是我们的路径 工作目录,第二个是 URL 或从中拉出的路径。
另外, mylib
项目目录结构如下所示:
mylib
|-- .hg
| |-- 00changelog.i
| |-- dirstate
| |-- requires
| |-- store
| | |-- 00changelog.i
| | |-- 00manifest.i
| | | |-- data
| | | | ` magic.h.i
| | |-- fncache
| | `-- undo
| |-- undo.branch
| `-- undo.dirstate
`-- magic.h
因此,假设我将 fooproj
下拉到我的主文件夹:
~$ hg clone http://myserver/hg/fooproj foo
它将正确下拉目录结构并添加文件夹~/foo/src/mylib
这是本地 Mercurial 存储库。这就是问题开始的地方:除了 .hg
中的项目之外,mylib
文件夹是空的。来自 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
经过 2 秒的调查,我们可以看到 src/mylib/.hg/hgrc 是:
[paths]
default = http://myserver/hg/fooproj/src/mylib
这是完全错误的(尝试拉取该内容) repo 会给出 404,因为这个 URL 没有任何意义)。
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
从逻辑上讲,默认值应该是我在 .hgsub 中指定的值,否则它将以某种方式从存储库获取文件。当然,将 src/mylib/.hg/hgrc 更改为:
[paths]
default = http://myserver/hg/mylib
并运行 hg pull && hg update 工作完美。当然,这与一开始就不使用子存储库基本上是一样的。
Mercurial 命令都不会返回错误代码(除了从 src/mylib
内进行 pull
操作),因此它显然认为它的行为正常(而且可能是),尽管这看起来根本不合逻辑。
我做错了什么?
最终的问题可能是 .hgsubstate
总是看起来像:
0000000000000000000000000000000000000000 src/mylib
但我不知道如何解决这个问题......
I'm trying to set up my Mercurial repository system to work with multiple subrepos. I've basically followed these instructions to set up the client repo with Mercurial client v1.5 and I'm using HgWebDir to host my multiple projects.
I have an HgWebDir with the following structure:
http://myserver/hg
|-- fooproj
|-- mylib
where mylib
is some collection of common template library to be consumed by fooproj
. The structure of fooproj
looks like this:
fooproj
|-- doc/
| `-- readme
|-- src/
| `-- main.cpp
|-- .hgignore
|-- .hgsub
`-- .hgsubstate
And .hgsub
looks like:
src/mylib = http://myserver/hg/mylib
This should work, per my interpretation of the documentation:
The first 'nested' is the path in our
working dir, and the second is a URL
or path to pull from.
Also, the mylib
project directory structure looks like this:
mylib
|-- .hg
| |-- 00changelog.i
| |-- dirstate
| |-- requires
| |-- store
| | |-- 00changelog.i
| | |-- 00manifest.i
| | | |-- data
| | | | ` magic.h.i
| | |-- fncache
| | `-- undo
| |-- undo.branch
| `-- undo.dirstate
`-- magic.h
So, let's say I pull down fooproj
to my home folder with:
~$ hg clone http://myserver/hg/fooproj foo
Which pulls down the directory structure properly and adds the folder ~/foo/src/mylib
which is a local Mercurial repository. This is where the problems begin: the mylib
folder is empty aside from the items in .hg
. The messages from Mercurial are:
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 investigation, one can see the src/mylib/.hg/hgrc
is:
[paths]
default = http://myserver/hg/fooproj/src/mylib
which is completely wrong (attempting a pull
of that repo will give a 404 because, well, that 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 it would get the files from the repository in some way. Of course, changing src/mylib/.hg/hgrc
to:
[paths]
default = http://myserver/hg/mylib
and running hg pull && hg update
works perfectly. Of course, this is basically the same thing as not using subrepos in the first place.
None of the Mercurial commands return error codes (aside from a pull
from within src/mylib
), so it clearly believes that it is behaving properly (and just might be), although this does not seem logical at all.
What am I doing wrong?
The ultimate problem might be that .hgsubstate
will always look like:
0000000000000000000000000000000000000000 src/mylib
But I have no idea how to fix that...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
.hgsub
文件中的左侧路径是相对于它在树中的位置的。它已经位于src
中,因此src
不需要位于路径中。我认为如果您将.hgsub
文件设置为如下所示:并将其保留在原来的位置,您将得到您想要的内容。或者,您可以将
.hgsub
的位置向上移动一个目录(src
之外,在您的 root 中),然后它会是正确的:就是现在。我刚刚通过如下设置确认了这种解释:
顶级
.hgsub
文件包含:并且父级的圆锥体显示它也克隆了子级:
The left-hand-side path in your
.hgsub
file is relative to its location in your tree. It's already down insrc
, sosrc
doesn't need to be in the path. I think if you make the.hgsub
file look like:and leave it where it is you'll get what you want. Alternately, you could move the location of
.hgsub
up a directory (outside ofsrc
, in your root) and then it would be correct as it is now.I've just confirmed this interpretation with a setup like this:
Where that top level
.hgsub
file contains:and a cone done of the parent shows it cloning the child too: