views:

329

answers:

2

I'm looking at the mercurial handbook, chapter 6 "Working with multiple branches". In there the author states that if you have separate versions/branches of the same software that it makes sense in an implied obvious way to host each branch of the software in a separate repository.

I know that Mercurial supports tags (which is the way that branches are done in subversion AFAIK). Why would you use different repositories instead of tags for branch managing?

+5  A: 

There are advantages in having different repositories in Mercurial, and problem in handling branches.

Branches mean multiple heads, the graphs are much more complicated then, and even the graphical representation may not be able to accommodate so many convoluted paths... and I don't even talk about the human brain!

On the other hand, having multiple repositories mean that each repository will have a much simpler structure, therefore easing the brain trauma of having to deal with multiple branches/merges (that you have anyway, since two developers working from the same changeset and onward develop concurrently).

Furthermore, with multiple repositories, you can read/edit any file on a given repository easily with whatever editor you are using (if you maintain the working dir up to date relatively to the tip).

On subversion you HAVE to deal with multiple branches, there is no other way around, and you have to use tags.

On Mercurial, tags are not supposed to move (it needlessly introduce changesets) and branches are handled off-the-shelf: you always have branches. However, since you can have multiple repositories, you are offered another dimension. It is your choice whether you use it or not, it made my life easier anyway.

Matthieu M.
I need to go look at this, but I would have to share the same confusion. A tag or a branch in SVN is a fork maintained in the repository, I can go to my machine "over there" and pull down exactly what I want, if I create a new repository instead surely attempting to do that becomes significantly more complex *and* do I not have to keep both repositories? I can see that there are significant positive features with DVCS but its should also be obvious that there are positive features in having a central repository that seem often to be ignored by DVCS converts.
Murph
You really can't compare tags and branches in hg with tags and branches in svn, it's *really* different!
tonfa
I like your answer, thanks. It's like the good answer for question on Bazaar: "why Bazaar always keep every branch in separate directory?" Because human brains is weak on dealing with zillion heads in one repo.
bialix
+9  A: 

Mercurial's tags are not the same as Subversion's branches. In Subversion, making a branch creates a separate copy of the code (with hardlinks at least, I think) while tags in Mercurial just point to a specific commit.

A while ago I wrote about Mercurial's branching models (of which branching-with-clones is one of four options), maybe you'd find it useful?

Steve Losh
Very interesting guide, I didn't know about bookmarks.
Matthieu M.