# HG changeset patch # User Boris Feld # Date 1498490343 -7200 # Node ID 008f7cd1fcbe749654beb7bd18cdfe71857d1da3 # Parent 90e11985d0ccde540721c3e992f190c6ff8b2a5d obsfate: refactor obsfate data computing Refactor how obsfate data are computed in order to reuse this logic later when hooking on default log output. diff -r 90e11985d0cc -r 008f7cd1fcbe hgext3rd/evolve/templatekw.py --- 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))