Mercurial 远程子存储库

发布于 2024-08-27 18:04:22 字数 3156 浏览 1 评论 0原文

我正在尝试设置我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静赏你的温柔 2024-09-03 18:04:22

.hgsub 文件中的左侧路径是相对于它在树中的位置的。它已经位于 src 中,因此 src 不需要位于路径中。我认为如果您将 .hgsub 文件设置为如下所示:

mylib = http://myserver/hg/mylib

并将其保留在原来的位置,您将得到您想要的内容。或者,您可以将 .hgsub 的位置向上移动一个目录(src 之外,在您的 root 中),然后它会是正确的:就是现在。

我刚刚通过如下设置确认了这种解释:

.
|-- .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

顶级 .hgsub 文件包含:

$ cat .hgsub
src/mylib = https://[email protected]/Ry4an/hg-chart-extension/

并且父级的圆锥体显示它也克隆了子级:

$ 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

The left-hand-side path in your .hgsub file is relative to its location in your tree. It's already down in src, so src doesn't need to be in the path. I think if you make the .hgsub file look like:

mylib = http://myserver/hg/mylib

and leave it where it is you'll get what you want. Alternately, you could move the location of .hgsub up a directory (outside of src, in your root) and then it would be correct as it is now.

I've just confirmed this interpretation with a setup like this:

.
|-- .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

Where that top level .hgsub file contains:

$ cat .hgsub
src/mylib = https://[email protected]/Ry4an/hg-chart-extension/

and a cone done of the parent shows it cloning the child too:

$ 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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文