[PATCH 0 of 3] update: allow branch crossing without -c or -C

Matt Mackall mpm at selenic.com
Fri Sep 25 12:34:50 CDT 2009


On Thu, 2009-09-24 at 22:24 -0700, Stuart W. Marks wrote:
> Matt Mackall wrote:
> > On Thu, 2009-09-24 at 12:24 -0700, Stuart W. Marks wrote:
> >> Dirkjan Ochtman wrote:
> >>> On Fri, Sep 18, 2009 at 08:45, Stuart W Marks <smarks at smarks.org> wrote:
> >>>> Patch to allow updating across branches without -c or -C, round two.
> >>> Matt, can you review the resulting behavior?
> >>>
> >>> The ideas here look good to me.
> >> Hi Matt, any thoughts on this? The patch thread is here:
> >>
> >> http://markmail.org/thread/kzmhsufhbvntthlr
> > 
> > Let me see if I can distill your tables a bit further:
> > 
> > -c  -C  dirty   rev  |  linear   same  cross
> >  n   n    n      n        ok      (1)   ok
> >  n   n    n      y        ok      !!!   ok
> >  n   n    y      *      merge     (2)   (3)
> >  n   y    *      *        --- discard ---
> >  y   n    y      *        ---   (5)  ---          
> >  y   n    n      *        ---   ok    ---
> >  y   y    *      *        ---   (4)  --- 
> >  
> > 1 = abort: crosses branches (use 'hg merge' or 'hg update -C')
> > 2 = abort: crosses branches (use 'hg merge' or 'hg update -C'
> >             to discard changes)
> > 3 = abort: crosses named branches (use 'hg update -C' to
> >             discard changes)
> > 4 = abort: uncommitted local changes
> > 5 = incompatible options
> > 
> > So the proposal is to change !!! from (1) to ok, yes?
> 
> Not exactly. There are a few things in the table that aren't quite right:
> 
> - 'hg up' with no REV will go to the head of the current branch, so it cannot 
> cross to another (named) branch
> - the proposal changes behavior both with and without a REV argument (see below)
> - (4) and (5) are swapped
> 
> Here's a revised table:
> 
> -c  -C  dirty   rev  |  linear   same  cross
>   n   n    n      n        ok      !A!   n/a
>   n   n    n      y        ok      !B!   ok
>   n   n    y      *      merge     (2)   (3)
>   n   y    *      *        --- discard ---
>   y   n    y      *        ---   (4)  ---
>   y   n    n      *        ---   ok    ---
>   y   y    *      *        ---   (5)  ---
> 
> 1 = abort: crosses branches (use 'hg merge' or 'hg update -C')
> 2 = abort: crosses branches (use 'hg merge' or 'hg update -C'
>              to discard changes)
> 3 = abort: crosses named branches (use 'hg update -C' to
>              discard changes)
> 4 = abort: uncommitted local changes
> 5 = incompatible options
> 
> Currently, !A! and !B! are both (1). The proposal is to change them both to be ok.

Ok, !A! absolutely must continue to be an abort. Blindly updating and
mysteriously getting new heads is a known major newbie pitfall as I
pointed out the last time I chimed into this topic. In other words,
there's a reason this message has been there for four years.

Making !B! ok is looking pretty reasonable. Let's preserve this table in
a code comment.

Also give a thought to run-time in your test cases. We could
exhaustively test this with 48 test cases, but 13 is probably sufficient
(one for each entry in the table). Most of the non-error cases also get
tested repeatedly elsewhere.

-- 
http://selenic.com : development and support for Mercurial and Linux




More information about the Mercurial-devel mailing list