--- a/hgext3rd/evolve/obshistory.py Fri Jun 16 11:55:40 2017 +0200
+++ b/hgext3rd/evolve/obshistory.py Fri Jun 16 19:48:24 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 = {
--- a/hgext3rd/evolve/templatekw.py Fri Jun 16 11:55:40 2017 +0200
+++ b/hgext3rd/evolve/templatekw.py Fri Jun 16 19:48:24 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"
--- a/tests/test-evolve-templates.t Fri Jun 16 11:55:40 2017 +0200
+++ b/tests/test-evolve-templates.t Fri Jun 16 19:48:24 2017 +0200
@@ -78,13 +78,17 @@
| semi-colon: [d004c8f274b9]
o ea207398892e
+ $ hg up 'desc(A1)' --hidden
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ working directory parent is obsolete! (a468dc9b3633)
+ (use 'hg evolve' to update to its successor: d004c8f274b9)
Precursors template should show current revision as it is the working copy
$ hg tlog
o d004c8f274b9
- | Precursors: 471f378eab4c
- | semi-colon: 471f378eab4c
- | @ 471f378eab4c
+ | Precursors: a468dc9b3633
+ | semi-colon: a468dc9b3633
+ | @ a468dc9b3633
|/ Successors: [d004c8f274b9]
| semi-colon: [d004c8f274b9]
o ea207398892e
@@ -95,29 +99,28 @@
o d004c8f274b9
| Precursors: a468dc9b3633
| semi-colon: a468dc9b3633
- | x a468dc9b3633
+ | @ a468dc9b3633
|/ Precursors: 471f378eab4c
| semi-colon: 471f378eab4c
| Successors: [d004c8f274b9]
| semi-colon: [d004c8f274b9]
| x f137d23bb3e1
| |
- | @ 471f378eab4c
+ | x 471f378eab4c
|/ Successors: [a468dc9b3633]
| semi-colon: [a468dc9b3633]
o ea207398892e
+
+ $ hg up 'desc(A2)'
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg tlog
- o d004c8f274b9
- | Precursors: 471f378eab4c
- | semi-colon: 471f378eab4c
- | @ 471f378eab4c
- |/ Successors: [d004c8f274b9]
- | semi-colon: [d004c8f274b9]
+ @ d004c8f274b9
+ |
o ea207398892e
$ hg tlog --hidden
- o d004c8f274b9
+ @ d004c8f274b9
| Precursors: a468dc9b3633
| semi-colon: a468dc9b3633
| x a468dc9b3633
@@ -127,7 +130,7 @@
| semi-colon: [d004c8f274b9]
| x f137d23bb3e1
| |
- | @ 471f378eab4c
+ | x 471f378eab4c
|/ Successors: [a468dc9b3633]
| semi-colon: [a468dc9b3633]
o ea207398892e
@@ -335,19 +338,27 @@
| semi-colon: [eb5a0daa2192]
o ea207398892e
+ $ hg up 'desc(B0)' --hidden
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ working directory parent is obsolete! (0dec01379d3b)
+ (use 'hg evolve' to update to its successor: eb5a0daa2192)
+
Precursors template should show both precursors as they should be both
displayed
$ hg tlog
o eb5a0daa2192
- | Precursors: 471f378eab4c
- | semi-colon: 471f378eab4c
- | @ 471f378eab4c
+ | Precursors: 0dec01379d3b 471f378eab4c
+ | semi-colon: 0dec01379d3b; 471f378eab4c
+ | @ 0dec01379d3b
+ | | Successors: [eb5a0daa2192]
+ | | semi-colon: [eb5a0daa2192]
+ | x 471f378eab4c
|/ Successors: [eb5a0daa2192]
| semi-colon: [eb5a0daa2192]
o ea207398892e
$ hg up 'desc(C0)'
- 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
Precursors template should not show precursors as it's not displayed in the
log
@@ -464,6 +475,26 @@
|/
o ea207398892e
+
+Precursors template should a precursor as we force its display with --hidden
+ $ hg tlog --hidden
+ o 019fadeab383
+ | Precursors: 65b757b745b9
+ | semi-colon: 65b757b745b9
+ | x 65b757b745b9
+ |/ Precursors: 471f378eab4c
+ | semi-colon: 471f378eab4c
+ | Successors: [019fadeab383]
+ | semi-colon: [019fadeab383]
+ | @ fdf9bde5129a
+ |/ Precursors: 471f378eab4c
+ | semi-colon: 471f378eab4c
+ | x 471f378eab4c
+ |/ Successors: [fdf9bde5129a], [65b757b745b9]
+ | semi-colon: [fdf9bde5129a]; [65b757b745b9]
+ o ea207398892e
+
+
Test templates with amended + folded commit
===========================================
@@ -547,8 +578,49 @@
| semi-colon: [eb5a0daa2192]
o ea207398892e
+ $ hg up 'desc(B0)' --hidden
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ working directory parent is obsolete! (0dec01379d3b)
+ (use 'hg evolve' to update to its successor: eb5a0daa2192)
+ $ hg tlog
+ o eb5a0daa2192
+ | Precursors: 0dec01379d3b 471f378eab4c
+ | semi-colon: 0dec01379d3b; 471f378eab4c
+ | @ 0dec01379d3b
+ | | Successors: [eb5a0daa2192]
+ | | semi-colon: [eb5a0daa2192]
+ | x 471f378eab4c
+ |/ Successors: [eb5a0daa2192]
+ | semi-colon: [eb5a0daa2192]
+ o ea207398892e
+
+
+ $ hg up 'desc(B1)' --hidden
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ working directory parent is obsolete! (b7ea6d14e664)
+ (use 'hg evolve' to update to its successor: eb5a0daa2192)
+ $ hg tlog
+ o eb5a0daa2192
+ | Precursors: 471f378eab4c b7ea6d14e664
+ | semi-colon: 471f378eab4c; b7ea6d14e664
+ | @ b7ea6d14e664
+ | | Successors: [eb5a0daa2192]
+ | | semi-colon: [eb5a0daa2192]
+ | x 471f378eab4c
+ |/ Successors: [eb5a0daa2192]
+ | semi-colon: [eb5a0daa2192]
+ o ea207398892e
+
+
+ $ hg up 'desc(C0)'
+ 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ hg tlog
+ @ eb5a0daa2192
+ |
+ o ea207398892e
+
$ hg tlog --hidden
- o eb5a0daa2192
+ @ eb5a0daa2192
| Precursors: 471f378eab4c b7ea6d14e664
| semi-colon: 471f378eab4c; b7ea6d14e664
| x b7ea6d14e664
@@ -559,7 +631,7 @@
| | x 0dec01379d3b
| |/ Successors: [b7ea6d14e664]
| | semi-colon: [b7ea6d14e664]
- | @ 471f378eab4c
+ | x 471f378eab4c
|/ Successors: [eb5a0daa2192]
| semi-colon: [eb5a0daa2192]
o ea207398892e