Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templatekw.py @ 34847:e27f1f04c2cf
templatekw: introduce obsfate keyword
Introduce an obsfate printer that uses all helpers functions defined in
obsutil to get all the obsfate-related data and format a string according to
the current format in test-obsmarker-template.t.
Then, introduce an obsfate templatekw that uses the obsfateprinter to return a
list of strings.
The goal is not to replace existing obsfate template functions but to propose
a default, good-enough and easily usable obsfate definition for end-users that
don't want to customize it. Such output would ultimately get included in the
default log output.
Here are some output examples for a commit amended:
rewritten using amend as 5:a9b1f8652753 by test (at 1970-01-01 00:00 +0000)
Next patches will make the output dependent on the verbosity.
Exemple of use-cases:
For having the obsfate on a single-line between brackets:
{if(obsfate, " [{join(obsfate, "; ")}]")}
For having the obsfate in several lines:
{if(obsfate, "{obsfate % " Obsfate: {fate}\n"}")}
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Thu, 05 Oct 2017 17:42:56 +0200 |
parents | bfb6fd93b637 |
children | 29e6513856ee |
line wrap: on
line diff
--- a/mercurial/templatekw.py Tue Oct 10 02:25:03 2017 +0530 +++ b/mercurial/templatekw.py Thu Oct 05 17:42:56 2017 +0200 @@ -600,6 +600,23 @@ # rev and node are completely different from changeset's. return _mappable(f, None, f, lambda x: {'rev': mrev, 'node': mhex}) +@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. + succsandmarkers = showsuccsandmarkers(**args) + + ui = args['ui'] + + values = [] + + for x in succsandmarkers: + values.append(obsutil.obsfateprinter(x['successors'], x['markers'], ui)) + + return showlist("fate", values, args) + def shownames(namespace, **args): """helper method to generate a template keyword for a namespace""" args = pycompat.byteskwargs(args)