views:

146

answers:

2

I've read a lot about Mercurial and branching in it, however, I am still very much a version control newbie.

I'm currently working on a project, where I have been tasked to work on a new module.

I have a "main" repository, which contains the latest code from the rest of the project, and a cloned repository (call it "task") where I am doing my work now.

I am a bunch of commits into my task, and find that I would like to do a little "experiment" with the way my program reads/stores/handles configuration data.

Now, if I understand VC best-practices correctly, this would be a great time to branch.

If I start into this experiment, and I like where it's going, I will want to merge it back into my "task" repository on the "default" branch pretty quickly.

On the other hand, if I don't like how it's going, I'll probably just scrap the branch.

The way I am most comfortable branching is through cloning, however I don't think this would be the best approach in this situation, as I'll only be changing a few files, but apparently using named branches is permanent, which doesn't seem appropriate here either.

What is your advice / best practice for this kind of situation?

+3  A: 

I'm relatively new to Mercurial, but I know exactly the situation you are describing. I did some research on this before, and my conclusion was that the easiest way was to clone my repository.

See this answer for some more insight.

Also, this is a great guide to branching in Mercurial :)

bentsai
+2  A: 

Go with a clone, no doubt about it. A named branch in Mercurial is something that even the Mercurial folks say you don't need all that often. One of the beautiful things about DVCS is the fact that you can easily clone the repo and try some new and different things, and if they work, great, merge it back in to the main repo, otherwise, delete it all.

I personally use a "Branch By Feature" approach with Mercurial, which means that I will make a clone of my primary repo for each feature I'm working on. This includes spikes and experiments.

ckramer
Why not anonymous branch? It's less heavy than a clone, and not so permanent as a feature branch.
Santa
That seems like a reasonable option, and probably less bulky for a large project. Thanks!
ckramer