Mercurial > hg
changeset 25736:8854ca3fa675
templatekw: apply manifest template only if ctx.manifestnode() exists
This will prevent crash by "hg log -r 'wdir()' -Tdefault". We could use the
pseudo ff... hash introduced by 183965a00c76, but it isn't proven idea yet.
For now, I want to make "hg log" just works in order to test 'wdir()' revset.
Note that unlike its name, "{manifest}" is not a list of files in that
revision, but a pair of (manifestrev, manifestnode).
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 14 Mar 2015 17:58:18 +0900 |
parents | 3948cb4d0ae7 |
children | 1a5211f2f87f |
files | mercurial/templatekw.py tests/test-command-template.t |
diffstat | 2 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templatekw.py Tue Jul 07 19:07:04 2015 -0500 +++ b/mercurial/templatekw.py Sat Mar 14 17:58:18 2015 +0900 @@ -355,6 +355,9 @@ def showmanifest(**args): repo, ctx, templ = args['repo'], args['ctx'], args['templ'] mnode = ctx.manifestnode() + if mnode is None: + # just avoid crash, we might want to use the 'ff...' hash in future + return args = args.copy() args.update({'rev': repo.manifest.rev(mnode), 'node': hex(mnode)}) return templ('manifest', **args)
--- a/tests/test-command-template.t Tue Jul 07 19:07:04 2015 -0500 +++ b/tests/test-command-template.t Sat Mar 14 17:58:18 2015 +0900 @@ -51,6 +51,12 @@ 8 t 7 f +Some keywords are invalid for working-directory revision, but they should +never cause crash: + + $ hg log -r 'wdir()' -T '{manifest}\n' + + Quoting for ui.logtemplate $ hg tip --config "ui.logtemplate={rev}\n"