[PATCH 2 of 9 phases] phases: ``{phase}`` template keyword display the phase name

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Jan 5 23:40:13 CST 2012


On Thu, Jan 05, 2012 at 09:52:02PM -0600, Matt Mackall wrote:
> On Thu, 2012-01-05 at 02:25 +0100, Pierre-Yves David wrote:
> > # HG changeset patch
> > # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> > # Date 1325690382 -3600
> > # Node ID 6b569ff0bd5dbe065e6f10bdd0c008a1039ce79b
> > # Parent  f6f960709a0373f1163bd7d60944c6656de9493d
> > phases: ``{phase}`` template keyword display the phase name
> > 
> >  ``{phaseidx}`` is providing the phase index as integer.
> 
> Why do we want to ever publicly expose the number?

As I explained to the list before, exposing the sortage property of phase is
useful and the easiess way to do it is to use the same number than internally.

> 
> > Test keep using the number version for readability purpose.
> > 
> > diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
> > --- a/mercurial/templatekw.py
> > +++ b/mercurial/templatekw.py
> > @@ -276,7 +276,11 @@
> >      return ctx.hex()
> >  
> >  def showphase(repo, ctx, templ, **args):
> > -    """:rev: Integer. The changeset phase."""
> > +    """:rev: String. The changeset phase name."""
> > +    return ctx.phasestr()
> > +
> > +def showphaseidx(repo, ctx, templ, **args):
> > +    """:rev: Integer. The changeset phase index."""
> >      return ctx.phase()
> >  
> >  def showrev(repo, ctx, templ, **args):
> > @@ -317,6 +321,7 @@
> >      'manifest': showmanifest,
> >      'node': shownode,
> >      'phase': showphase,
> > +    'phaseidx': showphaseidx,
> >      'rev': showrev,
> >      'tags': showtags,
> >  }
> > diff --git a/tests/test-phases-exchange.t b/tests/test-phases-exchange.t
> > --- a/tests/test-phases-exchange.t
> > +++ b/tests/test-phases-exchange.t
> > @@ -2,7 +2,7 @@
> >    > [extensions]
> >    > graphlog=
> >    > EOF
> > -  $ alias hgph='hg log --template "{rev} {phase} {desc} - {node|short}\n"'
> > +  $ alias hgph='hg log --template "{rev} {phaseidx} {desc} - {node|short}\n"'
> >  
> >    $ mkcommit() {
> >    >    echo "$1" > "$1"
> > diff --git a/tests/test-phases.t b/tests/test-phases.t
> > --- a/tests/test-phases.t
> > +++ b/tests/test-phases.t
> > @@ -1,4 +1,4 @@
> > -  $ alias hglog='hg log --template "{rev} {phase} {desc}\n"'
> > +  $ alias hglog='hg log --template "{rev} {phaseidx} {desc}\n"'
> >    $ mkcommit() {
> >    >    echo "$1" > "$1"
> >    >    hg add "$1"
> 
> 
> -- 
> Mathematics is the supreme nostalgia of our time.
> 
> 


More information about the Mercurial-devel mailing list