Search code examples
version-controlmercurialtortoisehg

Move a specific branch to new repository


I have a mercurial repository in which I had created a branch 7-8 months back. And now this branch is the one in which I do most of the development and I don't have anything fruitful in default branch and other branches that I have.

I want to create a new repository that represent only this branch. i.e. I want to move this branch to a new repository with history.

I tried to use HG convert tool with following syntax:

hg convert --filemap ~filemap.txt --branchmap branchmap.txt  --source-type hg --dest-type hg "E:\MyStuff\Dev\MyOldRepo" "E:\NewRepo"

File map I have defined all my file that I want to include. In branchmap file i had defined

MyOldNamedBranch default

Convert tool do rename MyOldNamedBranch to default but it also brings the changesets from other branch that I don't need.

I also tried to set the following in setting file but no results:

[convert]
hg.usebranchnames=0
hg.startrev=5262

Please suggest how I can move a branch to new repository with history and leaving other branches behind.


Solution

  • I have set the start revision number in command only and it worked.

    hg convert --config convert.hg.startrev=5262 --branchmap branchmap.txt "E:\MyStuff\Dev\MyOldRepo" "E:\NewRepo"
    

    And it worked like a charm.