Can I clone part of a Mercurial repository?

前端 未结 7 1107
余生分开走
余生分开走 2020-12-24 01:27

Is it possible to clone part of a Mercurial repository? Let\'s say the repository is quite large, or contains multiple projects, or multiple branches. Can I clone only part

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-24 02:00

    Yes you can. I'm sure you've moved on, but for the sake of those who will wander here later, I followed the docs at ConvertExtension, and wrote a simple batch script:

    @echo off
    echo Converting %1
    REM Create the file map
    echo include %1 > ~myfilemap               
    echo rename %1 . >> ~myfilemap 
    REM Run the convert process
    hg convert --filemap ~myfilemap .\ ..\%1   
    REM Delete the file map
    del ~myfilemap                             
    cd ..\%1
    REM update the new repo--to create the files
    hg update                                  
    

    Name it something like split.cmd, and put it in the directory for the repo you want to split. Say for example you have C:\repos\ReallyBigProject, and a subfolder is C:\repos\ReallyBigProject\small-project. At the command prompt, run:

    cd\repos\ReallyBigProject
    split.cmd small-project
    

    This will create C:\repos\small-project with a slice of the relevant history of revisions from the larger project.

    The convert is not enabled by default. You'll need to make sure the following lines exist in your .hg\hgrc file (c:\repos\ReallyBigProject\.hg\hgrc in my example):

    [extensions]
    hgext.convert=
    

提交回复
热议问题