【发布时间】:2010-04-03 06:50:26
【问题描述】:
我正在尝试设置我的 Mercurial 存储库系统以使用多个子存储库。我基本上遵循these instructions 来使用 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 的 pull 将给出 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 可以完美运行。当然,这与一开始不使用 subrepos 基本上是一样的。
没有任何 Mercurial 命令返回错误代码(除了 src/mylib 中的 pull),因此它清楚地认为它的行为正确(而且可能是正确的),尽管这似乎根本不合逻辑。
我做错了什么?
最终的问题可能是.hgsubstate 总是看起来像:
0000000000000000000000000000000000000000 src/mylib
但我不知道如何解决这个问题......
【问题讨论】: