Patchwork [3,of,3] cat: disable optimization of single file case for workingctx

login
register
mail settings
Submitter Yuya Nishihara
Date April 11, 2015, 8:06 a.m.
Message ID <f01f98bb99cf25317322.1428739583@mimosa>
Download mbox | patch
Permalink /patch/8613/
State Accepted
Commit 28094b17eb04c54c313e1ac115c848af9bf79ef9
Headers show

Comments

Yuya Nishihara - April 11, 2015, 8:06 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1428207406 -32400
#      Sun Apr 05 13:16:46 2015 +0900
# Node ID f01f98bb99cf25317322cc5871635b6fe0cb0537
# Parent  0ba34786c958ea24d33ca914546214982b729442
cat: disable optimization of single file case for workingctx

It crashes because workingctx has no manifest.
Augie Fackler - April 11, 2015, 9:29 p.m.
On Sat, Apr 11, 2015 at 05:06:23PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1428207406 -32400
> #      Sun Apr 05 13:16:46 2015 +0900
> # Node ID f01f98bb99cf25317322cc5871635b6fe0cb0537
> # Parent  0ba34786c958ea24d33ca914546214982b729442
> cat: disable optimization of single file case for workingctx

queued these, thanks

>
> It crashes because workingctx has no manifest.
>
> diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -2403,7 +2403,7 @@ def cat(ui, repo, ctx, matcher, prefix,
>          file = matcher.files()[0]
>          mf = repo.manifest
>          mfnode = ctx.manifestnode()
> -        if mf.find(mfnode, file)[0]:
> +        if mfnode and mf.find(mfnode, file)[0]:
>              write(file)
>              return 0
>
> diff --git a/tests/test-cat.t b/tests/test-cat.t
> --- a/tests/test-cat.t
> +++ b/tests/test-cat.t
> @@ -63,3 +63,8 @@ Test fileset
>    tmp/h_45116003780e
>    tmp/r_2
>
> +Test working directory
> +
> +  $ echo b-wdir > b
> +  $ hg cat -r 'wdir()' b
> +  b-wdir
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2403,7 +2403,7 @@  def cat(ui, repo, ctx, matcher, prefix, 
         file = matcher.files()[0]
         mf = repo.manifest
         mfnode = ctx.manifestnode()
-        if mf.find(mfnode, file)[0]:
+        if mfnode and mf.find(mfnode, file)[0]:
             write(file)
             return 0
 
diff --git a/tests/test-cat.t b/tests/test-cat.t
--- a/tests/test-cat.t
+++ b/tests/test-cat.t
@@ -63,3 +63,8 @@  Test fileset
   tmp/h_45116003780e
   tmp/r_2
 
+Test working directory
+
+  $ echo b-wdir > b
+  $ hg cat -r 'wdir()' b
+  b-wdir