FAQ和hginit.com对于帮助我从svn过渡到hg非常有用.
然而,当谈到以颠覆的外部方式使用Hg的子存储库功能时,我已经尝试了所有的标志,并且不能复制svn外部的良好行为.
这是我想要做的最简单的例子:
Init"lib"存储库此存储库永远不会被用作独立存储库; 它始终包含在主存储库中,作为子存储库.
初始化一个或多个包含存储库为了使示例简单,我将"初始化"一个名为"main"的存储库
让"main"包含"lib"作为子库
重要的是 - 在这里,我无法工作:当我修改"main/lib"中的文件,并推送修改,然后该更改被推送到"lib"存储库 - 而不是副本在"主要"里面.
命令行胜于雄辩.我在这个主题上尝试了很多变化,但这里是要点.如果有人能够在命令行中回复,我将永远感激不尽!
$ cd/home/moi/hgrepos ##我在我的主服务器上存储我的hg存储库
$ hg init lib
$ echo"foo"> lib/lib.txt
$ hg add lib
$ hg ci -A -m"Init lib"lib
$ cd/home/moi/hgrepos
$ hg init main
$ echo"foo"> main/main.txt
$ hg add main
$ cd main
$ hg clone ../lib lib
$ echo"lib = lib"> .hgsub
$ hg ci -A -m"Init main".
这一切都运行正常,但是当我复制"main"存储库,并对"main/lib"中的文件进行本地修改并推送它们时,更改会被推送到"main/lib",而不是"lib" ".
$/home/moi/hg-test
$ hg clone ssh://moi@www.moi.com/hgrepos/lib lib
$ hg clone ssh://moi@www.moi.com/hgrepos/main main
$ cd main
$ echo foo >> lib/lib.txt
$ hg st
M lib.txt
$ hg com -m"修改了lib.txt,来自主要仓库"lib.txt
$ hg推
它表明我已经对lib中的文件的COPY进行了修改,而不是对lib库中的文件进行了修改.如果这是按照我希望的方式工作,则推送到hgrepos/lib,而不是hgrepos/main/lib.即,我会看到:
$ hg推
推送到ssh://moi@www.moi.com/hgrepos/lib
先感谢您!
艾米丽在波特兰
问题出在您的.hgsub文件中.它指向lib repo的位置,所以如果lib是main的兄弟,它应该是:
lib=../lib
Run Code Online (Sandbox Code Playgroud)
你的hg add lib和hg add main线条也没有意义.在main和lib之外的repo是被添加的那些?你在进来时正在运行它们/home/moi/hgrepos.
这是你的脚本,有一些调整:
+ cd /home/ry4an/hgtest
+ hg init lib
+ echo foo
+ cd lib
+ hg commit -A -m Init lib
adding lib.txt
+ cd /home/ry4an/hgtest
+ hg init main
+ echo foo
+ cd main
+ echo lib=../lib
+ hg clone ../lib
destination directory: lib
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ hg add .hgsub main.txt
+ hg commit -m Init main: initial file and a .hgsub
committing subrepository lib
+ cd /home/ry4an/hgtest
+ hg clone main main-clone
updating to branch default
pulling subrepo lib
requesting all changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ cd main-clone
+ echo foo
+ hg commit -m Modified lib.txt, from inside the main repos
committing subrepository lib
+ hg push
pushing to /home/ry4an/hgtest/main
pushing subrepo lib
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
Run Code Online (Sandbox Code Playgroud)
要通过ssh://执行此操作,您只需进行一次更改即可.当克隆主要仓库hg clone main main-clone变为hg clone ssh://host/hgtest/main main-clone- 克隆主要自动克隆lib - 这是subrepo的好处.
这是一个工作日志:
+ cd /home/ry4an/hgtest
+ hg init lib
+ echo foo
+ cd lib
+ hg commit -A -m Init lib
adding lib.txt
+ cd /home/ry4an/hgtest
+ hg init main
+ echo foo
+ cd main
+ echo lib=../lib
+ hg clone ../lib
destination directory: lib
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ hg add .hgsub main.txt
+ hg commit -m Init main: initial file and a .hgsub
committing subrepository lib
+ cd /home/ry4an/hgtest
+ hg clone ssh://localhost/hgtest/main main-clone
The authenticity of host 'localhost (::1)' can't be established.
RSA key fingerprint is 0c:58:d6:d3:d3:16:14:ee:3b:be:01:bc:c7:3c:92:0b.
Are you sure you want to continue connecting (yes/no)? yes
ry4an@localhost's password:
requesting all changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 3 changes to 3 files
updating to branch default
pulling subrepo lib
ry4an@localhost's password:
requesting all changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
remote: Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
+ cd main-clone
+ echo foo
+ hg commit -m Modified lib.txt, from inside the main repos
committing subrepository lib
+ hg push
ry4an@localhost's password:
pushing to ssh://localhost/hgtest/main
pushing subrepo lib
ry4an@localhost's password:
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3450 次 |
| 最近记录: |