Zack
Zack

Reputation: 2151

Cheap cloning/local branching in Mercurial

Just started working with Mercurial a few days ago and there's something I don't understand.

I have an experimental thing I want to do, so the normal thing to do would be to clone my repository, work on the clone and if eventually I want to keep those changes, I'll push them to my main repository.

Problem is cloning my repository takes alot of time (we have alot of code) and just compiling the cloned copy would take up to an hour.
So I need to somehow work on a different repository but still in my original working copy.

Enter local branches.

Problem is just creating a local branch takes forever, and working with them isn't all that fun either. Because when moving between local branches doesn't "revert" to the target branch state, I have to issue a hg purge (to remove files that were added in the moved from branch) and then hg update -c (to revert modified files in the moved from branch). (note: I did try PK11 fork of local branch extension, it a simple local branch creation crashes with an exception)

At the end of the day, this is just too complex. What are my options?

Upvotes: 2

Views: 658

Answers (4)

Laurens Holst
Laurens Holst

Reputation: 21086

Probably not the answer you want to hear, but I would say maybe you should consider splitting your repository into a little more manageable chunks :). E.g. does that documentation and those design files really need to be included in the same repository, does that editor tool not deserve its own repository, etc.

Because as cloning creates hard links, it’s pretty much already as fast as it can get; if cloning takes 5-10 minutes already, making a file system copy must be even worse. (Tip: keep in mind hg clone -U if you do not need a working copy, it will be much much faster.)

Otherwise, yeah, anonymous branches with bookmarks is the usual way to do in-place switching.

Upvotes: 1

Andrey Vlasovskikh
Andrey Vlasovskikh

Reputation: 16858

There are several ways of working with local branches besides cloning:

  • Bookmarks
  • Named branches
  • Anonymous branches

You may be interested in reading a very insightful guide to branching in Mercurial. I guess the bookmarks extension is the most appropriate way of branching in the context you've described.

Upvotes: 5

domruf
domruf

Reputation: 1563

couldn't you make your experiments on top of your existing clone and when you want to make some changes to the main line go back and update to the last revision before you started the experiments?

Upvotes: 0

jk.
jk.

Reputation: 14004

how long does cloning a local repo take?

it sounds like you build process might be the weak link to me - perhaps you need something like ccache? so that you can clone and build quickly

Upvotes: 0

Related Questions