Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I clone part of a Mercurial repository?

Tags:

dvcs

mercurial

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 of the repository?

E.g. in Subversion, you might have trunk and branches. If I only want to get trunk (or one of the branches) I can just request [project]/trunk. If I clone the hg repo I'll get trunk and all of the branches. This might be a lot of information I don't want. Can I avoid getting this?

Alternatively, if I want to have multiple projects in one hg repo, how should I do this? I.e. so that I might just get one of the projects and ignore the others.

like image 286
Nick Avatar asked Nov 16 '09 21:11

Nick


People also ask

How do I clone a Mercurial repository?

Clone a remote Mercurial repositoryFrom the main menu, select Hg | Get from Version Control. The Get from Version Control dialog opens. In the dialog that opens, select Mercurial from the Version control list and specify the URL of the remote repository you want to clone. Click Clone.

How do you clone in Tortoise Hg?

To clone a repository you have to run the clone dialog. From the explorer context menu select TortoiseHg… ‣ Clone a repository or type thg clone. It is the path (or URL) of the repository that will be cloned.

What is a Mercurial repository?

Mercurial is a free, distributed version control system. It's also referred to as a revision control system or Mercurial source control. It is used by software development teams to manage and track changes across projects.


1 Answers

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= 
like image 68
Andy Edinborough Avatar answered Sep 21 '22 17:09

Andy Edinborough