Patchwork [3,of,5] templatekw: change {manifest} to be empty for workingctx

login
register
mail settings
Submitter Yuya Nishihara
Date April 7, 2015, 2:07 p.m.
Message ID <a019d816cc08bf16135e.1428415661@mimosa>
Download mbox | patch
Permalink /patch/8532/
State Changes Requested
Headers show

Comments

Yuya Nishihara - April 7, 2015, 2:07 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1426323498 -32400
#      Sat Mar 14 17:58:18 2015 +0900
# Node ID a019d816cc08bf16135e1e22c32eae56fc2d32da
# Parent  8c44ed02f5ff82584e55c6978396ad004ec0dbe2
templatekw: change {manifest} to be empty for workingctx

This will prevent crash by "hg log -r 'wdir()' -Tdefault".
Sean Farley - April 7, 2015, 4:42 p.m.
Yuya Nishihara <yuya@tcha.org> writes:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1426323498 -32400
> #      Sat Mar 14 17:58:18 2015 +0900
> # Node ID a019d816cc08bf16135e1e22c32eae56fc2d32da
> # Parent  8c44ed02f5ff82584e55c6978396ad004ec0dbe2
> templatekw: change {manifest} to be empty for workingctx
>
> This will prevent crash by "hg log -r 'wdir()' -Tdefault".

Hmmm, I don't know how I feel about this. I would think the workingctx
manifest would be the parent manifest + added / removed files, no?
This would make it similar to how repo[None] works.
Pierre-Yves David - April 7, 2015, 6:27 p.m.
On 04/07/2015 09:42 AM, Sean Farley wrote:
>
> Yuya Nishihara <yuya@tcha.org> writes:
>
>> # HG changeset patch
>> # User Yuya Nishihara <yuya@tcha.org>
>> # Date 1426323498 -32400
>> #      Sat Mar 14 17:58:18 2015 +0900
>> # Node ID a019d816cc08bf16135e1e22c32eae56fc2d32da
>> # Parent  8c44ed02f5ff82584e55c6978396ad004ec0dbe2
>> templatekw: change {manifest} to be empty for workingctx
>>
>> This will prevent crash by "hg log -r 'wdir()' -Tdefault".
>
> Hmmm, I don't know how I feel about this. I would think the workingctx
> manifest would be the parent manifest + added / removed files, no?
> This would make it similar to how repo[None] works.

I second Sean here, this seems scary.
Yuya Nishihara - April 8, 2015, 11:08 a.m.
On Tue, 07 Apr 2015 11:27:59 -0700, Pierre-Yves David wrote:
> On 04/07/2015 09:42 AM, Sean Farley wrote:
> > Yuya Nishihara <yuya@tcha.org> writes:
> >> # HG changeset patch
> >> # User Yuya Nishihara <yuya@tcha.org>
> >> # Date 1426323498 -32400
> >> #      Sat Mar 14 17:58:18 2015 +0900
> >> # Node ID a019d816cc08bf16135e1e22c32eae56fc2d32da
> >> # Parent  8c44ed02f5ff82584e55c6978396ad004ec0dbe2
> >> templatekw: change {manifest} to be empty for workingctx
> >>
> >> This will prevent crash by "hg log -r 'wdir()' -Tdefault".
> >
> > Hmmm, I don't know how I feel about this. I would think the workingctx
> > manifest would be the parent manifest + added / removed files, no?
> > This would make it similar to how repo[None] works.
> 
> I second Sean here, this seems scary.

The {manifest} here is ctx.manifestnode(), not a list of files. I think you
are talking about ctx.manifest().

Regards,

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -333,6 +333,8 @@  def showlatesttagdistance(repo, ctx, tem
 
 def showmanifest(**args):
     repo, ctx, templ = args['repo'], args['ctx'], args['templ']
+    if ctx.rev() is None:
+        return None
     args = args.copy()
     args.update({'rev': repo.manifest.rev(ctx.changeset()[0]),
                  'node': hex(ctx.changeset()[0])})
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
@@ -60,6 +60,8 @@  because there are several ways to:
   
   $ hg log -r 'wdir()' -T '{rev|stringify}\n'
   
+  $ hg log -r 'wdir()' -T '{manifest}\n'
+  
 
 Quoting for ui.logtemplate