# HG changeset patch # User Pierre-Yves David # Date 1497634056 -7200 # Node ID 01e32f11f1ef1da6909779cd32424f5a862cbd9c # Parent 9a1c92132519cf58574da5556537f088874c4315# Parent 3d432af2f6cd3d2be12d0f3bce5c11c99cbf2ef4 compat-test: merge with stable diff -r 9a1c92132519 -r 01e32f11f1ef hgext3rd/evolve/obshistory.py --- a/hgext3rd/evolve/obshistory.py Fri Jun 16 19:37:13 2017 +0200 +++ b/hgext3rd/evolve/obshistory.py Fri Jun 16 19:27:36 2017 +0200 @@ -629,11 +629,13 @@ def _successorsetverb(successorset, markers): """ Return the verb summarizing the successorset """ - # XXX we need to handle prune markers at some point. - if not markers: - return {'verb': 'pruned'} - - return {'verb': 'rewritten'} + if not successorset: + verb = 'pruned' + elif len(successorset) == 1: + verb = 'rewritten' + else: + verb = 'split' + return {'verb': verb} FORMATSSETSFUNCTIONS = [ _successorsetdates, @@ -641,7 +643,7 @@ _successorsetverb ] -def _successorsetallmarkers(successorset, pathscache): +def successorsetallmarkers(successorset, pathscache): """compute all successors of a successorset. pathscache must contains all successors starting from selected nodes @@ -669,11 +671,24 @@ return markers -def _preparesuccessorset(successorset, pathscache): +def preparesuccessorset(successorset, rawmarkers): """ For a successor set, get all related markers, compute the set of user, the min date and the max date """ - markers = _successorsetallmarkers(successorset, pathscache) + hex = nodemod.hex + + successorset = [hex(n) for n in successorset] + + # hex the binary nodes in the markers + markers = [] + for m in rawmarkers: + hexprec = hex(m[0]) + hexsucs = tuple(hex(n) for n in m[1]) + hexparents = None + if m[5] is not None: + hexparents = tuple(hex(n) for n in m[5]) + newmarker = (hexprec, hexsucs) + m[2:5] + (hexparents,) + m[6:] + markers.append(newmarker) # Format basic data data = { diff -r 9a1c92132519 -r 01e32f11f1ef hgext3rd/evolve/templatekw.py --- a/hgext3rd/evolve/templatekw.py Fri Jun 16 19:37:13 2017 +0200 +++ b/hgext3rd/evolve/templatekw.py Fri Jun 16 19:27:36 2017 +0200 @@ -9,6 +9,7 @@ """ from . import ( + error, exthelper, obshistory ) @@ -65,18 +66,18 @@ @eh.templatekw("precursors") def shownextvisibleprecursors(repo, ctx, **args): - """Returns a string containing the list if the closest successors - displayed + """Returns a string containing the list of the closest precursors """ precursors = sorted(closestprecursors(repo, ctx.node())) + precursors = [node.hex(p) for p in precursors] # <= hg-4.1 requires an explicite gen. # we can use None once the support is dropped # # They also requires an iterator instead of an iterable. - gen = iter(" ".join(map(node.short, precursors))) + gen = iter(" ".join(p[:12] for p in precursors)) return templatekw._hybrid(gen.__iter__(), precursors, lambda x: {'precursor': x}, - lambda d: "%s" % node.short(d['precursor'])) + lambda d: d['precursor'][:12]) def closestsuccessors(repo, nodeid): """ returns the closest visible successors sets instead. @@ -85,18 +86,20 @@ @eh.templatekw("successors") def shownextvisiblesuccessors(repo, ctx, templ, **args): - """Returns a string of sets of successors for a changectx in this format: - [ctx1, ctx2], [ctx3] if ctx has been splitted into ctx1 and ctx2 while - also diverged into ctx3""" + """Returns a string of sets of successors for a changectx + + Format used is: [ctx1, ctx2], [ctx3] if ctx has been splitted into ctx1 and + ctx2 while also diverged into ctx3""" if not ctx.obsolete(): return '' ssets, _ = closestsuccessors(repo, ctx.node()) + ssets = [[node.hex(n) for n in ss] for ss in ssets] data = [] gen = [] for ss in ssets: - subgen = '[%s]' % ', '.join(map(node.short, ss)) + subgen = '[%s]' % ', '.join(n[:12] for n in ss) gen.append(subgen) h = templatekw._hybrid(iter(subgen), ss, lambda x: {'successor': x}, lambda d: "%s" % d["successor"]) @@ -106,7 +109,14 @@ return templatekw._hybrid(iter(gen), data, lambda x: {'successorset': x}, lambda d: d["successorset"]) -def obsfatedefaulttempl(): +def _getusername(ui): + """the default username in the config or None""" + try: + return ui.username() + except error.Abort: # no easy way to avoid ui raising Abort here :-/ + return None + +def obsfatedefaulttempl(ui): """ Returns a dict with the default templates for obs fate """ # Prepare templates @@ -118,10 +128,16 @@ datetempl = '{if(max_date, "{ifeq(min_date, max_date, "%s", "%s")}")}' % (datetempleq, datetemplnoteq) newline = '\n' + optionalusertempl = usertempl + username = _getusername(ui) + if username is not None: + optionalusertempl = ('{ifeq(join(users, "\0"), "%s", "", "%s")}' + % (username, usertempl)) + # Assemble them return { 'obsfate_quiet': verbtempl + succtempl + newline, - 'obsfate': verbtempl + usertempl + succtempl + newline, + 'obsfate': verbtempl + optionalusertempl + succtempl + newline, 'obsfate_verbose': verbtempl + usertempl + succtempl + datetempl + newline } @@ -137,14 +153,31 @@ if successorssets == []: successorssets = [[]] + succsmap = repo.obsstore.successors + fullsuccessorsets = [] # successor set + markers + for sset in successorssets: + if sset: + markers = obshistory.successorsetallmarkers(sset, pathcache) + fullsuccessorsets.append((sset, markers)) + else: + # XXX we do not catch all prune markers (eg rewritten then pruned) + # (fix me later) + foundany = False + for mark in succsmap.get(ctx.node(), ()): + if not mark[1]: + foundany = True + fullsuccessorsets.append((sset, [mark])) + if not foundany: + fullsuccessorsets.append(([], [])) + values = [] - for successorset in successorssets: - raw = obshistory._preparesuccessorset(successorset, pathcache) + for sset, rawmarkers in fullsuccessorsets: + raw = obshistory.preparesuccessorset(sset, rawmarkers) # As we can't do something like # "{join(map(nodeshort, successors), ', '}" in template, manually # create a correct textual representation - gen = ', '.join(map(node.short, raw['successors'])) + gen = ', '.join(n[:12] for n in raw['successors']) makemap = lambda x: {'successor': x} joinfmt = lambda d: "%s" % d['successor'] @@ -154,7 +187,7 @@ values.append(raw) # Insert default obsfate templates - args['templ'].cache.update(obsfatedefaulttempl()) + args['templ'].cache.update(obsfatedefaulttempl(repo.ui)) if repo.ui.quiet: name = "obsfate_quiet"