changeset 39960:1a7d901a0a0c

narrow: avoid looking up dirstate again when editing dirstate The narrow extension overrides the dirstate editing functions to restrict paths outside the narrowspec. These overrides access the dirstate from repo.dirstate instead of using the "self" reference passed to the overridden functions. I don't see a reason for this and it caused me problems with a later patch (it caused infinite recursion when I modified localrepo.dirstate()), so let's change it. Differential Revision: https://phab.mercurial-scm.org/D4829
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 01 Oct 2018 15:29:31 -0700
parents 43d3b09b3e5a
children ad9ca365738b
files hgext/narrow/narrowdirstate.py
diffstat 1 files changed, 1 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/narrow/narrowdirstate.py	Wed Sep 26 23:09:28 2018 -0700
+++ b/hgext/narrow/narrowdirstate.py	Mon Oct 01 15:29:31 2018 -0700
@@ -18,10 +18,9 @@
 
     def _editfunc(fn):
         def _wrapper(self, *args):
-            dirstate = repo.dirstate
             narrowmatch = repo.narrowmatch()
             for f in args:
-                if f is not None and not narrowmatch(f) and f not in dirstate:
+                if f is not None and not narrowmatch(f) and f not in self:
                     raise error.Abort(_("cannot track '%s' - it is outside " +
                         "the narrow clone") % f)
             return fn(self, *args)