[PATCH 05 of 11 V2] templatekw: introduce obsfate keyword

Yuya Nishihara yuya at tcha.org
Wed Oct 11 09:24:56 EDT 2017


On Wed, 11 Oct 2017 14:09:51 +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 34bb2af8638432dea3052eabd4b6eb12a1777e19
> # Parent  8447ccc2c5c91520ca75e6bbdc57100af8d0e931
> # EXP-Topic obsfatekeyword
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 34bb2af86384
> templatekw: introduce obsfate keyword

> +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]
> +        line.append(" as %s" % ", ".join(fmtsuccessors))
> +
> +    # Users
> +    users = markersusers(markers)
> +
> +    if users:
> +        line.append(" by %s" % ", ".join(users))
> +
> +    # Date
> +    dates = markersdates(markers)
> +
> +    min_date = min(dates)
> +    max_date = max(dates)
> +
> +    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
> @@ -580,6 +580,19 @@
>      # rev and node are completely different from changeset's.
>      return _mappable(f, f, lambda: {'rev': mrev, 'node': mhex})
>  
> + at templatekeyword('obsfate')
> +def showobsfate(**args):
> +    succsandmarkers = showsuccsandmarkers(**args)

Ugh, there's templatekw.defaulttempl which provides the default template
fragments to all stock/user templates. Maybe we can (ab)use it to define
the default '{obsfate}' template.

I'm so sorry I didn't mention it before. It totally slipped my mind.


More information about the Mercurial-devel mailing list