Patchwork purge: avoid full walks when directories aren't purged

login
register
mail settings
Submitter Siddharth Agarwal
Date Aug. 20, 2014, 10:15 p.m.
Message ID <373d25ae3077814c3c05.1408572946@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/5535/
State Accepted
Headers show

Comments

Siddharth Agarwal - Aug. 20, 2014, 10:15 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1408572445 25200
#      Wed Aug 20 15:07:25 2014 -0700
# Node ID 373d25ae3077814c3c05062ed11f21d5447cacd7
# Parent  de783f2403c498ef1e20121acf178b32ec27199c
purge: avoid full walks when directories aren't purged

If match.traversedir is not None, we're forced to do full walks. However when
we aren't purging directories we don't need to set match.traversedir to
anything.

This speeds up non-full walks such as the one hgwatchman makes possible. For
mozilla-central with hgwatchman enabled, 'hg purge --files' goes from 0.88
seconds to 0.22.
Pierre-Yves David - Aug. 21, 2014, 5:27 a.m.
On 08/20/2014 03:15 PM, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1408572445 25200
> #      Wed Aug 20 15:07:25 2014 -0700
> # Node ID 373d25ae3077814c3c05062ed11f21d5447cacd7
> # Parent  de783f2403c498ef1e20121acf178b32ec27199c
> purge: avoid full walks when directories aren't purged

Look good to me, pushed to the clown copter

(queued)
Augie Fackler - Aug. 23, 2014, 7:26 p.m.
On Wed, Aug 20, 2014 at 03:15:46PM -0700, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1408572445 25200
> #      Wed Aug 20 15:07:25 2014 -0700
> # Node ID 373d25ae3077814c3c05062ed11f21d5447cacd7
> # Parent  de783f2403c498ef1e20121acf178b32ec27199c
> purge: avoid full walks when directories aren't purged

Appears to have been ninja-queued as fe22d86a8992.

>
> If match.traversedir is not None, we're forced to do full walks. However when
> we aren't purging directories we don't need to set match.traversedir to
> anything.
>
> This speeds up non-full walks such as the one hgwatchman makes possible. For
> mozilla-central with hgwatchman enabled, 'hg purge --files' goes from 0.88
> seconds to 0.22.
>
> diff --git a/hgext/purge.py b/hgext/purge.py
> --- a/hgext/purge.py
> +++ b/hgext/purge.py
> @@ -95,9 +95,10 @@
>          else:
>              ui.write('%s%s' % (name, eol))
>
> -    directories = []
>      match = scmutil.match(repo[None], dirs, opts)
> -    match.explicitdir = match.traversedir = directories.append
> +    if removedirs:
> +        directories = []
> +        match.explicitdir = match.traversedir = directories.append
>      status = repo.status(match=match, ignored=opts['all'], unknown=True)
>
>      if removefiles:
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Pierre-Yves David - Aug. 23, 2014, 8:50 p.m.
On 08/23/2014 12:26 PM, Augie Fackler wrote:
> On Wed, Aug 20, 2014 at 03:15:46PM -0700, Siddharth Agarwal wrote:
>> # HG changeset patch
>> # User Siddharth Agarwal <sid0@fb.com>
>> # Date 1408572445 25200
>> #      Wed Aug 20 15:07:25 2014 -0700
>> # Node ID 373d25ae3077814c3c05062ed11f21d5447cacd7
>> # Parent  de783f2403c498ef1e20121acf178b32ec27199c
>> purge: avoid full walks when directories aren't purged
>
> Appears to have been ninja-queued as fe22d86a8992.

Ninjas rarely leave public trail on the internet:

http://www.selenic.com/pipermail/mercurial-devel/2014-August/060956.html
Augie Fackler - Aug. 23, 2014, 9:46 p.m.
Blah. That showed up after I synced mail. Sigh.
On Aug 23, 2014 4:50 PM, "Pierre-Yves David" <pierre-yves.david@ens-lyon.org>
wrote:

>
>
> On 08/23/2014 12:26 PM, Augie Fackler wrote:
>
>> On Wed, Aug 20, 2014 at 03:15:46PM -0700, Siddharth Agarwal wrote:
>>
>>> # HG changeset patch
>>> # User Siddharth Agarwal <sid0@fb.com>
>>> # Date 1408572445 25200
>>> #      Wed Aug 20 15:07:25 2014 -0700
>>> # Node ID 373d25ae3077814c3c05062ed11f21d5447cacd7
>>> # Parent  de783f2403c498ef1e20121acf178b32ec27199c
>>> purge: avoid full walks when directories aren't purged
>>>
>>
>> Appears to have been ninja-queued as fe22d86a8992.
>>
>
> Ninjas rarely leave public trail on the internet:
>
> http://www.selenic.com/pipermail/mercurial-devel/2014-August/060956.html
>
>
> --
> Pierre-Yves David
>

Patch

diff --git a/hgext/purge.py b/hgext/purge.py
--- a/hgext/purge.py
+++ b/hgext/purge.py
@@ -95,9 +95,10 @@ 
         else:
             ui.write('%s%s' % (name, eol))
 
-    directories = []
     match = scmutil.match(repo[None], dirs, opts)
-    match.explicitdir = match.traversedir = directories.append
+    if removedirs:
+        directories = []
+        match.explicitdir = match.traversedir = directories.append
     status = repo.status(match=match, ignored=opts['all'], unknown=True)
 
     if removefiles: