template: add the obsfate template
authorBoris Feld <boris.feld@octobus.net>
Fri, 26 May 2017 13:28:49 +0200
changeset 2489 84a8219a2f9a
parent 2488 1bdbe8f55339
child 2490 94f171534918
template: add the obsfate template Reuse _getobsoletefate and nextvisiblesuccessors to easily get the obsolescence fate of any node. The limitation is that obsfate is as precise as these two functions, which is not great for nextvisiblesuccessors.
README
hgext3rd/evolve/templatekw.py
tests/test-evolve-templates.t
--- a/README	Fri May 26 13:18:26 2017 +0200
+++ b/README	Fri May 26 13:28:49 2017 +0200
@@ -119,6 +119,7 @@
  - olog: add an '--all' option to show the whole obsolescence history tree.
  - template: add a 'precursors' template that display the closests precursors of changesets
  - template: add a 'successors' template that display the closests successors of changesets
+ - template: add a 'obsfate' template that display how a changeset has evolved
 
 6.2.2 - in progress
 -------------------
--- a/hgext3rd/evolve/templatekw.py	Fri May 26 13:18:26 2017 +0200
+++ b/hgext3rd/evolve/templatekw.py	Fri May 26 13:28:49 2017 +0200
@@ -10,6 +10,7 @@
 
 from . import (
     exthelper,
+    obshistory
 )
 
 from mercurial import (
@@ -96,6 +97,14 @@
 
     return ', '.join(final)
 
+@eh.templatekw("obsfate")
+def showobsfate(repo, ctx, templ, **args):
+    if not ctx.obsolete():
+        return ''
+
+    successorssets = closestsuccessors(repo, ctx.node())
+    return obshistory._getobsfate(successorssets)
+
 # copy from mercurial.obsolete with a small change to stop at first known changeset.
 
 def directsuccessorssets(repo, initialnode, cache=None):
--- a/tests/test-evolve-templates.t	Fri May 26 13:18:26 2017 +0200
+++ b/tests/test-evolve-templates.t	Fri May 26 13:28:49 2017 +0200
@@ -12,7 +12,7 @@
   > [extensions]
   > evolve =
   > [alias]
-  > tlog = log -G -T '{node|short} Precursors: {precursors} | Successors: {successors}\n'
+  > tlog = log -G -T '{node|short} Precursors: {precursors} | Successors: {successors} | Fate: {obsfate}\n'
   > EOF
 
 Test templates on amended commit
@@ -66,11 +66,11 @@
 
 Precursors template should show current revision as it is the working copy
   $ hg tlog
-  o  d004c8f274b9 Precursors: 471f378eab4c | Successors:
+  o  d004c8f274b9 Precursors: 471f378eab4c | Successors:  | Fate:
   |
-  | @  471f378eab4c Precursors:  | Successors: [d004c8f274b9]
+  | @  471f378eab4c Precursors:  | Successors: [d004c8f274b9] | Fate: superseed
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
   $ hg up 'desc(A1)' --hidden
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -79,43 +79,43 @@
 
 Precursors template should show current revision as it is the working copy
   $ hg tlog
-  o  d004c8f274b9 Precursors: a468dc9b3633 | Successors:
+  o  d004c8f274b9 Precursors: a468dc9b3633 | Successors:  | Fate:
   |
-  | @  a468dc9b3633 Precursors:  | Successors: [d004c8f274b9]
+  | @  a468dc9b3633 Precursors:  | Successors: [d004c8f274b9] | Fate: superseed
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
 Precursors template should show the precursor as we force its display with
 --hidden  
   $ hg tlog --hidden
-  o  d004c8f274b9 Precursors: a468dc9b3633 | Successors:
+  o  d004c8f274b9 Precursors: a468dc9b3633 | Successors:  | Fate:
   |
-  | @  a468dc9b3633 Precursors: 471f378eab4c | Successors: [d004c8f274b9]
+  | @  a468dc9b3633 Precursors: 471f378eab4c | Successors: [d004c8f274b9] | Fate: superseed
   |/
-  | x  f137d23bb3e1 Precursors:  | Successors:
+  | x  f137d23bb3e1 Precursors:  | Successors:  | Fate: pruned
   | |
-  | x  471f378eab4c Precursors:  | Successors: [a468dc9b3633]
+  | x  471f378eab4c Precursors:  | Successors: [a468dc9b3633] | Fate: superseed
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
 
   $ hg up 'desc(A2)'
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg tlog
-  @  d004c8f274b9 Precursors:  | Successors:
+  @  d004c8f274b9 Precursors:  | Successors:  | Fate:
   |
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
   $ hg tlog --hidden
-  @  d004c8f274b9 Precursors: a468dc9b3633 | Successors:
+  @  d004c8f274b9 Precursors: a468dc9b3633 | Successors:  | Fate:
   |
-  | x  a468dc9b3633 Precursors: 471f378eab4c | Successors: [d004c8f274b9]
+  | x  a468dc9b3633 Precursors: 471f378eab4c | Successors: [d004c8f274b9] | Fate: superseed
   |/
-  | x  f137d23bb3e1 Precursors:  | Successors:
+  | x  f137d23bb3e1 Precursors:  | Successors:  | Fate: pruned
   | |
-  | x  471f378eab4c Precursors:  | Successors: [a468dc9b3633]
+  | x  471f378eab4c Precursors:  | Successors: [a468dc9b3633] | Fate: superseed
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
 
 Test templates with splitted commit
@@ -210,13 +210,13 @@
 
 Precursors template should show current revision as it is the working copy
   $ hg tlog
-  o  f257fde29c7a Precursors: 471597cad322 | Successors:
+  o  f257fde29c7a Precursors: 471597cad322 | Successors:  | Fate:
   |
-  o  337fec4d2edc Precursors: 471597cad322 | Successors:
+  o  337fec4d2edc Precursors: 471597cad322 | Successors:  | Fate:
   |
-  | @  471597cad322 Precursors:  | Successors: [337fec4d2edc, f257fde29c7a]
+  | @  471597cad322 Precursors:  | Successors: [337fec4d2edc, f257fde29c7a] | Fate: superseed_split
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
   $ hg up f257fde29c7a
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -224,22 +224,22 @@
 Precursors template should not show a precursor as it's not displayed in the
 log
   $ hg tlog
-  @  f257fde29c7a Precursors:  | Successors:
+  @  f257fde29c7a Precursors:  | Successors:  | Fate:
   |
-  o  337fec4d2edc Precursors:  | Successors:
+  o  337fec4d2edc Precursors:  | Successors:  | Fate:
   |
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
 Precursors template should show the precursor as we force its display with
 --hidden
   $ hg tlog --hidden
-  @  f257fde29c7a Precursors: 471597cad322 | Successors:
+  @  f257fde29c7a Precursors: 471597cad322 | Successors:  | Fate:
   |
-  o  337fec4d2edc Precursors: 471597cad322 | Successors:
+  o  337fec4d2edc Precursors: 471597cad322 | Successors:  | Fate:
   |
-  | x  471597cad322 Precursors:  | Successors: [337fec4d2edc, f257fde29c7a]
+  | x  471597cad322 Precursors:  | Successors: [337fec4d2edc, f257fde29c7a] | Fate: superseed_split
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
 Test templates with folded commit
 ==============================
@@ -305,11 +305,11 @@
 
 Precursors template should show current revision as it is the working copy
   $ hg tlog
-  o  eb5a0daa2192 Precursors: 471f378eab4c | Successors:
+  o  eb5a0daa2192 Precursors: 471f378eab4c | Successors:  | Fate:
   |
-  | @  471f378eab4c Precursors:  | Successors: [eb5a0daa2192]
+  | @  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
   $ hg up 'desc(B0)' --hidden
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -319,13 +319,13 @@
 Precursors template should show both precursors as they should be both
 displayed
   $ hg tlog
-  o  eb5a0daa2192 Precursors: 0dec01379d3b, 471f378eab4c | Successors:
+  o  eb5a0daa2192 Precursors: 0dec01379d3b, 471f378eab4c | Successors:  | Fate:
   |
-  | @  0dec01379d3b Precursors:  | Successors: [eb5a0daa2192]
+  | @  0dec01379d3b Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
   | |
-  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192]
+  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
   $ hg up 'desc(C0)'
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -333,20 +333,20 @@
 Precursors template should not show precursors as it's not displayed in the
 log
   $ hg tlog
-  @  eb5a0daa2192 Precursors:  | Successors:
+  @  eb5a0daa2192 Precursors:  | Successors:  | Fate:
   |
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
 Precursors template should show both precursors as we force its display with
 --hidden
   $ hg tlog --hidden
-  @  eb5a0daa2192 Precursors: 0dec01379d3b, 471f378eab4c | Successors:
+  @  eb5a0daa2192 Precursors: 0dec01379d3b, 471f378eab4c | Successors:  | Fate:
   |
-  | x  0dec01379d3b Precursors:  | Successors: [eb5a0daa2192]
+  | x  0dec01379d3b Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
   | |
-  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192]
+  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
 
 Test templates with divergence
@@ -422,36 +422,36 @@
 
 Precursors template should show current revision as it is the working copy
   $ hg tlog
-  o  019fadeab383 Precursors: 471f378eab4c | Successors:
+  o  019fadeab383 Precursors: 471f378eab4c | Successors:  | Fate:
   |
-  | o  fdf9bde5129a Precursors: 471f378eab4c | Successors:
+  | o  fdf9bde5129a Precursors: 471f378eab4c | Successors:  | Fate:
   |/
-  | @  471f378eab4c Precursors:  | Successors: [fdf9bde5129a], [019fadeab383]
+  | @  471f378eab4c Precursors:  | Successors: [fdf9bde5129a], [019fadeab383] | Fate: diverged
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
   $ hg up 'desc(A1)'
   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
   $ hg tlog
-  o  019fadeab383 Precursors:  | Successors:
+  o  019fadeab383 Precursors:  | Successors:  | Fate:
   |
-  | @  fdf9bde5129a Precursors:  | Successors:
+  | @  fdf9bde5129a Precursors:  | Successors:  | Fate:
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
 Precursors template should a precursor as we force its display with --hidden
   $ hg tlog --hidden
-  o  019fadeab383 Precursors: 65b757b745b9 | Successors:
+  o  019fadeab383 Precursors: 65b757b745b9 | Successors:  | Fate:
   |
-  | x  65b757b745b9 Precursors: 471f378eab4c | Successors: [019fadeab383]
+  | x  65b757b745b9 Precursors: 471f378eab4c | Successors: [019fadeab383] | Fate: superseed
   |/
-  | @  fdf9bde5129a Precursors: 471f378eab4c | Successors:
+  | @  fdf9bde5129a Precursors: 471f378eab4c | Successors:  | Fate:
   |/
-  | x  471f378eab4c Precursors:  | Successors: [fdf9bde5129a], [65b757b745b9]
+  | x  471f378eab4c Precursors:  | Successors: [fdf9bde5129a], [65b757b745b9] | Fate: diverged
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
 Test templates with amended + folded commit
 ===========================================
@@ -528,55 +528,55 @@
   working directory parent is obsolete! (471f378eab4c)
   (use 'hg evolve' to update to its successor: eb5a0daa2192)
   $ hg tlog
-  o  eb5a0daa2192 Precursors: 471f378eab4c | Successors:
+  o  eb5a0daa2192 Precursors: 471f378eab4c | Successors:  | Fate:
   |
-  | @  471f378eab4c Precursors:  | Successors: [eb5a0daa2192]
+  | @  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
   $ 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 | Successors:
+  o  eb5a0daa2192 Precursors: 0dec01379d3b, 471f378eab4c | Successors:  | Fate:
   |
-  | @  0dec01379d3b Precursors:  | Successors: [eb5a0daa2192]
+  | @  0dec01379d3b Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
   | |
-  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192]
+  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
   $ 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 | Successors:
+  o  eb5a0daa2192 Precursors: 471f378eab4c, b7ea6d14e664 | Successors:  | Fate:
   |
-  | @  b7ea6d14e664 Precursors:  | Successors: [eb5a0daa2192]
+  | @  b7ea6d14e664 Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
   | |
-  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192]
+  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
   $ hg up 'desc(C0)'
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg tlog
-  @  eb5a0daa2192 Precursors:  | Successors:
+  @  eb5a0daa2192 Precursors:  | Successors:  | Fate:
   |
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
   $ hg tlog --hidden
-  @  eb5a0daa2192 Precursors: 471f378eab4c, b7ea6d14e664 | Successors:
+  @  eb5a0daa2192 Precursors: 471f378eab4c, b7ea6d14e664 | Successors:  | Fate:
   |
-  | x  b7ea6d14e664 Precursors: 0dec01379d3b | Successors: [eb5a0daa2192]
+  | x  b7ea6d14e664 Precursors: 0dec01379d3b | Successors: [eb5a0daa2192] | Fate: superseed
   | |
-  | | x  0dec01379d3b Precursors:  | Successors: [b7ea6d14e664]
+  | | x  0dec01379d3b Precursors:  | Successors: [b7ea6d14e664] | Fate: superseed
   | |/
-  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192]
+  | x  471f378eab4c Precursors:  | Successors: [eb5a0daa2192] | Fate: superseed
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
 
 Test template with pushed and pulled obs markers
@@ -667,23 +667,23 @@
 ---------------
 
   $ hg tlog
-  o  7a230b46bf61 Precursors: 471f378eab4c | Successors:
+  o  7a230b46bf61 Precursors: 471f378eab4c | Successors:  | Fate:
   |
-  | @  471f378eab4c Precursors:  | Successors: [7a230b46bf61]
+  | @  471f378eab4c Precursors:  | Successors: [7a230b46bf61] | Fate: superseed
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
   $ hg up 'desc(A2)'
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg tlog
-  @  7a230b46bf61 Precursors:  | Successors:
+  @  7a230b46bf61 Precursors:  | Successors:  | Fate:
   |
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate:
   
   $ hg tlog --hidden
-  @  7a230b46bf61 Precursors: 471f378eab4c | Successors:
+  @  7a230b46bf61 Precursors: 471f378eab4c | Successors:  | Fate:
   |
-  | x  471f378eab4c Precursors:  | Successors: [7a230b46bf61]
+  | x  471f378eab4c Precursors:  | Successors: [7a230b46bf61] | Fate: superseed
   |/
-  o  ea207398892e Precursors:  | Successors:
+  o  ea207398892e Precursors:  | Successors:  | Fate: