[PATCH 1 of 7 V3] templatekw: introduce obsfate keyword

Yuya Nishihara yuya at tcha.org
Wed Oct 18 09:12:37 EDT 2017


On Tue, 17 Oct 2017 17:14:02 +0200, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld at octobus.net>
> # Date 1507218176 -7200
> #      Thu Oct 05 17:42:56 2017 +0200
> # Node ID fc6e8b2484a3eaedd9e4b8ec10f3728b57bfbebe
> # Parent  68e0bcb903572cb3641c1b1ac11bdcf47d4ff5ac
> # EXP-Topic obsfatekeyword
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r fc6e8b2484a3
> templatekw: introduce obsfate keyword

Queued the series, thanks.

> +def obsfateprinter(successors, markers, ui):
> +    """ Build a obsfate string for a single successorset using all obsfate
> +    related function defined in obsutil
> +    """
> +    line = []
> +
> +    # Verb
> +    line.append(successorsetverb(successors))
> +
> +    # Operations
> +    operations = markersoperations(markers)
> +    if operations:
> +        line.append(" using %s" % ", ".join(operations))
> +
> +    # Successors
> +    if successors:
> +        fmtsuccessors = [successors.joinfmt(succ) for succ in successors]

We'll make it not depend on templater stuff because this function will be
called by changeset_printer. Please send a follow up after the release.

> +        line.append(" as %s" % ", ".join(fmtsuccessors))
> +
> +    # Users
> +    users = markersusers(markers)
> +
> +    if users:
> +        line.append(" by %s" % ", ".join(users))

These "using" "as" "by" will need to be translated at once. Please send a
follow up after the release.

> +    # Date
> +    dates = markersdates(markers)
> +
> +    min_date = min(dates)
> +    max_date = max(dates)

If dates is empty, ValueError will be raised. Please send a follow up.

And our coding style still discourage the use of underscore.
https://www.mercurial-scm.org/wiki/CodingStyle#Naming_conventions

> +    if min_date == max_date:
> +        fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2')
> +        line.append(" (at %s)" % fmtmin_date)
> +    else:
> +        fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2')
> +        fmtmax_date = util.datestr(max_date, '%Y-%m-%d %H:%M %1%2')
> +        line.append(" (between %s and %s)" % (fmtmin_date, fmtmax_date))
> +
> +    return "".join(line)

> diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
> --- a/mercurial/templatekw.py
> +++ b/mercurial/templatekw.py
> @@ -600,6 +600,24 @@
>      # rev and node are completely different from changeset's.
>      return _mappable(f, None, f, lambda x: {'rev': mrev, 'node': mhex})
>  
> + at templatekeyword('obsfate')
> +def showobsfate(**args):
> +    """ this function returns a list containing pre-formatted obsfate strings.
> +
> +    This function will be replaced by templates fragments when we will have
> +    the verbosity templatekw available.
> +    """

Changed this to a comment to hide {ofsfate} in help.


More information about the Mercurial-devel mailing list