Making mercurial subrepositories behave like subversion externals

后端 未结 2 1183
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-06 11:55

The FAQ, and hginit.com have been really useful for helping me make the transition from svn to hg.

However, when it comes to using Hg\'s subrepository feature in the man

2条回答
  •  庸人自扰
    2021-02-06 12:53

    The problem is with your .hgsub file. It points to where the lib repo is, so if lib is a sibling to main it should be:

    lib=../lib
    

    Also your hg add lib and hg add main lines don't make sense. To what repo outside of main and lib are those being added? You're running them while in in /home/moi/hgrepos.

    Here's your script with some tweaks:

    + 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
    

    To do that over ssh:// you need only make a single change. When cloning the main repo change hg clone main main-clone to hg clone ssh://host/hgtest/main main-clone -- cloning the main automatically clones the lib -- that's the subrepo benefit.

    Here's a log of that working:

    + 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
    

提交回复
热议问题