diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py --- a/mercurial/templatekw.py +++ b/mercurial/templatekw.py @@ -355,6 +355,9 @@ def showchangessincelatesttag(repo, ctx, 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) diff --git a/tests/test-command-template.t b/tests/test-command-template.t --- a/tests/test-command-template.t +++ b/tests/test-command-template.t @@ -51,6 +51,12 @@ Second branch starting at nullrev: 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"