changeset 5282:0bc31f853862

templatekw: add obsorigin keyword
author Anton Shestakov <av6@dwimlabs.net>
date Tue, 10 Mar 2020 17:18:09 +0700
parents 0dc4c16506fc
children 9e2f2557c42e
files hgext3rd/evolve/obshistory.py hgext3rd/evolve/templatekw.py tests/test-evolve-templates.t
diffstat 3 files changed, 292 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/obshistory.py	Fri Apr 24 01:14:34 2020 +0800
+++ b/hgext3rd/evolve/obshistory.py	Tue Mar 10 17:18:09 2020 +0700
@@ -23,6 +23,8 @@
     util,
 )
 
+from mercurial.utils import dateutil
+
 from mercurial.i18n import _
 
 from . import (
@@ -814,3 +816,61 @@
 @eh.wrapfunction(obsutil, 'obsfateverb')
 def obsfateverb(orig, *args, **kwargs):
     return _successorsetverb(*args, **kwargs)[b'verb']
+
+def obsoriginprinter(ui, repo, predecessors, markers):
+    """ Build an obsorigin string for a single set of predecessors.
+    """
+    quiet = ui.quiet
+    verbose = ui.verbose
+    normal = not verbose and not quiet
+
+    line = []
+
+    # Verb
+    line.append(_predecessorsverb(predecessors, markers))
+
+    # Operations
+    operations = obsutil.markersoperations(markers)
+    if operations:
+        line.append(b" using %s" % b", ".join(operations))
+
+    # Predecessors
+    if predecessors:
+        unfi = repo.unfiltered()
+
+        def formatnode(node):
+            if node in unfi:
+                return scmutil.formatchangeid(unfi[node])
+            return nodemod.short(node)
+
+        fmtpredecessors = [formatnode(pred) for pred in predecessors]
+        line.append(b" from %s" % b", ".join(sorted(fmtpredecessors)))
+
+    # Users
+    users = obsutil.markersusers(markers)
+    # Filter out current user in not verbose mode to reduce amount of
+    # information
+    if not verbose:
+        currentuser = ui.username(acceptempty=True)
+        if len(users) == 1 and currentuser in users:
+            users = None
+
+    if (verbose or normal) and users:
+        line.append(b" by %s" % b", ".join(users))
+
+    # Dates
+    dates = obsutil.markersdates(markers)
+
+    if dates and verbose:
+        min_date = min(dates)
+        max_date = max(dates)
+
+        if min_date == max_date:
+            fmtmin_date = dateutil.datestr(min_date, b'%Y-%m-%d %H:%M %1%2')
+            line.append(b" (at %s)" % fmtmin_date)
+        else:
+            fmtmin_date = dateutil.datestr(min_date, b'%Y-%m-%d %H:%M %1%2')
+            fmtmax_date = dateutil.datestr(max_date, b'%Y-%m-%d %H:%M %1%2')
+            line.append(b" (between %s and %s)" % (fmtmin_date, fmtmax_date))
+
+    return b"".join(line)
--- a/hgext3rd/evolve/templatekw.py	Fri Apr 24 01:14:34 2020 +0800
+++ b/hgext3rd/evolve/templatekw.py	Tue Mar 10 17:18:09 2020 +0700
@@ -11,6 +11,7 @@
 from . import (
     error,
     exthelper,
+    obshistory,
 )
 
 from mercurial import (
@@ -37,6 +38,18 @@
     return templatekw.compatlist(context, mapping, b'trouble',
                                  ctx.instabilities(), plural=b'troubles')
 
+@eh.templatekeyword(b'obsorigin', requires={b'ui', b'repo', b'ctx'})
+def showobsorigin(context, mapping):
+    ui = context.resource(mapping, b'ui')
+    repo = context.resource(mapping, b'repo')
+    ctx = context.resource(mapping, b'ctx')
+    values = []
+    r = obshistory.predecessorsandmarkers(repo, ctx.node())
+    for (nodes, markers) in sorted(obshistory.groupbyfoldid(r)):
+        v = obshistory.obsoriginprinter(ui, repo, nodes, markers)
+        values.append(v)
+    return templatekw.compatlist(context, mapping, b'origin', values)
+
 _sp = templatekw.showpredecessors
 if util.safehasattr(_sp, '_requires'):
     def showprecursors(context, mapping):
--- a/tests/test-evolve-templates.t	Fri Apr 24 01:14:34 2020 +0800
+++ b/tests/test-evolve-templates.t	Tue Mar 10 17:18:09 2020 +0700
@@ -19,8 +19,11 @@
   >     {if(predecessors, "\n  semi-colon: {join(predecessors, "; ")}")}\
   >     {if(successors, "\n  Successors: {successors}")}\
   >     {if(successors, "\n  semi-colon: {join(successors, "; ")}")}\
-  >     {if(obsfate, "\n  Fate: {join(obsfate, "\n  Fate: ")}\n")}\n'
-  > fatelog = log -G -T '{node|short}\n{if(obsfate, "  Obsfate: {join(obsfate, "; ")}\n\n")}'
+  >     {if(obsfate, "{obsfate % "\n  Fate: {fate}"}")}\
+  >     {if(obsorigin, "{obsorigin % "\n  Origin: {origin}"}")}\n\n'
+  > fateoriginlog = log -G -T '{node|short}\
+  >     {if(obsfate, "\n  Obsfate: {join(obsfate, "; ")}")}\
+  >     {if(obsorigin, "\n  Obsorigin: {join(obsorigin, "; ")}")}\n\n'
   > EOF
 
 Test templates on amended commit
@@ -85,6 +88,8 @@
   o  d004c8f274b9
   |    Predecessors: 1:471f378eab4c
   |    semi-colon: 1:471f378eab4c
+  |    Origin: rewritten using amend from 1:471f378eab4c by test, test2
+  |
   | @  471f378eab4c
   |/     Successors: 3:d004c8f274b9
   |      semi-colon: 3:d004c8f274b9
@@ -113,8 +118,9 @@
      summary:     ROOT
   
 
-  $ hg fatelog -q
+  $ hg fateoriginlog -q
   o  d004c8f274b9
+  |    Obsorigin: rewritten using amend from 1:471f378eab4c
   |
   | @  471f378eab4c
   |/     Obsfate: rewritten using amend as 3:d004c8f274b9
@@ -122,16 +128,18 @@
   o  ea207398892e
   
 
-  $ hg fatelog
+  $ hg fateoriginlog
   o  d004c8f274b9
+  |    Obsorigin: rewritten using amend from 1:471f378eab4c by test, test2
   |
   | @  471f378eab4c
   |/     Obsfate: rewritten using amend as 3:d004c8f274b9 by test, test2
   |
   o  ea207398892e
   
-  $ hg fatelog -v
+  $ hg fateoriginlog -v
   o  d004c8f274b9
+  |    Obsorigin: rewritten using amend from 1:471f378eab4c by test, test2 (between 2001-04-19 04:25 +0000 and 2009-02-13 23:31 +0000)
   |
   | @  471f378eab4c
   |/     Obsfate: rewritten using amend as 3:d004c8f274b9 by test, test2 (between 2001-04-19 04:25 +0000 and 2009-02-13 23:31 +0000)
@@ -169,6 +177,8 @@
   o  d004c8f274b9
   |    Predecessors: 2:a468dc9b3633
   |    semi-colon: 2:a468dc9b3633
+  |    Origin: reworded using amend from 2:a468dc9b3633 by test2
+  |
   | @  a468dc9b3633
   |/     Successors: 3:d004c8f274b9
   |      semi-colon: 3:d004c8f274b9
@@ -182,12 +192,15 @@
   o  d004c8f274b9
   |    Predecessors: 2:a468dc9b3633
   |    semi-colon: 2:a468dc9b3633
+  |    Origin: reworded using amend from 2:a468dc9b3633 by test2
+  |
   | @  a468dc9b3633
   |/     Predecessors: 1:471f378eab4c
   |      semi-colon: 1:471f378eab4c
   |      Successors: 3:d004c8f274b9
   |      semi-colon: 3:d004c8f274b9
   |      Fate: reworded using amend as 3:d004c8f274b9 by test2
+  |      Origin: rewritten using amend from 1:471f378eab4c
   |
   | x  471f378eab4c
   |/     Successors: 2:a468dc9b3633
@@ -196,8 +209,9 @@
   |
   o  ea207398892e
   
-  $ hg fatelog -v
+  $ hg fateoriginlog -v
   o  d004c8f274b9
+  |    Obsorigin: reworded using amend from 2:a468dc9b3633 by test2 (at 2001-04-19 04:25 +0000)
   |
   | @  a468dc9b3633
   |/     Obsfate: reworded using amend as 3:d004c8f274b9 by test2 (at 2001-04-19 04:25 +0000)
@@ -215,12 +229,15 @@
   @  d004c8f274b9
   |    Predecessors: 2:a468dc9b3633
   |    semi-colon: 2:a468dc9b3633
+  |    Origin: reworded using amend from 2:a468dc9b3633 by test2
+  |
   | x  a468dc9b3633
   |/     Predecessors: 1:471f378eab4c
   |      semi-colon: 1:471f378eab4c
   |      Successors: 3:d004c8f274b9
   |      semi-colon: 3:d004c8f274b9
   |      Fate: reworded using amend as 3:d004c8f274b9 by test2
+  |      Origin: rewritten using amend from 1:471f378eab4c
   |
   | x  471f378eab4c
   |/     Successors: 2:a468dc9b3633
@@ -229,17 +246,19 @@
   |
   o  ea207398892e
   
-  $ hg fatelog -v
+  $ hg fateoriginlog -v
   @  d004c8f274b9
   |
   o  ea207398892e
   
 
-  $ hg fatelog -v --hidden
+  $ hg fateoriginlog -v --hidden
   @  d004c8f274b9
+  |    Obsorigin: reworded using amend from 2:a468dc9b3633 by test2 (at 2001-04-19 04:25 +0000)
   |
   | x  a468dc9b3633
   |/     Obsfate: reworded using amend as 3:d004c8f274b9 by test2 (at 2001-04-19 04:25 +0000)
+  |      Obsorigin: rewritten using amend from 1:471f378eab4c by test (at 2009-02-13 23:31 +0000)
   |
   | x  471f378eab4c
   |/     Obsfate: rewritten using amend as 2:a468dc9b3633 by test (at 2009-02-13 23:31 +0000)
@@ -350,9 +369,13 @@
   o  f257fde29c7a
   |    Predecessors: 1:471597cad322
   |    semi-colon: 1:471597cad322
+  |    Origin: split using split from 1:471597cad322
+  |
   o  337fec4d2edc
   |    Predecessors: 1:471597cad322
   |    semi-colon: 1:471597cad322
+  |    Origin: split using split from 1:471597cad322
+  |
   | @  471597cad322
   |/     Successors: 2:337fec4d2edc 3:f257fde29c7a
   |      semi-colon: 2:337fec4d2edc 3:f257fde29c7a
@@ -360,10 +383,12 @@
   |
   o  ea207398892e
   
-  $ hg fatelog
+  $ hg fateoriginlog
   o  f257fde29c7a
+  |    Obsorigin: split using split from 1:471597cad322
   |
   o  337fec4d2edc
+  |    Obsorigin: split using split from 1:471597cad322
   |
   | @  471597cad322
   |/     Obsfate: split using split as 2:337fec4d2edc, 3:f257fde29c7a
@@ -389,9 +414,13 @@
   @  f257fde29c7a
   |    Predecessors: 1:471597cad322
   |    semi-colon: 1:471597cad322
+  |    Origin: split using split from 1:471597cad322
+  |
   o  337fec4d2edc
   |    Predecessors: 1:471597cad322
   |    semi-colon: 1:471597cad322
+  |    Origin: split using split from 1:471597cad322
+  |
   | x  471597cad322
   |/     Successors: 2:337fec4d2edc 3:f257fde29c7a
   |      semi-colon: 2:337fec4d2edc 3:f257fde29c7a
@@ -399,10 +428,12 @@
   |
   o  ea207398892e
   
-  $ hg fatelog --hidden
+  $ hg fateoriginlog --hidden
   @  f257fde29c7a
+  |    Obsorigin: split using split from 1:471597cad322
   |
   o  337fec4d2edc
+  |    Obsorigin: split using split from 1:471597cad322
   |
   | x  471597cad322
   |/     Obsfate: split using split as 2:337fec4d2edc, 3:f257fde29c7a
@@ -481,6 +512,8 @@
   o  eb5a0daa2192
   |    Predecessors: 1:471f378eab4c
   |    semi-colon: 1:471f378eab4c
+  |    Origin: folded using fold from 1:471f378eab4c
+  |
   | @  471f378eab4c
   |/     Successors: 3:eb5a0daa2192
   |      semi-colon: 3:eb5a0daa2192
@@ -488,8 +521,9 @@
   |
   o  ea207398892e
   
-  $ hg fatelog
+  $ hg fateoriginlog
   o  eb5a0daa2192
+  |    Obsorigin: folded using fold from 1:471f378eab4c
   |
   | @  471f378eab4c
   |/     Obsfate: folded using fold as 3:eb5a0daa2192
@@ -509,6 +543,8 @@
   o  eb5a0daa2192
   |    Predecessors: 2:0dec01379d3b 1:471f378eab4c
   |    semi-colon: 2:0dec01379d3b; 1:471f378eab4c
+  |    Origin: folded using fold from 1:471f378eab4c, 2:0dec01379d3b
+  |
   | @  0dec01379d3b
   | |    Successors: 3:eb5a0daa2192
   | |    semi-colon: 3:eb5a0daa2192
@@ -521,8 +557,9 @@
   |
   o  ea207398892e
   
-  $ hg fatelog
+  $ hg fateoriginlog
   o  eb5a0daa2192
+  |    Obsorigin: folded using fold from 1:471f378eab4c, 2:0dec01379d3b
   |
   | @  0dec01379d3b
   | |    Obsfate: folded using fold as 3:eb5a0daa2192
@@ -549,6 +586,8 @@
   @  eb5a0daa2192
   |    Predecessors: 2:0dec01379d3b 1:471f378eab4c
   |    semi-colon: 2:0dec01379d3b; 1:471f378eab4c
+  |    Origin: folded using fold from 1:471f378eab4c, 2:0dec01379d3b
+  |
   | x  0dec01379d3b
   | |    Successors: 3:eb5a0daa2192
   | |    semi-colon: 3:eb5a0daa2192
@@ -561,8 +600,9 @@
   |
   o  ea207398892e
   
-  $ hg fatelog --hidden
+  $ hg fateoriginlog --hidden
   @  eb5a0daa2192
+  |    Obsorigin: folded using fold from 1:471f378eab4c, 2:0dec01379d3b
   |
   | x  0dec01379d3b
   | |    Obsfate: folded using fold as 3:eb5a0daa2192
@@ -656,9 +696,13 @@
   *  019fadeab383
   |    Predecessors: 1:471f378eab4c
   |    semi-colon: 1:471f378eab4c
+  |    Origin: reworded using amend from 1:471f378eab4c
+  |
   | *  fdf9bde5129a
   |/     Predecessors: 1:471f378eab4c
   |      semi-colon: 1:471f378eab4c
+  |      Origin: reworded using amend from 1:471f378eab4c
+  |
   | @  471f378eab4c
   |/     Successors: 2:fdf9bde5129a; 4:019fadeab383
   |      semi-colon: 2:fdf9bde5129a; 4:019fadeab383
@@ -667,11 +711,13 @@
   |
   o  ea207398892e
   
-  $ hg fatelog
+  $ hg fateoriginlog
   *  019fadeab383
+  |    Obsorigin: reworded using amend from 1:471f378eab4c
   |
   | *  fdf9bde5129a
-  |/
+  |/     Obsorigin: reworded using amend from 1:471f378eab4c
+  |
   | @  471f378eab4c
   |/     Obsfate: reworded using amend as 2:fdf9bde5129a; reworded using amend as 4:019fadeab383
   |
@@ -690,7 +736,7 @@
   o  ea207398892e
   
 
-  $ hg fatelog
+  $ hg fateoriginlog
   *  019fadeab383
   |
   | @  fdf9bde5129a
@@ -702,16 +748,21 @@
   *  019fadeab383
   |    Predecessors: 3:65b757b745b9
   |    semi-colon: 3:65b757b745b9
+  |    Origin: reworded using amend from 3:65b757b745b9
+  |
   | x  65b757b745b9
   |/     Predecessors: 1:471f378eab4c
   |      semi-colon: 1:471f378eab4c
   |      Successors: 4:019fadeab383
   |      semi-colon: 4:019fadeab383
   |      Fate: reworded using amend as 4:019fadeab383
+  |      Origin: reworded using amend from 1:471f378eab4c
   |
   | @  fdf9bde5129a
   |/     Predecessors: 1:471f378eab4c
   |      semi-colon: 1:471f378eab4c
+  |      Origin: reworded using amend from 1:471f378eab4c
+  |
   | x  471f378eab4c
   |/     Successors: 2:fdf9bde5129a; 3:65b757b745b9
   |      semi-colon: 2:fdf9bde5129a; 3:65b757b745b9
@@ -720,14 +771,17 @@
   |
   o  ea207398892e
   
-  $ hg fatelog --hidden
+  $ hg fateoriginlog --hidden
   *  019fadeab383
+  |    Obsorigin: reworded using amend from 3:65b757b745b9
   |
   | x  65b757b745b9
   |/     Obsfate: reworded using amend as 4:019fadeab383
+  |      Obsorigin: reworded using amend from 1:471f378eab4c
   |
   | @  fdf9bde5129a
-  |/
+  |/     Obsorigin: reworded using amend from 1:471f378eab4c
+  |
   | x  471f378eab4c
   |/     Obsfate: reworded using amend as 2:fdf9bde5129a; reworded using amend as 3:65b757b745b9
   |
@@ -818,6 +872,8 @@
   o  eb5a0daa2192
   |    Predecessors: 1:471f378eab4c
   |    semi-colon: 1:471f378eab4c
+  |    Origin: folded using fold from 1:471f378eab4c
+  |
   | @  471f378eab4c
   |/     Successors: 4:eb5a0daa2192
   |      semi-colon: 4:eb5a0daa2192
@@ -825,8 +881,9 @@
   |
   o  ea207398892e
   
-  $ hg fatelog
+  $ hg fateoriginlog
   o  eb5a0daa2192
+  |    Obsorigin: folded using fold from 1:471f378eab4c
   |
   | @  471f378eab4c
   |/     Obsfate: folded using fold as 4:eb5a0daa2192
@@ -843,6 +900,8 @@
   o  eb5a0daa2192
   |    Predecessors: 2:0dec01379d3b 1:471f378eab4c
   |    semi-colon: 2:0dec01379d3b; 1:471f378eab4c
+  |    Origin: folded using amend, fold from 1:471f378eab4c, 2:0dec01379d3b
+  |
   | @  0dec01379d3b
   | |    Successors: 4:eb5a0daa2192
   | |    semi-colon: 4:eb5a0daa2192
@@ -855,8 +914,9 @@
   |
   o  ea207398892e
   
-  $ hg fatelog
+  $ hg fateoriginlog
   o  eb5a0daa2192
+  |    Obsorigin: folded using amend, fold from 1:471f378eab4c, 2:0dec01379d3b
   |
   | @  0dec01379d3b
   | |    Obsfate: rewritten using amend, fold as 4:eb5a0daa2192
@@ -877,6 +937,8 @@
   o  eb5a0daa2192
   |    Predecessors: 1:471f378eab4c 3:b7ea6d14e664
   |    semi-colon: 1:471f378eab4c; 3:b7ea6d14e664
+  |    Origin: folded using fold from 1:471f378eab4c, 3:b7ea6d14e664
+  |
   | @  b7ea6d14e664
   | |    Successors: 4:eb5a0daa2192
   | |    semi-colon: 4:eb5a0daa2192
@@ -889,8 +951,9 @@
   |
   o  ea207398892e
   
-  $ hg fatelog
+  $ hg fateoriginlog
   o  eb5a0daa2192
+  |    Obsorigin: folded using fold from 1:471f378eab4c, 3:b7ea6d14e664
   |
   | @  b7ea6d14e664
   | |    Obsfate: folded using fold as 4:eb5a0daa2192
@@ -912,12 +975,15 @@
   @  eb5a0daa2192
   |    Predecessors: 1:471f378eab4c 3:b7ea6d14e664
   |    semi-colon: 1:471f378eab4c; 3:b7ea6d14e664
+  |    Origin: folded using fold from 1:471f378eab4c, 3:b7ea6d14e664
+  |
   | x  b7ea6d14e664
   | |    Predecessors: 2:0dec01379d3b
   | |    semi-colon: 2:0dec01379d3b
   | |    Successors: 4:eb5a0daa2192
   | |    semi-colon: 4:eb5a0daa2192
   | |    Fate: folded using fold as 4:eb5a0daa2192
+  | |    Origin: reworded using amend from 2:0dec01379d3b
   | |
   | | x  0dec01379d3b
   | |/     Successors: 3:b7ea6d14e664
@@ -931,11 +997,13 @@
   |
   o  ea207398892e
   
-  $ hg fatelog --hidden
+  $ hg fateoriginlog --hidden
   @  eb5a0daa2192
+  |    Obsorigin: folded using fold from 1:471f378eab4c, 3:b7ea6d14e664
   |
   | x  b7ea6d14e664
   | |    Obsfate: folded using fold as 4:eb5a0daa2192
+  | |    Obsorigin: reworded using amend from 2:0dec01379d3b
   | |
   | | x  0dec01379d3b
   | |/     Obsfate: reworded using amend as 3:b7ea6d14e664
@@ -1041,6 +1109,8 @@
   o  7a230b46bf61
   |    Predecessors: 1:471f378eab4c
   |    semi-colon: 1:471f378eab4c
+  |    Origin: reworded using amend from 1:471f378eab4c
+  |
   | @  471f378eab4c
   |/     Successors: 2:7a230b46bf61
   |      semi-colon: 2:7a230b46bf61
@@ -1048,8 +1118,9 @@
   |
   o  ea207398892e
   
-  $ hg fatelog --hidden -v
+  $ hg fateoriginlog --hidden -v
   o  7a230b46bf61
+  |    Obsorigin: reworded using amend from 1:471f378eab4c by test (at 1970-01-01 00:00 +0000)
   |
   | @  471f378eab4c
   |/     Obsfate: reworded using amend as 2:7a230b46bf61 by test (at 1970-01-01 00:00 +0000)
@@ -1063,7 +1134,7 @@
   |
   o  ea207398892e
   
-  $ hg fatelog -v
+  $ hg fateoriginlog -v
   @  7a230b46bf61
   |
   o  ea207398892e
@@ -1072,6 +1143,8 @@
   @  7a230b46bf61
   |    Predecessors: 1:471f378eab4c
   |    semi-colon: 1:471f378eab4c
+  |    Origin: reworded using amend from 1:471f378eab4c
+  |
   | x  471f378eab4c
   |/     Successors: 2:7a230b46bf61
   |      semi-colon: 2:7a230b46bf61
@@ -1079,8 +1152,9 @@
   |
   o  ea207398892e
   
-  $ hg fatelog --hidden -v
+  $ hg fateoriginlog --hidden -v
   @  7a230b46bf61
+  |    Obsorigin: reworded using amend from 1:471f378eab4c by test (at 1970-01-01 00:00 +0000)
   |
   | x  471f378eab4c
   |/     Obsfate: reworded using amend as 2:7a230b46bf61 by test (at 1970-01-01 00:00 +0000)
@@ -1124,7 +1198,7 @@
   |
   o  ea207398892e
   
-  $ hg fatelog
+  $ hg fateoriginlog
   @  f897c6137566
   |
   o  ea207398892e
@@ -1139,6 +1213,8 @@
   o  f897c6137566
   |    Predecessors: 2:0dec01379d3b
   |    semi-colon: 2:0dec01379d3b
+  |    Origin: rewritten from 2:0dec01379d3b
+  |
   | @  0dec01379d3b
   | |    Predecessors: 1:471f378eab4c
   | |    semi-colon: 1:471f378eab4c
@@ -1146,6 +1222,7 @@
   | |    semi-colon: 3:f897c6137566; 1:471f378eab4c
   | |    Fate: rewritten as 3:f897c6137566
   | |    Fate: rewritten as 1:471f378eab4c
+  | |    Origin: rewritten from 1:471f378eab4c
   | |
   | x  471f378eab4c
   |/     Predecessors: 2:0dec01379d3b
@@ -1153,17 +1230,21 @@
   |      Successors: 2:0dec01379d3b
   |      semi-colon: 2:0dec01379d3b
   |      Fate: rewritten as 2:0dec01379d3b
+  |      Origin: rewritten from 2:0dec01379d3b
   |
   o  ea207398892e
   
-  $ hg fatelog
+  $ hg fateoriginlog
   o  f897c6137566
+  |    Obsorigin: rewritten from 2:0dec01379d3b
   |
   | @  0dec01379d3b
   | |    Obsfate: rewritten as 3:f897c6137566; rewritten as 1:471f378eab4c
+  | |    Obsorigin: rewritten from 1:471f378eab4c
   | |
   | x  471f378eab4c
   |/     Obsfate: rewritten as 2:0dec01379d3b
+  |      Obsorigin: rewritten from 2:0dec01379d3b
   |
   o  ea207398892e
   
@@ -1175,13 +1256,16 @@
   o  f897c6137566
   |    Predecessors: 1:471f378eab4c
   |    semi-colon: 1:471f378eab4c
+  |    Origin: rewritten from 1:471f378eab4c
+  |
   | @  471f378eab4c
   |/     Fate: pruned
   |
   o  ea207398892e
   
-  $ hg fatelog
+  $ hg fateoriginlog
   o  f897c6137566
+  |    Obsorigin: rewritten from 1:471f378eab4c
   |
   | @  471f378eab4c
   |/     Obsfate: pruned
@@ -1196,7 +1280,7 @@
   |
   @  ea207398892e
   
-  $ hg fatelog
+  $ hg fateoriginlog
   o  f897c6137566
   |
   @  ea207398892e
@@ -1205,6 +1289,8 @@
   o  f897c6137566
   |    Predecessors: 2:0dec01379d3b
   |    semi-colon: 2:0dec01379d3b
+  |    Origin: rewritten from 2:0dec01379d3b
+  |
   | x  0dec01379d3b
   | |    Predecessors: 1:471f378eab4c
   | |    semi-colon: 1:471f378eab4c
@@ -1212,6 +1298,7 @@
   | |    semi-colon: 3:f897c6137566; 1:471f378eab4c
   | |    Fate: rewritten as 3:f897c6137566
   | |    Fate: rewritten as 1:471f378eab4c
+  | |    Origin: rewritten from 1:471f378eab4c
   | |
   | x  471f378eab4c
   |/     Predecessors: 2:0dec01379d3b
@@ -1219,6 +1306,7 @@
   |      Successors: 2:0dec01379d3b
   |      semi-colon: 2:0dec01379d3b
   |      Fate: rewritten as 2:0dec01379d3b
+  |      Origin: rewritten from 2:0dec01379d3b
   |
   @  ea207398892e
   
@@ -1392,9 +1480,13 @@
   @  0b997eb7ceee
   |    Predecessors: 6:4a004186e638
   |    semi-colon: 6:4a004186e638
+  |    Origin: reworded using amend from 6:4a004186e638
+  |
   | *  b18bc8331526
   |/     Predecessors: 6:4a004186e638
   |      semi-colon: 6:4a004186e638
+  |      Origin: reworded using amend from 6:4a004186e638
+  |
   | *  ba2ed02b0c9a
   | |
   | x  4a004186e638
@@ -1409,11 +1501,13 @@
   |
   o  ea207398892e
   
-  $ hg fatelog
+  $ hg fateoriginlog
   @  0b997eb7ceee
+  |    Obsorigin: reworded using amend from 6:4a004186e638
   |
   | *  b18bc8331526
-  |/
+  |/     Obsorigin: reworded using amend from 6:4a004186e638
+  |
   | *  ba2ed02b0c9a
   | |
   | x  4a004186e638
@@ -1429,12 +1523,18 @@
   @  0b997eb7ceee
   |    Predecessors: 6:4a004186e638
   |    semi-colon: 6:4a004186e638
+  |    Origin: reworded using amend from 6:4a004186e638
+  |
   | *  b18bc8331526
   |/     Predecessors: 6:4a004186e638
   |      semi-colon: 6:4a004186e638
+  |      Origin: reworded using amend from 6:4a004186e638
+  |
   | *  ba2ed02b0c9a
   | |    Predecessors: 4:9bd10a0775e4
   | |    semi-colon: 4:9bd10a0775e4
+  | |    Origin: split from 4:9bd10a0775e4
+  | |
   | x  4a004186e638
   |/     Predecessors: 4:9bd10a0775e4
   |      semi-colon: 4:9bd10a0775e4
@@ -1442,10 +1542,13 @@
   |      semi-colon: 8:b18bc8331526; 9:0b997eb7ceee
   |      Fate: reworded using amend as 8:b18bc8331526
   |      Fate: reworded using amend as 9:0b997eb7ceee
+  |      Origin: split from 4:9bd10a0775e4
   |
   *  dd800401bd8c
   |    Predecessors: 4:9bd10a0775e4
   |    semi-colon: 4:9bd10a0775e4
+  |    Origin: split from 4:9bd10a0775e4
+  |
   | x  9bd10a0775e4
   |/     Successors: 5:dd800401bd8c 6:4a004186e638 7:ba2ed02b0c9a
   |      semi-colon: 5:dd800401bd8c 6:4a004186e638 7:ba2ed02b0c9a
@@ -1454,6 +1557,8 @@
   o  f897c6137566
   |    Predecessors: 2:0dec01379d3b
   |    semi-colon: 2:0dec01379d3b
+  |    Origin: rewritten from 2:0dec01379d3b
+  |
   | x  0dec01379d3b
   | |    Predecessors: 1:471f378eab4c
   | |    semi-colon: 1:471f378eab4c
@@ -1461,6 +1566,7 @@
   | |    semi-colon: 3:f897c6137566; 1:471f378eab4c
   | |    Fate: rewritten as 3:f897c6137566
   | |    Fate: rewritten as 1:471f378eab4c
+  | |    Origin: rewritten from 1:471f378eab4c
   | |
   | x  471f378eab4c
   |/     Predecessors: 2:0dec01379d3b
@@ -1468,31 +1574,40 @@
   |      Successors: 2:0dec01379d3b
   |      semi-colon: 2:0dec01379d3b
   |      Fate: rewritten as 2:0dec01379d3b
+  |      Origin: rewritten from 2:0dec01379d3b
   |
   o  ea207398892e
   
-  $ hg fatelog --hidden
+  $ hg fateoriginlog --hidden
   @  0b997eb7ceee
+  |    Obsorigin: reworded using amend from 6:4a004186e638
   |
   | *  b18bc8331526
-  |/
+  |/     Obsorigin: reworded using amend from 6:4a004186e638
+  |
   | *  ba2ed02b0c9a
+  | |    Obsorigin: split from 4:9bd10a0775e4
   | |
   | x  4a004186e638
   |/     Obsfate: reworded using amend as 8:b18bc8331526; reworded using amend as 9:0b997eb7ceee
+  |      Obsorigin: split from 4:9bd10a0775e4
   |
   *  dd800401bd8c
+  |    Obsorigin: split from 4:9bd10a0775e4
   |
   | x  9bd10a0775e4
   |/     Obsfate: split as 5:dd800401bd8c, 6:4a004186e638, 7:ba2ed02b0c9a
   |
   o  f897c6137566
+  |    Obsorigin: rewritten from 2:0dec01379d3b
   |
   | x  0dec01379d3b
   | |    Obsfate: rewritten as 3:f897c6137566; rewritten as 1:471f378eab4c
+  | |    Obsorigin: rewritten from 1:471f378eab4c
   | |
   | x  471f378eab4c
   |/     Obsfate: rewritten as 2:0dec01379d3b
+  |      Obsorigin: rewritten from 2:0dec01379d3b
   |
   o  ea207398892e
   
@@ -1508,15 +1623,23 @@
   *  eceed8f98ffc
   |    Predecessors: 4:9bd10a0775e4
   |    semi-colon: 4:9bd10a0775e4
+  |    Origin: rewritten using rebase from 4:9bd10a0775e4
+  |
   | *  0b997eb7ceee
   | |    Predecessors: 4:9bd10a0775e4
   | |    semi-colon: 4:9bd10a0775e4
+  | |    Origin: rewritten using amend from 4:9bd10a0775e4
+  | |
   * |  b18bc8331526
   |/     Predecessors: 4:9bd10a0775e4
   |      semi-colon: 4:9bd10a0775e4
+  |      Origin: rewritten using amend from 4:9bd10a0775e4
+  |
   *  dd800401bd8c
   |    Predecessors: 4:9bd10a0775e4
   |    semi-colon: 4:9bd10a0775e4
+  |    Origin: split from 4:9bd10a0775e4
+  |
   | @  9bd10a0775e4
   |/     Successors: 5:dd800401bd8c 9:0b997eb7ceee 10:eceed8f98ffc; 5:dd800401bd8c 8:b18bc8331526 10:eceed8f98ffc
   |      semi-colon: 5:dd800401bd8c 9:0b997eb7ceee 10:eceed8f98ffc; 5:dd800401bd8c 8:b18bc8331526 10:eceed8f98ffc
@@ -1527,14 +1650,18 @@
   |
   o  ea207398892e
   
-  $ hg fatelog
+  $ hg fateoriginlog
   *  eceed8f98ffc
+  |    Obsorigin: rewritten using rebase from 4:9bd10a0775e4
   |
   | *  0b997eb7ceee
+  | |    Obsorigin: rewritten using amend from 4:9bd10a0775e4
   | |
   * |  b18bc8331526
-  |/
+  |/     Obsorigin: rewritten using amend from 4:9bd10a0775e4
+  |
   *  dd800401bd8c
+  |    Obsorigin: split from 4:9bd10a0775e4
   |
   | @  9bd10a0775e4
   |/     Obsfate: split using amend, rebase as 5:dd800401bd8c, 9:0b997eb7ceee, 10:eceed8f98ffc; split using amend, rebase as 5:dd800401bd8c, 8:b18bc8331526, 10:eceed8f98ffc
@@ -1573,9 +1700,65 @@
   |
   o  ea207398892e
   
-  $ hg fatelog -v
+  $ hg fateoriginlog -v
   @  471f378eab4c
   |    Obsfate: pruned using prune by test (at 1970-01-01 00:00 +0000)
   |
   o  ea207398892e
   
+
+Test templates when having multiple unrelated predecessors
+==========================================================
+
+  $ hg init $TESTTMP/templates-local-multipreds
+  $ cd $TESTTMP/templates-local-multipreds
+  $ mkcommit R
+  $ mkcommit A
+  $ mkcommit B
+  $ hg up 'desc(R)'
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  $ mkcommit C
+  created new head
+  $ hg up 'desc(R)'
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ mkcommit Z
+  created new head
+  $ hg up 'desc(R)'
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg prune -r 'desc(A) + desc(B)' -s 'desc(Z)' --fold
+  2 changesets pruned
+  $ hg prune -r 'desc(C)' -s 'desc(Z)'
+  1 changesets pruned
+  $ hg debugobsolete
+  944ade52b6a1afe01817e7cae4c3006f1f128279 4568aafd15c0ac96a9828ce8418556bb1e76d6d7 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'fold-id': 'c59cbeaa', 'fold-idx': '1', 'fold-size': '2', 'operation': 'prune', 'user': 'test'}
+  36ca49338d3a303e90126c28b1713092aaf3e9ed 4568aafd15c0ac96a9828ce8418556bb1e76d6d7 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'fold-id': 'c59cbeaa', 'fold-idx': '2', 'fold-size': '2', 'operation': 'prune', 'user': 'test'}
+  5b3370228fe5fa9824b8df21cd54876ef23ac745 4568aafd15c0ac96a9828ce8418556bb1e76d6d7 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'prune', 'user': 'test'}
+  $ hg tlog
+  o  4568aafd15c0
+  |
+  @  7ca5bfdbe243
+  
+  $ hg tlog --hidden
+  o  4568aafd15c0
+  |    Predecessors: 2:36ca49338d3a 3:5b3370228fe5 1:944ade52b6a1
+  |    semi-colon: 2:36ca49338d3a; 3:5b3370228fe5; 1:944ade52b6a1
+  |    Origin: folded using prune from 1:944ade52b6a1, 2:36ca49338d3a
+  |    Origin: rewritten using prune from 3:5b3370228fe5
+  |
+  | x  5b3370228fe5
+  |/     Successors: 4:4568aafd15c0
+  |      semi-colon: 4:4568aafd15c0
+  |      Fate: rewritten using prune as 4:4568aafd15c0
+  |
+  | x  36ca49338d3a
+  | |    Successors: 4:4568aafd15c0
+  | |    semi-colon: 4:4568aafd15c0
+  | |    Fate: folded using prune as 4:4568aafd15c0
+  | |
+  | x  944ade52b6a1
+  |/     Successors: 4:4568aafd15c0
+  |      semi-colon: 4:4568aafd15c0
+  |      Fate: folded using prune as 4:4568aafd15c0
+  |
+  @  7ca5bfdbe243
+