[PATCH 2 of 2] templatekw: introduce the changessincelatesttag keyword

Yuya Nishihara yuya at tcha.org
Mon Jun 29 08:11:24 CDT 2015


On Sun, 28 Jun 2015 12:51:38 -0400, Matt Harbison wrote:
> On Sun, 28 Jun 2015 07:03:21 -0400, Yuya Nishihara <yuya at tcha.org> wrote:
> > On Sat, 27 Jun 2015 12:50:48 -0400, Matt Harbison wrote:
> >> On Sat, 27 Jun 2015 09:15:33 -0400, Yuya Nishihara <yuya at tcha.org>  
> >> wrote:
> >> > On Sat, 27 Jun 2015 00:01:24 -0400, Matt Harbison wrote:
> >> >> +def showchangessincelatesttag(repo, ctx, templ, cache, **args):
> >> >> +    """:changessincelatesttag: Integer. All ancestors not in the
> >> >> latest tag."""
> >> >> +    latesttag = getlatesttags(repo, ctx, cache)[2][0]
> >> >> +    offset = 0
> >> >> +
> >> >> +    if ctx.rev() is None:
> >> >> +        if ctx.dirty(missing=True):
> >> >> +            offset = 1
> >> >
> >> > IMHO, offset is always 1 because the wdir revision exists no matter if
> >> > it is
> >> > dirty or not.
> >>
> >> Is there an ease of coding something factor?  It seems a bit surprising  
> >> to
> >> me if you clean update to a tag, that immediately the change count is 1.
> >
> > We expect that "hg log -r 'wdir()'" shows something related to the wdir  
> > even
> > if it is clean, which means that the clean wdir resides in the log.
> >
> >   T -- 1 -- 2 -- wdir()
> >                  [clean]
> 
> Makes sense.
> 
> > In the example above, if 'only()' could handle 'wdir()', 'only(wdir(),  
> > T)'
> > should be evaluated to [1, 2, wdirrev]. So I think the offset should  
> > always
> > be 1 for consistency.
> 
> Ah, so there's the difference.  I don't think of this keyword as "_offset_  
>  from latest tag", but "how many _changes_ since the latest tag", where  
> changes are measured in commits + what could be committed.  (Obviously a  
> clean wdir() can't be committed.)  There's already a distance keyword.   
> (What I'm proposing here would change the current invariant of changes >=  
> distance to changes >= distance - 1.)

Well, but if you specify the 'wdir()' explicitly, it should be there.
It is a log template, and a log shows each changeset no matter if it is
empty or not. So I expect that {changessincelatesttag} will count the number
of changesets including empty one.

Also, you can make an empty commit by qnew, commit --close-branch or
ui.allowemptycommit.


More information about the Mercurial-devel mailing list