[PATCH 1 of 3] identify: change p1/p2 to a list of parents

Matt Harbison mharbison72 at gmail.com
Sun Jun 25 23:55:26 EDT 2017

On Sun, 25 Jun 2017 21:48:02 -0400, Yuya Nishihara <yuya at tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1498436335 -32400
> #      Mon Jun 26 09:18:55 2017 +0900
> # Node ID 556d2afe74385fe2a6dd7cdff5651080a827813f
> # Parent  a49ab7f5e7e765a94a1dfab2ee3b1da695789eb6
> identify: change p1/p2 to a list of parents
> It makes sense because the nested data structure is a list of items.

Having them rolled into one list makes it a little more difficult to  
access in a -T pattern, but maybe that's OK.  (I know nothing about the  
json parsing aspect.)

What I'm hoping to do is build the version string with the template.  The  
closest I came is:

$ ../hg id -T "{latesttag}{if('{dirty}', '+{latesttag % \'{changes}\'}',  
'+{parents % \'{latesttag % \"{changes}\"}\'}')}-{id}{if('{dirty}',  
'{date(date, \"%Y%m%d\")}')}"

Yikes.  This won't work for a (clean) merge revision, since there's no way  
to select only p1.  (And a future subscript operator probably makes this  
more obscure.)  The right thing to do is probably for setup.py to format  
an .hg_archival.txt type file, and then the separate handling there can  
disappear.  But that doesn't really simplify the pattern.

A few years ago you suggested something like '-r "heads(. or wdir() &  
file('glob:**'))" to select the revision based on dirty or not, to  
simplify the template.  But that's blind to '!' files, and thinking beyond  
Mercurial, also doesn't see subrepo changes either.

I'm not sure if it's reasonable to roll this up into a {version()}  
template for this command, to make it easier for 3rd party usage.  My  
concern would be that pip (I think) complains about the current version  
format.  I'm not sure if we will need to change it at some point.  And  
really, it's just the {changes} bit that's complicated here.


More information about the Mercurial-devel mailing list