Mercurial > hg
changeset 34852:d45236f3d38e
log: add obsfate by default in changeset printer
Having an obsfate by default in log will be useful for users to understand why
they have obsolete and unstable changesets. Obsfate will only be shown for
obsolete changesets, which only happens if people opt-in to experimental feature.
But when obsolete changeset are visible, it is very useful to understand where
they are. Having it in log could be sufficient for most people, so they don't
have to learn a new command (like obslog which is itself useful in case of
divergences).
For example, when pulling and working directory parent become obsolete:
$ hg pull
...
working directory parent is obsolete! (f936c1697205)
This message comes from the Evolve extension.
Obsfate would comes handy:
$ hg log -G
o changeset: 2:6f91013c5136
| tag: tip
| parent: 0:4ef7b558f3ec
| user: Boris Feld <boris.feld@octobus.net>
| date: Mon Oct 09 16:00:27 2017 +0200
| summary: A
|
| @ changeset: 1:f936c1697205
|/ user: Boris Feld <boris.feld@octobus.net>
| date: Mon Oct 09 16:00:27 2017 +0200
| obsfate: rewritten using amend as 2:6f91013c5136
| summary: -A
|
o changeset: 0:feb4dd822b8c
user: Boris Feld <boris.feld@octobus.net>
date: Tue Oct 09 16:00:00 2017 +0200
summary: ROOT
And once we update, we don't have an obsolete changeset in the log anymore so
we don't show obsfate anymore, most users won't see obsfate often if they
don't have obsolete changeset often:
@ changeset: 2:6f91013c5136
| tag: tip
| parent: 0:4ef7b558f3ec
| user: Boris Feld <boris.feld@octobus.net>
| date: Mon Oct 09 16:00:27 2017 +0200
| summary: A
|
o changeset: 0:feb4dd822b8c
user: Boris Feld <boris.feld@octobus.net>
date: Tue Oct 09 16:00:00 2017 +0200
summary: ROOT
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Thu, 05 Oct 2017 15:25:18 +0200 |
parents | 6f53a53245a2 |
children | 962f7df21a73 |
files | mercurial/cmdutil.py tests/test-commandserver.t tests/test-obsmarker-template.t tests/test-obsolete.t |
diffstat | 4 files changed, 56 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Mon Oct 09 15:34:26 2017 +0200 +++ b/mercurial/cmdutil.py Thu Oct 05 15:25:18 2017 +0200 @@ -1665,6 +1665,9 @@ self.ui.write(_("instability: %s\n") % ', '.join(instabilities), label='log.instability') + elif ctx.obsolete(): + self._showobsfate(ctx) + self._exthook(ctx) if self.ui.debugflag: @@ -1713,6 +1716,15 @@ self.showpatch(ctx, matchfn) + def _showobsfate(self, ctx): + obsfate = templatekw.showobsfate(repo=self.repo, ctx=ctx, ui=self.ui) + + if obsfate: + for obsfateline in obsfate: + # i18n: column positioning for "hg log" + self.ui.write(_("obsfate: %s\n") % obsfateline, + label='log.obsfate') + def _exthook(self, ctx): '''empty method used by extension as a hook point '''
--- a/tests/test-commandserver.t Mon Oct 09 15:34:26 2017 +0200 +++ b/tests/test-commandserver.t Thu Oct 05 15:25:18 2017 +0200 @@ -535,6 +535,7 @@ tag: tip user: test date: Thu Jan 01 00:00:00 1970 +0000 + obsfate: pruned summary: . changeset: 0:eff892de26ec
--- a/tests/test-obsmarker-template.t Mon Oct 09 15:34:26 2017 +0200 +++ b/tests/test-obsmarker-template.t Thu Oct 05 15:25:18 2017 +0200 @@ -58,11 +58,13 @@ |/ parent: 0:ea207398892e | user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: rewritten using amend as 3:d004c8f274b9 by test2 | summary: A1 | | x changeset: 1:471f378eab4c |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: rewritten using amend as 2:a468dc9b3633 | summary: A0 | o changeset: 0:ea207398892e @@ -103,6 +105,26 @@ |/ Obsfate: rewritten using amend as 3:d004c8f274b9 by test, test2 o ea207398892e + + $ hg log -G --config ui.logtemplate= + o changeset: 3:d004c8f274b9 + | tag: tip + | parent: 0:ea207398892e + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: A2 + | + | @ changeset: 1:471f378eab4c + |/ user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: rewritten using amend as 3:d004c8f274b9 by test2 + | summary: A0 + | + o changeset: 0:ea207398892e + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: ROOT + $ hg up 'desc(A1)' --hidden 1 files updated, 0 files merged, 0 files removed, 0 files unresolved @@ -294,6 +316,7 @@ | x changeset: 1:471597cad322 |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: split as 2:337fec4d2edc, 3:f257fde29c7a | summary: A0 | o changeset: 0:ea207398892e @@ -469,11 +492,13 @@ | x changeset: 2:0dec01379d3b | | user: test | | date: Thu Jan 01 00:00:00 1970 +0000 + | | obsfate: rewritten as 3:eb5a0daa2192 | | summary: B0 | | | x changeset: 1:471f378eab4c |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: rewritten as 3:eb5a0daa2192 | summary: A0 | o changeset: 0:ea207398892e @@ -640,6 +665,7 @@ | x changeset: 1:471f378eab4c |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: rewritten using amend as 2:fdf9bde5129a | summary: A0 | o changeset: 0:ea207398892e @@ -669,6 +695,8 @@ | x changeset: 1:471f378eab4c |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: rewritten using amend as 2:fdf9bde5129a + | obsfate: rewritten using amend as 3:65b757b745b9 | summary: A0 | o changeset: 0:ea207398892e @@ -690,6 +718,7 @@ |/ parent: 0:ea207398892e | user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: rewritten using amend as 4:019fadeab383 | summary: A2 | | o changeset: 2:fdf9bde5129a @@ -702,6 +731,8 @@ | x changeset: 1:471f378eab4c |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: rewritten using amend as 2:fdf9bde5129a + | obsfate: rewritten using amend as 3:65b757b745b9 | summary: A0 | o changeset: 0:ea207398892e @@ -880,6 +911,7 @@ | x changeset: 2:0dec01379d3b |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: rewritten using amend as 3:b7ea6d14e664 | summary: B0 | o changeset: 1:471f378eab4c @@ -918,16 +950,19 @@ | | parent: 1:471f378eab4c | | user: test | | date: Thu Jan 01 00:00:00 1970 +0000 + | | obsfate: rewritten as 4:eb5a0daa2192 | | summary: B1 | | | | x changeset: 2:0dec01379d3b | |/ user: test | | date: Thu Jan 01 00:00:00 1970 +0000 + | | obsfate: rewritten using amend as 3:b7ea6d14e664 | | summary: B0 | | | x changeset: 1:471f378eab4c |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: rewritten as 4:eb5a0daa2192 | summary: A0 | o changeset: 0:ea207398892e @@ -1166,11 +1201,13 @@ |/ parent: 0:ea207398892e | user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: rewritten using amend as 3:7a230b46bf61 | summary: A1 | | x changeset: 1:471f378eab4c |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: rewritten using amend as 2:fdf9bde5129a | summary: A0 | o changeset: 0:ea207398892e @@ -1201,6 +1238,7 @@ | @ changeset: 1:471f378eab4c |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: rewritten using amend as 2:7a230b46bf61 | summary: A0 | o changeset: 0:ea207398892e @@ -1608,6 +1646,8 @@ | x changeset: 6:4a004186e638 |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: rewritten using amend as 8:b18bc8331526 + | obsfate: rewritten using amend as 9:0b997eb7ceee | summary: Add A,B,C | o changeset: 5:dd800401bd8c @@ -2051,6 +2091,7 @@ | tag: tip | user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: pruned | summary: A2 | o changeset: 2:617adc3a144c @@ -2062,6 +2103,7 @@ | x changeset: 1:471597cad322 |/ user: test | date: Thu Jan 01 00:00:00 1970 +0000 + | obsfate: split as 2:617adc3a144c, 3:0d0ef4bdf70e | summary: A0 | o changeset: 0:ea207398892e
--- a/tests/test-obsolete.t Mon Oct 09 15:34:26 2017 +0200 +++ b/tests/test-obsolete.t Thu Oct 05 15:25:18 2017 +0200 @@ -975,6 +975,7 @@ [log.parent changeset.draft|parent: 3:6f9641995072] [log.user|user: test] [log.date|date: Thu Jan 01 00:00:00 1970 +0000] + [log.obsfate|obsfate: pruned] [log.summary|summary: add obsolete_e]