Mercurial > evolve
changeset 2685:008f7cd1fcbe
obsfate: refactor obsfate data computing
Refactor how obsfate data are computed in order to reuse this logic later when
hooking on default log output.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Mon, 26 Jun 2017 17:19:03 +0200 |
parents | 90e11985d0cc |
children | fc3a66ad635b |
files | hgext3rd/evolve/templatekw.py |
diffstat | 1 files changed, 19 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/templatekw.py Thu Jun 29 16:49:33 2017 +0200 +++ b/hgext3rd/evolve/templatekw.py Mon Jun 26 17:19:03 2017 +0200 @@ -140,10 +140,12 @@ 'obsfate_verbose': verbtempl + usertempl + succtempl + datetempl, } -@eh.templatekw("obsfate") -def showobsfate(repo, ctx, **args): +def obsfatedata(repo, ctx): + """compute the raw data needed for computing obsfate + Returns a list of dict + """ if not ctx.obsolete(): - return '' + return None successorssets, pathcache = closestsuccessors(repo, ctx.node()) @@ -172,7 +174,20 @@ values = [] for sset, rawmarkers in fullsuccessorsets: raw = obshistory.preparesuccessorset(sset, rawmarkers) + values.append(raw) + return values + +@eh.templatekw("obsfate") +def showobsfate(repo, ctx, **args): + # Get the needed obsfate data + values = obsfatedata(repo, ctx) + + if values is None: + return '' + + # Format each successorset successors list + for raw in values: # As we can't do something like # "{join(map(nodeshort, successors), ', '}" in template, manually # create a correct textual representation @@ -183,8 +198,7 @@ raw['successors'] = templatekw._hybrid(gen, raw['successors'], makemap, joinfmt) - values.append(raw) - + # And then format them # Insert default obsfate templates args['templ'].cache.update(obsfatedefaulttempl(repo.ui))