[PATCH 1 of 3 V2] cmdutil: add support for evolution "troubles" display in changeset_printer

Augie Fackler raf at durin42.com
Tue Nov 8 11:07:24 EST 2016


On Tue, Nov 08, 2016 at 03:19:55PM +0100, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde at logilab.fr>
> # Date 1476094018 -7200
> #      Mon Oct 10 12:06:58 2016 +0200
> # Node ID 8be06285117259ddd122201b1e0428711c0e2a6b
> # Parent  d06c049695e6ad3219e7479c65ce98a2f123e878
> # EXP-Topic evolve-ui
> cmdutil: add support for evolution "troubles" display in changeset_printer
>
> Add a "troubles" line in changeset header along with a couple of labels on
> "log.changeset" line to indicate whether a changeset is troubled or not and
> which kind trouble occurs.

I'm -0 on the word "troubles": it feels wrong in a way I'm having
trouble describing. It definitely feels odd to have a plural for the
label (the line for tags is "tag:" after all) - maybe "trouble:" would
be better?

(I'm very open to better word choices here than trouble, but I have
none to offer.)

>
> Extract a _changesetlabels function to be reused in summary command.
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -1228,6 +1228,14 @@ def diffordiffstat(ui, repo, diffopts, n
>              sub.diff(ui, diffopts, tempnode2, submatch, changes=changes,
>                       stat=stat, fp=fp, prefix=prefix)
>
> +def _changesetlabels(ctx):
> +    labels = ['log.changeset', 'changeset.%s' % ctx.phasestr()]
> +    if ctx.troubled():
> +        labels.append('changeset.troubled')
> +        for trouble in ctx.troubles():
> +            labels.append('trouble.%s' % trouble)
> +    return ' '.join(labels)
> +
>  class changeset_printer(object):
>      '''show changeset information when templating not requested.'''
>
> @@ -1288,7 +1296,7 @@ class changeset_printer(object):
>
>          # i18n: column positioning for "hg log"
>          self.ui.write(_("changeset:   %d:%s\n") % revnode,
> -                      label='log.changeset changeset.%s' % ctx.phasestr())
> +                      label=_changesetlabels(ctx))
>
>          # branches are shown first before any other names due to backwards
>          # compatibility
> @@ -1333,6 +1341,10 @@ class changeset_printer(object):
>          self.ui.write(_("date:        %s\n") % date,
>                        label='log.date')
>
> +        if ctx.troubled():
> +            self.ui.write(_("troubles:    %s\n") % ', '.join(ctx.troubles()),
> +                          label='ui.note log.troubles')
> +
>          if self.ui.debugflag:
>              files = ctx.p1().status(ctx)[:3]
>              for key, value in zip([# i18n: column positioning for "hg log"
> diff --git a/tests/test-commit-amend.t b/tests/test-commit-amend.t
> --- a/tests/test-commit-amend.t
> +++ b/tests/test-commit-amend.t
> @@ -614,6 +614,7 @@ Test that rewriting leaving instability
>    parent:      11:3334b7925910
>    user:        test
>    date:        Thu Jan 01 00:00:00 1970 +0000
> +  troubles:    unstable
>    summary:     babar
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list