[PATCH 0 of 9] improvements for named branches

Alexis S. L. Carvalho alexis at cecm.usp.br
Tue Mar 4 15:11:02 CST 2008

Thus spake Matt Mackall:
> On Tue, Mar 04, 2008 at 03:08:19AM -0300, Alexis S. L. Carvalho wrote:
> > What does it mean to close/inactivate/... a named branch?
> > 
> >   To make it look as if that name never existed (but you could still
> >   recalculate them if you're doing archaeology).
> Ok, so when a bonehead does merge --close stable, I now have to do
> archaeology? (Haha.. bonehead.. archaeology..) That sounds *bad*. The
> bonehead will have no idea he typed --close (his fingers are faster
> than his little dinosaur brain), and everyone will say "where the hell
> did our stable branch go! our build server just wet itself! this
> software is crap!" and no one will know who to blame and they'll all
> wave their tiny little T-rex arms about in panic.

I was thinking of something like

hg branches --closed | grep stable

(or maybe even just "hg branches --closed stable"), which would count as
archaeology because hg would have to scan the whole changelog since this
wouldn't be cached.

> Instead, I'd like this "branch closing" to be about giving a more
> useful meaning to "active branches" (hg branch -a), such that we can
> stop checking out  (and listing) "inactive (closed)" branches by
> default, but they still live on for the purposes of hg up, log, etc.
> Compare deleting a tag: I've got to actually consciously do a whole
> "hg tag --delete 1.0" and then even a slightly clueful person can do
> hg log .hgtags to find the appropriate cruise missile coordinates.
> With "hg commit --close branch" simply marking the branch inactive,
> people instead say "huh, stable still works great, but stopped showing
> up as an active branch. how odd. hg log -b stable shows that
> 'maverick' closed it, and his commit message shows why he thinks we
> don't need a stable branch any more. let's go have a little chat with
> him after lunch about who's in charge."

My gut feeling is that by making it hard to accidentally close a
long-lived branch, you're making it too cumbersome to close short-lived
branches.  But maybe I just have to think a bit more about how this
would all come together.

I'm not sure it's good to compare this with tag deletion.  You almost
never delete tags (so a long command line is fine), but for the
short-lived branch case, you'll want to close every branch you create.

> > > Also, what happens if you do:
> > > 
> > > hg branch --close thisbranch
> > 
> > abort: refusing to close current branch "thisbranch"
> This is the embarrassment case:
> hg co embarrassment
> hg commit --close-branch -m "Sorry you had to see that, folks"
> hg push -r embarrassment
> Our embarrassment now moves to the bottom or even disappears from hg
> branches, and we might not show it on hg heads either unless we pass a
> --inactive.

One nice thing here is that the push -r foo includes the info that the
branch is closed (unlike pull -r some-tag, which will include the right
revisions, but won't include the "some-tag" name).

> > What I think is important is to have pull/push/clone -r transfer all the
> > heads of the repo and have log -r show all the heads.  In general, make
> > all commands that can operate on multiple revisions operate on all the
> > heads.
> ??

Using the example repo that pmezard sent to this thread:

@  changeset:   2:f2bb7b077333                                                                                        
|  branch:      foo                                                                                                   
|  tag:         tip                                                                                                   
|  parent:      0:a260d8b9e97b                                                                                        
|  user:        Patrick Mezard <pmezard at gmail.com>                                                                    
|  date:        Tue Mar 04 09:41:00 2008 +0100                                                                        
|  summary:     addc                                                                                                  
| o  changeset:   1:6080b678133f                                                                                      
|/   branch:      foo                                                                                                 
|    user:        Patrick Mezard <pmezard at gmail.com>                                                                  
|    date:        Tue Mar 04 09:40:52 2008 +0100                                                                      
|    summary:     addb                                                                                                
o  changeset:   0:a260d8b9e97b                                                                                        
   branch:      foo                                                                                                   
   user:        Patrick Mezard <pmezard at gmail.com>                                                                    
   date:        Tue Mar 04 09:40:45 2008 +0100                                                                        
   summary:     adda                                       

The named branch "foo" has two heads.  I'm saying that a "clone -r foo"
should give me a repo with both heads.  Same for "pull -r foo".
"push -r foo" should push both heads (but maybe it should require -f).
And log -r foo should show both heads.


More information about the Mercurial-devel mailing list