Mercurial Subrepos - How do you create them and how do they work?

后端 未结 2 1182
青春惊慌失措
青春惊慌失措 2020-11-28 04:31

Situation

I have two .NET solutions (Foo and Bar) and a common library that contains ProjectA, ProjectB, and ProjectC.

相关标签:
2条回答
  • 2020-11-28 04:49

    Just a quick update, after the release of TortoiseHg 1.0.

    The subrepo support in THG 1 is good enough to do let you do example steps from Windows Explorer. The only one I couldn't do from Explorer was step 6:

    echo nested = nested > .hgsub
    

    Windows explorer (in XP at least) reports a rename error "You must type a file name." if you try to rename "New Text Document.txt" to ".hgsub". *8')

    Edit: Incidentally, if you use both hg via TortoiseHg and the command line and you don't already have Microsofts "Command Here" PowerTool installed, I can highly recommend it. It adds an "Open Command Window Here" context menu entry to every directory in Windows Explorer, making it very easy to open command windows any where you need them.

    0 讨论(0)
  • 2020-11-28 04:54

    You could probably try this stuff out and learn it more quickly than writing up your question took, but I'll bite.

    Can any or all of these steps be executed with TortoiseHG, as of version 0.9.2? If yes, how?

    TortiseHG doesn't yet put GUI wrappers around sub-repo creation, but TortiseHG has always done a great job of working with the command line. Use the command line to create and them and you're good to go.

    What does the above code do (a line-by-line explanation would be much appreciated).

    hg init main  # creates the main repo
    cd main # enter the main repo
    hg init nested # create the nested. internal repo
    echo test > nested/foo # put the word test into the file foo in the nested repo
    hg -R nested add nested/foo # do an add in the nested repo of file foo
    echo nested = nested > .hgsub # put the string "nested = nested" into a file (in main) named .hgsub
    hg add .hgsub # add the file .hgsub into the main repo
    

    Here are some specific questions that came to mind as I was trying to decipher it: What does > do?

    That has nothing to do with mercurial it's standard shell (unix and dos) for "put the result into a file named X"

    In line 5, I don't understand what nested/foo is. Where did foo come from? What is foo? A repository? A folder?

    It's a file in the subrepo. Foo is a traditional arbitrary name, and the arbitrary contents are the string "test"

    Line 6 - this one completely baffles me.

    It's putting the contents in .hgsub necessary to say that nested is a nested repo named nested and located at nested.

    In line 7, I assume .hgsub is being added to main? Or is it being added to nested?

    main

    Let's say I get my subrepos set up, and my Bar repository is now up to revision 10. If I attempt to update to revision 7, will this cause my library folders (My Documents/Development/Libraries/ProjectA and .../Libraries/ProjectB) to update to whatever is stored in revision 7 as well? Given that Foo also refers to Libraries/ProjectA, this could get interesting!

    Revision numbers won't carry across, but you have control by editing the .hgsubstate file.

    0 讨论(0)
提交回复
热议问题