[PATCH 1 of 3] dirstate: don't check state of subrepo directories

durin42 at gmail.com durin42 at gmail.com
Thu Dec 31 14:36:20 CST 2009


# HG changeset patch
# User Augie Fackler <durin42 at gmail.com>
# Date 1261857501 21600
# Node ID 68d80c9814d720f2b7d8b2f39008ae6547a5b128
# Parent  513c89a60f203a8387d8dfa6f2dc67b21725790a
dirstate: don't check state of subrepo directories

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -32,7 +32,7 @@
 def perfwalk(ui, repo, *pats):
     try:
         m = cmdutil.match(repo, pats, {})
-        timer(lambda: len(list(repo.dirstate.walk(m, True, False))))
+        timer(lambda: len(list(repo.dirstate.walk(m, True, False, []))))
     except:
         try:
             m = cmdutil.match(repo, pats, {})
@@ -150,4 +150,3 @@
     'perftemplating': (perftemplating, []),
     'perfdiffwd': (perfdiffwd, []),
 }
-
diff --git a/hgext/inotify/__init__.py b/hgext/inotify/__init__.py
--- a/hgext/inotify/__init__.py
+++ b/hgext/inotify/__init__.py
@@ -42,11 +42,11 @@
         # to start an inotify server if it won't start.
         _inotifyon = True
 
-        def status(self, match, ignored, clean, unknown=True):
+        def status(self, match, ignored, clean, unknown=True, skip=None):
             files = match.files()
             if '.' in files:
                 files = []
-            if self._inotifyon and not ignored and not self._dirty:
+            if self._inotifyon and not ignored and not skip and not self._dirty:
                 cli = client(ui, repo)
                 try:
                     result = cli.statusquery(files, match, False,
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -638,7 +638,8 @@
         return self._parents[0].ancestor(c2) # punt on two parents for now
 
     def walk(self, match):
-        return sorted(self._repo.dirstate.walk(match, True, False))
+        return sorted(self._repo.dirstate.walk(match, True, False,
+                                               self.substate.keys()))
 
     def dirty(self, missing=False):
         "check whether a working directory is modified"
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -425,7 +425,7 @@
                 return True
         return False
 
-    def walk(self, match, unknown, ignored):
+    def walk(self, match, unknown, ignored, skiplist):
         '''
         Walk recursively through the directory tree, finding all files
         matched by match.
@@ -486,7 +486,8 @@
         files = set(match.files())
         if not files or '.' in files:
             files = ['']
-        results = {'.hg': None}
+        results = dict.fromkeys(skiplist)
+        results['.hg'] = None
 
         # step 1: find all explicit files
         for ff in sorted(files):
@@ -564,11 +565,11 @@
                 if not st is None and not getkind(st.st_mode) in (regkind, lnkkind):
                     st = None
                 results[nf] = st
-
+        map(results.pop, skiplist)
         del results['.hg']
         return results
 
-    def status(self, match, ignored, clean, unknown):
+    def status(self, match, ignored, clean, unknown, skip=[]):
         '''Determine the status of the working copy relative to the
         dirstate and return a tuple of lists (unsure, modified, added,
         removed, deleted, unknown, ignored, clean), where:
@@ -609,7 +610,8 @@
         dadd = deleted.append
         cadd = clean.append
 
-        for fn, st in self.walk(match, listunknown, listignored).iteritems():
+        for fn, st in self.walk(match, listunknown,
+                                listignored, skip).iteritems():
             if fn not in dmap:
                 if (listignored or match.exact(fn)) and self._dirignore(fn):
                     if listignored:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1000,7 +1000,9 @@
             match.bad = bad
 
         if working: # we need to scan the working dir
-            s = self.dirstate.status(match, listignored, listclean, listunknown)
+            s = self.dirstate.status(match, listignored, listclean, listunknown,
+                                     skip=set(ctx1.substate.keys() +
+                                              ctx2.substate.keys()))
             cmp, modified, added, removed, deleted, unknown, ignored, clean = s
 
             # check for any possibly clean files


More information about the Mercurial-devel mailing list