template: update obsfate to be more human friendly
authorBoris Feld <boris.feld@octobus.net>
Fri, 26 May 2017 19:21:36 +0200
changeset 2490 94f171534918
parent 2489 84a8219a2f9a
child 2491 e2b6b978f38f
template: update obsfate to be more human friendly Approach the obslog output for the moment.
hgext3rd/evolve/obshistory.py
hgext3rd/evolve/templatekw.py
tests/test-evolve-templates.t
--- a/hgext3rd/evolve/obshistory.py	Fri May 26 13:28:49 2017 +0200
+++ b/hgext3rd/evolve/obshistory.py	Fri May 26 19:21:36 2017 +0200
@@ -515,13 +515,14 @@
         else:
             return 'superseed_split'
 
-def _getobsfateandsuccs(repo, revnode):
+def _getobsfateandsuccs(repo, revnode, successorssets=None):
     """ Return a tuple containing:
     - the reason a revision is obsolete (diverged, pruned or superseed)
     - the list of successors short node if the revision is neither pruned
     or has diverged
     """
-    successorssets = obsolete.successorssets(repo, revnode)
+    if successorssets is None:
+        successorssets = obsolete.successorssets(repo, revnode)
 
     fate = _getobsfate(successorssets)
 
@@ -530,5 +531,21 @@
         successors = [nodemod.short(node_id) for node_id in successorssets[0]]
     else:
         successors = []
+        for succset in successorssets:
+            successors.append([nodemod.short(node_id) for node_id in succset])
 
     return (fate, successors)
+
+def _humanizedobsfate(fate, successors):
+    """ Returns a humanized string for a changeset fate and its successors
+    """
+
+    if fate == 'pruned':
+        return 'pruned'
+    elif fate == 'diverged':
+        msgs = []
+        for successorsset in successors:
+            msgs.append('superseed as %s' % ','.join(successorsset))
+        return ' + '.join(msgs)
+    elif fate in ('superseed', 'superseed_split'):
+        return 'superseed as %s' % ','.join(successors)
--- a/hgext3rd/evolve/templatekw.py	Fri May 26 13:28:49 2017 +0200
+++ b/hgext3rd/evolve/templatekw.py	Fri May 26 19:21:36 2017 +0200
@@ -103,7 +103,7 @@
         return ''
 
     successorssets = closestsuccessors(repo, ctx.node())
-    return obshistory._getobsfate(successorssets)
+    return obshistory._humanizedobsfate(*obshistory._getobsfateandsuccs(repo, ctx, successorssets))
 
 # copy from mercurial.obsolete with a small change to stop at first known changeset.
 
--- a/tests/test-evolve-templates.t	Fri May 26 13:28:49 2017 +0200
+++ b/tests/test-evolve-templates.t	Fri May 26 19:21:36 2017 +0200
@@ -68,7 +68,7 @@
   $ hg tlog
   o  d004c8f274b9 Precursors: 471f378eab4c | Successors:  | Fate:
   |
-  | @  471f378eab4c Precursors:  | Successors: [d004c8f274b9] | Fate: superseed
+  | @  471f378eab4c Precursors:  | Successors: [d004c8f274b9] | Fate: superseed as d004c8f274b9
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -81,7 +81,7 @@
   $ hg tlog
   o  d004c8f274b9 Precursors: a468dc9b3633 | Successors:  | Fate:
   |
-  | @  a468dc9b3633 Precursors:  | Successors: [d004c8f274b9] | Fate: superseed
+  | @  a468dc9b3633 Precursors:  | Successors: [d004c8f274b9] | Fate: superseed as d004c8f274b9
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -90,11 +90,11 @@
   $ hg tlog --hidden
   o  d004c8f274b9 Precursors: a468dc9b3633 | Successors:  | Fate:
   |
-  | @  a468dc9b3633 Precursors: 471f378eab4c | Successors: [d004c8f274b9] | Fate: superseed
+  | @  a468dc9b3633 Precursors: 471f378eab4c | Successors: [d004c8f274b9] | Fate: superseed as d004c8f274b9
   |/
   | x  f137d23bb3e1 Precursors:  | Successors:  | Fate: pruned
   | |
-  | x  471f378eab4c Precursors:  | Successors: [a468dc9b3633] | Fate: superseed
+  | x  471f378eab4c Precursors:  | Successors: [a468dc9b3633] | Fate: superseed as d004c8f274b9
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -109,11 +109,11 @@
   $ hg tlog --hidden
   @  d004c8f274b9 Precursors: a468dc9b3633 | Successors:  | Fate:
   |
-  | x  a468dc9b3633 Precursors: 471f378eab4c | Successors: [d004c8f274b9] | Fate: superseed
+  | x  a468dc9b3633 Precursors: 471f378eab4c | Successors: [d004c8f274b9] | Fate: superseed as d004c8f274b9
   |/
   | x  f137d23bb3e1 Precursors:  | Successors:  | Fate: pruned
   | |
-  | x  471f378eab4c Precursors:  | Successors: [a468dc9b3633] | Fate: superseed
+  | x  471f378eab4c Precursors:  | Successors: [a468dc9b3633] | Fate: superseed as d004c8f274b9
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -214,7 +214,7 @@
   |
   o  337fec4d2edc Precursors: 471597cad322 | Successors:  | Fate:
   |
-  | @  471597cad322 Precursors:  | Successors: [337fec4d2edc, f257fde29c7a] | Fate: superseed_split
+  | @  471597cad322 Precursors:  | Successors: [337fec4d2edc, f257fde29c7a] | Fate: superseed as 337fec4d2edc,f257fde29c7a
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -237,7 +237,7 @@
   |
   o  337fec4d2edc Precursors: 471597cad322 | Successors:  | Fate:
   |
-  | x  471597cad322 Precursors:  | Successors: [337fec4d2edc, f257fde29c7a] | Fate: superseed_split
+  | x  471597cad322 Precursors:  | Successors: [337fec4d2edc, f257fde29c7a] | Fate: superseed as 337fec4d2edc,f257fde29c7a
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -307,7 +307,7 @@
   $ hg tlog
   o  eb5a0daa2192 Precursors: 471f378eab4c | Successors:  | Fate:
   |
-  | @  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
+  | @  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -321,9 +321,9 @@
   $ hg tlog
   o  eb5a0daa2192 Precursors: 0dec01379d3b, 471f378eab4c | Successors:  | Fate:
   |
-  | @  0dec01379d3b Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
+  | @  0dec01379d3b Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192
   | |
-  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
+  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -342,9 +342,9 @@
   $ hg tlog --hidden
   @  eb5a0daa2192 Precursors: 0dec01379d3b, 471f378eab4c | Successors:  | Fate:
   |
-  | x  0dec01379d3b Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
+  | x  0dec01379d3b Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192
   | |
-  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
+  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -426,7 +426,7 @@
   |
   | o  fdf9bde5129a Precursors: 471f378eab4c | Successors:  | Fate:
   |/
-  | @  471f378eab4c Precursors:  | Successors: [fdf9bde5129a], [019fadeab383] | Fate: diverged
+  | @  471f378eab4c Precursors:  | Successors: [fdf9bde5129a], [019fadeab383] | Fate: superseed as fdf9bde5129a + superseed as 019fadeab383
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -445,11 +445,11 @@
   $ hg tlog --hidden
   o  019fadeab383 Precursors: 65b757b745b9 | Successors:  | Fate:
   |
-  | x  65b757b745b9 Precursors: 471f378eab4c | Successors: [019fadeab383] | Fate: superseed
+  | x  65b757b745b9 Precursors: 471f378eab4c | Successors: [019fadeab383] | Fate: superseed as 019fadeab383
   |/
   | @  fdf9bde5129a Precursors: 471f378eab4c | Successors:  | Fate:
   |/
-  | x  471f378eab4c Precursors:  | Successors: [fdf9bde5129a], [65b757b745b9] | Fate: diverged
+  | x  471f378eab4c Precursors:  | Successors: [fdf9bde5129a], [65b757b745b9] | Fate: superseed as fdf9bde5129a + superseed as 019fadeab383
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -530,7 +530,7 @@
   $ hg tlog
   o  eb5a0daa2192 Precursors: 471f378eab4c | Successors:  | Fate:
   |
-  | @  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
+  | @  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -541,9 +541,9 @@
   $ hg tlog
   o  eb5a0daa2192 Precursors: 0dec01379d3b, 471f378eab4c | Successors:  | Fate:
   |
-  | @  0dec01379d3b Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
+  | @  0dec01379d3b Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192
   | |
-  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
+  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -554,9 +554,9 @@
   $ hg tlog
   o  eb5a0daa2192 Precursors: 471f378eab4c, b7ea6d14e664 | Successors:  | Fate:
   |
-  | @  b7ea6d14e664 Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
+  | @  b7ea6d14e664 Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192
   | |
-  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
+  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -570,11 +570,11 @@
   $ hg tlog --hidden
   @  eb5a0daa2192 Precursors: 471f378eab4c, b7ea6d14e664 | Successors:  | Fate:
   |
-  | x  b7ea6d14e664 Precursors: 0dec01379d3b | Successors: [eb5a0daa2192] | Fate: superseed
+  | x  b7ea6d14e664 Precursors: 0dec01379d3b | Successors: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192
   | |
-  | | x  0dec01379d3b Precursors:  | Successors: [b7ea6d14e664] | Fate: superseed
+  | | x  0dec01379d3b Precursors:  | Successors: [b7ea6d14e664] | Fate: superseed as eb5a0daa2192
   | |/
-  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
+  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed as eb5a0daa2192
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -669,7 +669,7 @@
   $ hg tlog
   o  7a230b46bf61 Precursors: 471f378eab4c | Successors:  | Fate:
   |
-  | @  471f378eab4c Precursors:  | Successors: [7a230b46bf61] | Fate: superseed
+  | @  471f378eab4c Precursors:  | Successors: [7a230b46bf61] | Fate: superseed as 7a230b46bf61
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate:
   
@@ -683,7 +683,7 @@
   $ hg tlog --hidden
   @  7a230b46bf61 Precursors: 471f378eab4c | Successors:  | Fate:
   |
-  | x  471f378eab4c Precursors:  | Successors: [7a230b46bf61] | Fate: superseed
+  | x  471f378eab4c Precursors:  | Successors: [7a230b46bf61] | Fate: superseed as 7a230b46bf61
   |/
   o  ea207398892e Precursors:  | Successors:  | Fate: