What is a branch?

Adrian Buehlmann adrian at cadifra.com
Fri Feb 8 18:31:55 CST 2008


On 09.02.2008 00:28, Stuart W. Marks wrote:
> Adrian Buehlmann wrote:
>> I've whipped up:
>>
>> http://www.selenic.com/mercurial/wiki/index.cgi/Branch
>>
>> In the hope this reduces some confusion.
>>
>> Contributions welcome.
>>
>> I intend to insert inline-links on other wiki pages.
> 
> Nice! Quick work, too. I think it's necessary to have a page like this 
> to have inline links from other pages. (BTW what tool do you use for 
> diagrams?)

The one Matt has installed on the wiki :-). I just stole/adapted the raw wiki 
text from the page UnderstandingMercurial.

> The big problem I see is that it still tries to support both usages of 
> the word "branch", that is, (a) a fork in the history graph, and (b) a 
> cloned repo. In particular the section starting with "The creation of a 
> branch can also happen in two different repositories R1 and R2..." is a 
> rather odd description of usage (b). I think that some people really 
> refer to the creation of clone as "branching" regardless of whether any 
> commits have been made to either repo. I'd suggest removing this section 
> entirely.

Hmm. If you must remove that section feel free to do so. I think it would be 
helpful to leave it for completeness sake. My motivation was to document 
existing uses of the term "branch" and not imposing The Correct One.

BTW Bazaar uses "branch" in yet another way. I suppose some people look at 
Bazaar *and* Mercurial anyway (I did it myself and choose Mercurial). I wouldn't 
be surprised if some branch/clone confusion comes from that anyway.

BTW on the Branch wiki page, I didn't write that a clone is a branch. The 
branching on the cloned repo does not happen until you *commit* two differing 
changesets in both clones. So, effectively, there is no difference to the single 
repo case. Semantically, that branching already happened on the commit of C2 in 
R2. Not just when you pull it into R1.

> People will use whatever words they're comfortable with, no matter what.
> 
> For Mercurial's "official" docs (man pages, help text, wiki, BOS's 
> book), though, I really think that trying to support the word "branch" 
> for both meanings is a recipe for continued confusion. Since the "hg 
> branch" and "hg branches" commands refer unambiguously to forks in the 
> history graph, I propose that we eradicate other usages of this term.

The history graph is in fact a "distributed history graph". So the branch exists 
earlier. Per your terminology, the branch would not exist until I pull it into a 
  combining repo. So I'm not sure if your approach really does help to reduce 
any (supposed) confusion.

I can clone a repo for a couple of reasons. Working independently for some time 
is one of them.






More information about the Mercurial mailing list