[PATCH 1 of 5] committablectx: override hex() to return None

Matt Mackall mpm at selenic.com
Tue Apr 7 15:00:46 CDT 2015


On Tue, 2015-04-07 at 11:25 -0700, Pierre-Yves David wrote:
> 
> On 04/07/2015 09:44 AM, Sean Farley wrote:
> >
> > Yuya Nishihara <yuya at tcha.org> writes:
> >
> >> # HG changeset patch
> >> # User Yuya Nishihara <yuya at tcha.org>
> >> # Date 1428141006 -32400
> >> #      Sat Apr 04 18:50:06 2015 +0900
> >> # Node ID 6e0da90c09aab6f350afe167f176d37c4bb83a0e
> >> # Parent  b2fb1403994e033584aed8a487ab162a9d75fa80
> >> committablectx: override hex() to return None
> >>
> >> wctx.hex() crashed before because wctx.node() is None. It could be changed
> >> to return "{p1node}+" but I chose None for consistency with node().
> >> "{p1node}+" is sometimes useful, but not always. Machine-readable output such
> >> as XML does not want it and "|short" filter can't process "+" suffix.
> >
> > Could we not just improve 'short' to handle '+'? We seem to have a
> > precedent with 'hg id' appending '+' and also with the actual node used
> > in the code. I'm unsure what to tell machine-readable output since they
> > still have to deal with it for 'hg id'.
> 
> 
> We should definitely not crash on 'wctx.hex()'
> 
> I mostly agree with Sean here, we should probably use the '<parent>+' 
> notation here for consistency.
> 
> However, if 'wctx.node() → None' it also makes sense to have 'wctx.hex() 
> → None'. (but I do not like the templating implication of it.
> 
> To summarise, I'm a bit confused but I think we should setup things so 
> that template can display <short>+

We should probably undocument "wdir()" until this area is a bit more
complete, but otherwise I'm happy to take stuff that moves things
forward here so we can experiment with it.

Again, "+" is a problem because revsets can't parse "221b+". Nor would
we want it to, probably, because it a) wouldn't be a useful shortcut for
wdir and b) wouldn't be meaningful in general. Nor does just plain "+"
work.

(If we want to get crazy, maybe we can burn another point from our SHA1
space and declare that FFFFFFFFF.. is the hash of the working copy for
symmetry with 0000000... But we don't have a good story for what to do
with revision numbers here.)

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list