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

login
register
mail settings
Submitter Denis Laxalde
Date July 24, 2017, 9:05 a.m.
Message ID <55539b4f598f54115e82.1500887121@sh77.tls.logilab.fr>
Download mbox | patch
Permalink /patch/22543/
State Accepted
Headers show

Comments

Denis Laxalde - July 24, 2017, 9:05 a.m.
# HG changeset patch
# User Denis Laxalde <denis.laxalde@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.
Augie Fackler - July 25, 2017, 1:38 a.m.
On Mon, Jul 24, 2017 at 11:05:21AM +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis.laxalde@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"

I'm really really enthusiastic about this. But it's enough of a "new
feature" that I'm wary of landing it during the freeze. I've queued it
for default, but that means it won't show up anywhere until we finish
the 4.3 release. Let me know if I should discard it and expect a
resend instead.

>
> 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):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Denis Laxalde - July 25, 2017, 11:25 a.m.
Augie Fackler a écrit :
> On Mon, Jul 24, 2017 at 11:05:21AM +0200, Denis Laxalde wrote:
>> # HG changeset patch
>> # User Denis Laxalde <denis.laxalde@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"
>
> I'm really really enthusiastic about this. But it's enough of a "new
> feature" that I'm wary of landing it during the freeze. I've queued it
> for default, but that means it won't show up anywhere until we finish
> the 4.3 release. Let me know if I should discard it and expect a
> resend instead.

Ok, that's fine.
Anyways, I guess that, beyond this patch, the code would need other
performance-related tweaks.

>>
>> 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):
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

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):