Patchwork [1,of,2,V3] files: use ctx object to access dirstate

login
register
mail settings
Submitter Matt Harbison
Date March 11, 2015, 1:09 a.m.
Message ID <a8a49154503c2e7ca4c2.1426036187@Envy>
Download mbox | patch
Permalink /patch/7987/
State Accepted
Commit 9640820bc957301b49bb677a4aee181de8d8266b
Headers show

Comments

Matt Harbison - March 11, 2015, 1:09 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1425847529 14400
#      Sun Mar 08 16:45:29 2015 -0400
# Node ID a8a49154503c2e7ca4c2ab796a76da42712f780b
# Parent  73191a7fdebbf8aa518eef5a65abb25678c5781f
files: use ctx object to access dirstate

This allows the cmdutil method to not need to be passed the repo as well as the
ctx.
Augie Fackler - March 11, 2015, 4:56 p.m.
On Tue, Mar 10, 2015 at 09:09:47PM -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1425847529 14400
> #      Sun Mar 08 16:45:29 2015 -0400
> # Node ID a8a49154503c2e7ca4c2ab796a76da42712f780b
> # Parent  73191a7fdebbf8aa518eef5a65abb25678c5781f
> files: use ctx object to access dirstate
>
> This allows the cmdutil method to not need to be passed the repo as well as the
> ctx.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -3268,7 +3268,7 @@
>      fmt = '%s' + end
>
>      m = scmutil.match(ctx, pats, opts)
> -    ds = repo.dirstate
> +    ds = ctx._repo.dirstate

As an eventual followup I'd like to see a variant of this that doesn't
use a private attribute off the ctx.

>      for f in ctx.matches(m):
>          if rev is None and ds[f] == 'r':
>              continue
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3268,7 +3268,7 @@ 
     fmt = '%s' + end
 
     m = scmutil.match(ctx, pats, opts)
-    ds = repo.dirstate
+    ds = ctx._repo.dirstate
     for f in ctx.matches(m):
         if rev is None and ds[f] == 'r':
             continue