Making mercurial subrepositories behave like subversion externals

后端 未结 2 1180
佛祖请我去吃肉
佛祖请我去吃肉 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:57

    Oops, sorry for the formatting in previous answer. Here it is again, formatted!

    So, here are the two scenarios most folks will be faced with:

    A) Using subrepositories in a completely local situation. This is Ryan's solution, essentially. I imagine only developers working solo will be in this boat.

        cd /home/moi/hgrepos
        hg init lib
        cd lib
        echo foo > lib.txt
        hg ci -A -m Init
    
        cd /home/moi/hgrepos
        hg init main
        cd main
        echo foo > main.txt
        echo lib = ../lib > .hgsub
        hg clone ../lib
        hg add .hgsub main.txt
        hg ci -m Init
    
        cd /home/moi/hgrepos
        hg clone main main-clone
        cd main-clone/lib
        echo "Modified while on main trunk" >>lib.txt
        hg commit -m "Modified lib.txt, while on main trunk"
        hg push
        cd /home/moi/hgrepos/lib
        hg update
        1 files updated, 0 files merged, 0 files removed, 0 files unresolved
    
        cat lib.txt
        foo
        Modified while on main trunk
    

    -----------------------------------------------------------------

    B) Using subrepositories over ssh.
    I imagine most developers working on teams will be in this boat.

    1) Set up lib

    cd /home/moi/hgrepos
    hg init lib
    cd lib
    echo foo > lib.txt
    hg ci -A -m Init
    

    2) Set up main

    cd /home/moi/hgrepos
    hg init main
    cd main
    echo foo > main.txt
    echo lib=ssh://moi@www.moi.com/hgrepos/lib > .hgsub
    hg clone ssh://moi@www.moi.com/hgrepos/lib lib
    hg add .hgsub main.txt
    hg ci -m Init
    

    3) Clone lib to hgtest dir

    cd /home/moi/hgtest
    hg clone ssh://moi@www.moi.com/hgrepos/lib lib
    

    4) Clone main to hgtest dir

    cd /home/moi/hgtest
    hg clone ssh://moi@www.moi.com/hgrepos/main main
    

    5) Modify lib.txt while on main trunk

    cd /home/moi/hgtest/main/lib
    echo "Modified while on main trunk" >>lib.txt
    hg commit -m "Modified lib.txt, while on main trunk"
    hg push
    

    6) Verify that lib.txt got changed in the lib repository

    cd /home/moi/hgtest/lib
    hg pull
    hg update
    1 files updated, 0 files merged, 0 files removed, 0 files unresolved
    cat lib.txt
    foo
    Modified while on main trunk
    

提交回复
热议问题