Patchwork [v2] cleanup: reuse existing wctx variables instead of calling repo[None]

login
register
mail settings
Submitter via Mercurial-devel
Date May 21, 2017, 5:48 a.m.
Message ID <b86e47cf727e64b649c9.1495345735@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/20784/
State Accepted
Headers show

Comments

via Mercurial-devel - May 21, 2017, 5:48 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1495344472 25200
#      Sat May 20 22:27:52 2017 -0700
# Node ID b86e47cf727e64b649c9184d9f385ddb4de8dc85
# Parent  b9942bc6b292aa9b16ad80fceb765dab4f1c777c
cleanup: reuse existing wctx variables instead of calling repo[None]

Incidentally, this apparently means we load .hgsub one time less as
well, which affects a test case.
Augie Fackler - May 21, 2017, 6:28 a.m.
> On May 20, 2017, at 22:48, Martin von Zweigbergk via Mercurial-devel <mercurial-devel@mercurial-scm.org> wrote:
> 
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1495344472 25200
> #      Sat May 20 22:27:52 2017 -0700
> # Node ID b86e47cf727e64b649c9184d9f385ddb4de8dc85
> # Parent  b9942bc6b292aa9b16ad80fceb765dab4f1c777c
> cleanup: reuse existing wctx variables instead of calling repo[None]

queued, thanks

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -119,7 +119,7 @@ 
     m = matcher
 
     wctx = repo[None]
-    for f in repo[None].walk(matchmod.badmatch(m, lambda x, y: None)):
+    for f in wctx.walk(matchmod.badmatch(m, lambda x, y: None)):
         exact = m.exact(f)
         lfile = lfutil.standin(f) in wctx
         nfile = f in wctx
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -715,8 +715,8 @@ 
             badstates = '?'
         else:
             badstates = '?r'
-        m = scmutil.match(repo[None], [pat], opts, globbed=True)
-        for abs in repo[None].walk(m):
+        m = scmutil.match(wctx, [pat], opts, globbed=True)
+        for abs in wctx.walk(m):
             state = repo.dirstate[abs]
             rel = m.rel(abs)
             exact = m.exact(abs)
@@ -3049,7 +3049,7 @@ 
 
         if not m.always():
             matcher = matchmod.badmatch(m, lambda x, y: False)
-            for abs in repo[None].walk(matcher):
+            for abs in wctx.walk(matcher):
                 names[abs] = m.rel(abs), m.exact(abs)
 
             # walk target manifest to fill `names`
diff --git a/tests/test-subrepo-missing.t b/tests/test-subrepo-missing.t
--- a/tests/test-subrepo-missing.t
+++ b/tests/test-subrepo-missing.t
@@ -34,7 +34,6 @@ 
   $ hg revert .hgsub
   warning: subrepo spec file '.hgsub' not found
   warning: subrepo spec file '.hgsub' not found
-  warning: subrepo spec file '.hgsub' not found
 
 delete .hgsubstate and revert it