obsfate: override the default log output
Override the default log output by showing obsfate if not empty.
--- a/hgext3rd/evolve/templatekw.py Thu Jun 29 23:42:29 2017 +0200
+++ b/hgext3rd/evolve/templatekw.py Mon Jun 26 17:20:08 2017 +0200
@@ -15,8 +15,10 @@
)
from mercurial import (
+ cmdutil,
templatekw,
node,
+ util
)
eh = exthelper.exthelper()
@@ -178,6 +180,60 @@
return values
+def obsfatelineprinter(obsfateline, ui):
+ quiet = ui.quiet
+ verbose = ui.verbose
+ normal = not verbose and not quiet
+
+ # Build the line step by step
+ line = []
+
+ # Verb
+ line.append(obsfateline['verb'])
+
+ # Users
+ if verbose or normal:
+ users = obsfateline['users']
+
+ if normal:
+ username = _getusername(ui)
+ users = [user for user in users if user != username]
+
+ if users:
+ line.append(" by %s" % ",".join(users))
+
+ # Successors
+ successors = obsfateline["successors"]
+
+ if successors:
+ fmtsuccessors = map(lambda s: s[:12], successors)
+ line.append(" as %s" % ", ".join(fmtsuccessors))
+
+ # Date
+ if verbose:
+ min_date = obsfateline['min_date']
+ max_date = obsfateline['max_date']
+
+ if min_date == max_date:
+ fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2')
+ line.append(" (at %s)" % fmtmin_date)
+ else:
+ fmtmin_date = util.datestr(min_date, '%Y-%m-%d %H:%M %1%2')
+ fmtmax_date = util.datestr(max_date, '%Y-%m-%d %H:%M %1%2')
+ line.append(" (between %s and %s)" % (fmtmin_date, fmtmax_date))
+
+ return "".join(line)
+
+def obsfateprinter(obsfate, ui, prefix=""):
+ lines = []
+ for raw in obsfate:
+ lines.append(obsfatelineprinter(raw, ui))
+
+ if prefix:
+ lines = [prefix + line for line in lines]
+
+ return "\n".join(lines)
+
@eh.templatekw("obsfate")
def showobsfate(repo, ctx, **args):
# Get the needed obsfate data
@@ -235,6 +291,22 @@
return templatekw._hybrid(gen, values, lambda x: {name: x}, fmt)
+# Check if we can hook directly on the changeset_printer
+if util.safehasattr(cmdutil.changeset_printer, '_exthook'):
+ @eh.wrapfunction(cmdutil.changeset_printer, '_exthook')
+ def exthook(original, self, ctx):
+ # Call potential other extensions
+ original(self, ctx)
+
+ obsfate = obsfatedata(self.repo, ctx)
+ if obsfate is None:
+ return ""
+
+ output = obsfateprinter(obsfate, self.ui, prefix="obsolete: ")
+
+ self.ui.write(output, label='log.obsfate')
+ self.ui.write("\n")
+
# copy from mercurial.obsolete with a small change to stop at first known changeset.
def directsuccessorssets(repo, initialnode, cache=None):
--- a/tests/test-drop.t Thu Jun 29 23:42:29 2017 +0200
+++ b/tests/test-drop.t Mon Jun 26 17:20:08 2017 +0200
@@ -207,11 +207,13 @@
| x changeset: 3:87ea30a976fd
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: pruned
| | summary: temporary amend commit for 34b6c051bf1f
| |
| x changeset: 2:34b6c051bf1f
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as a2c06c884bfe
| summary: add child
|
o changeset: 1:19509a42b0d0
--- a/tests/test-evolve-cycles.t Thu Jun 29 23:42:29 2017 +0200
+++ b/tests/test-evolve-cycles.t Mon Jun 26 17:20:08 2017 +0200
@@ -62,16 +62,19 @@
| tag: tip
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as 2a34000d3544
| summary: C
|
x changeset: 2:c473644ee0e9
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as a8df460dbbfe
| summary: B
|
@ changeset: 1:2a34000d3544
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as c473644ee0e9
| summary: A
|
o changeset: 0:ea207398892e
@@ -204,31 +207,37 @@
| tag: tip
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as 868d2e0eb19c
| summary: F
|
x changeset: 5:0da815c333f6
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as d9f908fde1a1
| summary: E
|
@ changeset: 4:868d2e0eb19c
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as 0da815c333f6
| summary: D
|
x changeset: 3:a8df460dbbfe
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: split as 2a34000d3544, 868d2e0eb19c
| summary: C
|
x changeset: 2:c473644ee0e9
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as a8df460dbbfe
| summary: B
|
x changeset: 1:2a34000d3544
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as c473644ee0e9
| summary: A
|
o changeset: 0:ea207398892e
--- a/tests/test-evolve-obshistory-complex.t Thu Jun 29 23:42:29 2017 +0200
+++ b/tests/test-evolve-obshistory-complex.t Mon Jun 26 17:20:08 2017 +0200
@@ -99,21 +99,25 @@
x | | changeset: 4:868d2e0eb19c
| | | user: test
| | | date: Thu Jan 01 00:00:00 1970 +0000
+ | | | obsolete: rewritten as d15d0ffc75f6
| | | summary: D
| | |
x | | changeset: 3:a8df460dbbfe
|/ / user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: rewritten as d15d0ffc75f6
| | summary: C
| |
x | changeset: 2:c473644ee0e9
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: rewritten as b868bc49b0a4
| | summary: B
| |
x | changeset: 1:2a34000d3544
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as b868bc49b0a4
| summary: A
|
o changeset: 0:ea207398892e
@@ -269,21 +273,25 @@
x | | changeset: 4:868d2e0eb19c
| | | user: test
| | | date: Thu Jan 01 00:00:00 1970 +0000
+ | | | obsolete: split as 7b3290f6e0a0, d0f33db50670
| | | summary: D
| | |
x | | changeset: 3:a8df460dbbfe
|/ / user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: split as 7b3290f6e0a0, d0f33db50670
| | summary: C
| |
x | changeset: 2:c473644ee0e9
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: split as 19e14c8397fc, e036916b63ea
| | summary: B
| |
x | changeset: 1:2a34000d3544
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: split as 19e14c8397fc, e036916b63ea
| summary: A
|
o changeset: 0:ea207398892e
@@ -330,21 +338,25 @@
x | | changeset: 4:868d2e0eb19c
| | | user: test
| | | date: Thu Jan 01 00:00:00 1970 +0000
+ | | | obsolete: split as 7b3290f6e0a0, ec31316faa9d
| | | summary: D
| | |
x | | changeset: 3:a8df460dbbfe
|/ / user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: split as 7b3290f6e0a0, ec31316faa9d
| | summary: C
| |
x | changeset: 2:c473644ee0e9
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: split as 19e14c8397fc, 7b3290f6e0a0
| | summary: B
| |
x | changeset: 1:2a34000d3544
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: split as 19e14c8397fc, 7b3290f6e0a0
| summary: A
|
o changeset: 0:ea207398892e
--- a/tests/test-evolve-obshistory.t Thu Jun 29 23:42:29 2017 +0200
+++ b/tests/test-evolve-obshistory.t Mon Jun 26 17:20:08 2017 +0200
@@ -41,11 +41,13 @@
| x changeset: 2:f137d23bb3e1
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: pruned
| | summary: temporary amend commit for 471f378eab4c
| |
| x changeset: 1:471f378eab4c
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as 4ae3a4151de9
| summary: A0
|
o changeset: 0:ea207398892e
@@ -197,6 +199,7 @@
| tag: tip
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: pruned
| summary: B0
|
@ changeset: 1:471f378eab4c
@@ -336,6 +339,7 @@
| x changeset: 1:471597cad322
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: split as 337fec4d2edc, f257fde29c7a
| summary: A0
|
o changeset: 0:ea207398892e
@@ -589,6 +593,7 @@
| x changeset: 1:de7290d8b885
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: split as 1ae8bc733a14, 337fec4d2edc, c7f044602e9b, f257fde29c7a
| summary: A0
|
o changeset: 0:ea207398892e
@@ -764,11 +769,13 @@
| x changeset: 2:0dec01379d3b
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: rewritten as eb5a0daa2192
| | summary: B0
| |
| x changeset: 1:471f378eab4c
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as eb5a0daa2192
| summary: A0
|
o changeset: 0:ea207398892e
@@ -969,6 +976,7 @@
| x changeset: 1:471f378eab4c
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as fdf9bde5129a
| summary: A0
|
o changeset: 0:ea207398892e
@@ -1001,6 +1009,8 @@
| x changeset: 1:471f378eab4c
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as fdf9bde5129a
+ | obsolete: rewritten as 65b757b745b9
| summary: A0
|
o changeset: 0:ea207398892e
@@ -1282,6 +1292,7 @@
| x changeset: 2:0dec01379d3b
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as b7ea6d14e664
| summary: B0
|
o changeset: 1:471f378eab4c
@@ -1309,16 +1320,19 @@
| | parent: 1:471f378eab4c
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: rewritten as eb5a0daa2192
| | summary: B1
| |
| | x changeset: 2:0dec01379d3b
| |/ user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: rewritten as b7ea6d14e664
| | summary: B0
| |
| x changeset: 1:471f378eab4c
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as eb5a0daa2192
| summary: A0
|
o changeset: 0:ea207398892e
@@ -1542,11 +1556,13 @@
|/ parent: 0:ea207398892e
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as 7a230b46bf61
| summary: A1
|
| x changeset: 1:471f378eab4c
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as fdf9bde5129a
| summary: A0
|
o changeset: 0:ea207398892e
--- a/tests/test-evolve-templates.t Thu Jun 29 23:42:29 2017 +0200
+++ b/tests/test-evolve-templates.t Mon Jun 26 17:20:08 2017 +0200
@@ -47,16 +47,19 @@
|/ parent: 0:ea207398892e
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten by test2 as d004c8f274b9
| summary: A1
|
| x changeset: 2:f137d23bb3e1
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: pruned by test1
| | summary: temporary amend commit for 471f378eab4c
| |
| x changeset: 1:471f378eab4c
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten by test1 as a468dc9b3633
| summary: A0
|
o changeset: 0:ea207398892e
@@ -319,6 +322,7 @@
| x changeset: 1:471597cad322
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: split as 337fec4d2edc, f257fde29c7a
| summary: A0
|
o changeset: 0:ea207398892e
@@ -452,11 +456,13 @@
| x changeset: 2:0dec01379d3b
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: rewritten as eb5a0daa2192
| | summary: B0
| |
| x changeset: 1:471f378eab4c
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as eb5a0daa2192
| summary: A0
|
o changeset: 0:ea207398892e
@@ -599,6 +605,7 @@
| x changeset: 1:471f378eab4c
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as fdf9bde5129a
| summary: A0
|
o changeset: 0:ea207398892e
@@ -631,6 +638,8 @@
| x changeset: 1:471f378eab4c
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as fdf9bde5129a
+ | obsolete: rewritten as 65b757b745b9
| summary: A0
|
o changeset: 0:ea207398892e
@@ -766,6 +775,7 @@
| x changeset: 2:0dec01379d3b
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as b7ea6d14e664
| summary: B0
|
o changeset: 1:471f378eab4c
@@ -793,16 +803,19 @@
| | parent: 1:471f378eab4c
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: rewritten as eb5a0daa2192
| | summary: B1
| |
| | x changeset: 2:0dec01379d3b
| |/ user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: rewritten as b7ea6d14e664
| | summary: B0
| |
| x changeset: 1:471f378eab4c
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as eb5a0daa2192
| summary: A0
|
o changeset: 0:ea207398892e
@@ -997,11 +1010,13 @@
|/ parent: 0:ea207398892e
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as 7a230b46bf61
| summary: A1
|
| x changeset: 1:471f378eab4c
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as fdf9bde5129a
| summary: A0
|
o changeset: 0:ea207398892e
@@ -1032,6 +1047,7 @@
| @ changeset: 1:471f378eab4c
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as 7a230b46bf61
| summary: A0
|
o changeset: 0:ea207398892e
--- a/tests/test-obsolete.t Thu Jun 29 23:42:29 2017 +0200
+++ b/tests/test-obsolete.t Mon Jun 26 17:20:08 2017 +0200
@@ -126,6 +126,7 @@
parent: 1:7c3bad9141dc
user: test
date: Thu Jan 01 00:00:00 1970 +0000
+ obsolete: rewritten as 725c380fe99b
summary: add obsol_c
working directory parent is obsolete! (0d3f46688ccc)
@@ -740,12 +741,14 @@
| | | x changeset: 14:33d458d86621
| | | | user: test
| | | | date: Thu Jan 01 00:00:00 1970 +0000
+ | | | | obsolete: pruned
| | | | summary: temporary amend commit for 0b1b6dd009c0
| | | |
| | | x changeset: 13:0b1b6dd009c0
| | |/ parent: 10:2033b4e49474
| | | user: test
| | | date: Thu Jan 01 00:00:00 1970 +0000
+ | | | obsolete: rewritten as 705ab2a6b72e
| | | summary: add f
| | |
| | | o changeset: 12:6db5e282cb91
@@ -770,30 +773,36 @@
| | parent: -1:000000000000
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: pruned
| | summary: add toto
| |
| | x changeset: 8:159dfc9fa5d3
| | | parent: 3:0d3f46688ccc
| | | user: test
| | | date: Thu Jan 01 00:00:00 1970 +0000
+ | | | obsolete: rewritten as 9468a5f5d8b2
| | | summary: add obsol_d''
| | |
| | | x changeset: 7:909a0fb57e5d
| | |/ parent: 3:0d3f46688ccc
| | | user: test
| | | date: Thu Jan 01 00:00:00 1970 +0000
+ | | | obsolete: rewritten as 159dfc9fa5d3
| | | summary: add obsol_d'
| | |
| | | x changeset: 6:95de7fc6918d
| | |/ parent: 3:0d3f46688ccc
| | | user: test
| | | date: Thu Jan 01 00:00:00 1970 +0000
+ | | | obsolete: rewritten as 909a0fb57e5d
| | | summary: add obsol_d
| | |
| | | x changeset: 5:a7a6f2b5d8a5
| | |/ parent: 3:0d3f46688ccc
| | | user: test
| | | date: Thu Jan 01 00:00:00 1970 +0000
+ | | | obsolete: rewritten as 95de7fc6918d
+ | | | obsolete: rewritten as 50f11e5e3a63
| | | summary: add d
| | |
| o | changeset: 4:725c380fe99b
@@ -806,11 +815,14 @@
| |/ parent: 1:7c3bad9141dc
| | user: test
| | date: Thu Jan 01 00:00:00 1970 +0000
+ | | obsolete: rewritten as 725c380fe99b
+ | | obsolete: rewritten as 2033b4e49474
| | summary: add obsol_c
| |
x | changeset: 2:4538525df7e2
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as 0d3f46688ccc
| summary: add c
|
o changeset: 1:7c3bad9141dc
--- a/tests/test-stabilize-conflict.t Thu Jun 29 23:42:29 2017 +0200
+++ b/tests/test-stabilize-conflict.t Mon Jun 26 17:20:08 2017 +0200
@@ -152,6 +152,7 @@
|/ parent: 0:29ec1554cfaf
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as e04690b09bc6
| summary: babar count up to ten
|
o changeset: 0:29ec1554cfaf
@@ -243,6 +244,7 @@
|/ parent: 0:29ec1554cfaf
| user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as b20d08eea373
| summary: babar count up to ten
|
o changeset: 0:29ec1554cfaf
--- a/tests/test-stabilize-order.t Thu Jun 29 23:42:29 2017 +0200
+++ b/tests/test-stabilize-order.t Mon Jun 26 17:20:08 2017 +0200
@@ -221,6 +221,7 @@
| x changeset: 12:2256dae6521f
|/ user: test
| date: Thu Jan 01 00:00:00 1970 +0000
+ | obsolete: rewritten as f83a0bce03e4
| summary: addc
|
o changeset: 11:7a68bc4596ea