[PATCH STABLE] status: avoid recursing into ignored directory with "--terse u"

Denis Laxalde denis at laxalde.org
Mon Jul 24 09:05:21 UTC 2017


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1500885272 -7200
#      Mon Jul 24 10:34:32 2017 +0200
# Branch stable
# Node ID 55539b4f598f54115e82d47dadefce8feebd465f
# Parent  e9850cc580a758f06506276140cc424bc8a415be
# Available At http://hg.logilab.org/users/dlaxalde/hg
#              hg pull http://hg.logilab.org/users/dlaxalde/hg -r 55539b4f598f
status: avoid recursing into ignored directory with "--terse u"

Let "isignoreddir" function first check that supplied directory is itself
ignored before walking recursively into its content. Otherwise, the command is
awfully slow when one has an ignored directory with a lot of content.

Update and rephrase function docstring accordingly.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -466,12 +466,12 @@ def tersestatus(root, statlist, status, 
         return True
 
     def isignoreddir(localpath):
-        """
-        This function checks whether the directory contains only ignored files
-        and hence should the directory be considered ignored. Returns True, if
-        that should be ignored otherwise False.
+        """Return True if `localpath` directory is ignored or contains only
+        ignored files and should hence be considered ignored.
         """
         dirpath = os.path.join(root, localpath)
+        if ignorefn(dirpath):
+            return True
         for f in os.listdir(dirpath):
             filepath = os.path.join(dirpath, f)
             if os.path.isdir(filepath):


More information about the Mercurial-devel mailing list