[PATCH] .hgskip support

Matt Mackall mpm at selenic.com
Thu Jul 7 01:25:58 UTC 2005


On Thu, Jul 07, 2005 at 12:19:20AM +0100, M.A. Williamson wrote:

Content-Description: hg_changes_speedup.patch
> # HG changeset patch
> # User mwilli2 at localhost.localdomain
> # Node ID 8ef9f4a79b15b344e78ec5a02bcae8ebc4a9aa46
> # Parent  8b8f710bb65875d588044c3615cf42180aee23ff
> Speed up the case where .hgignore excludes a large directory.
> 
> Avoids recursing into directories which will be ignored, whilst retaining the
> ability to track updates to revision controlled files within those directories.
> 
> diff -r 8b8f710bb658 -r 8ef9f4a79b15 mercurial/hg.py
> --- a/mercurial/hg.py	Wed Jul  6 02:23:56 2005
> +++ b/mercurial/hg.py	Wed Jul  6 23:03:13 2005
> @@ -292,19 +292,26 @@
>  
>          # recursive generator of all files listed
>          def walk(files):
> +            all = []
>              for f in util.unique(files):
>                  f = os.path.join(self.root, f)
>                  if os.path.isdir(f):
>                      for dir, subdirs, fl in os.walk(f):
>                          d = dir[len(self.root) + 1:]
> -                        if ".hg" in subdirs: subdirs.remove(".hg")
> +                        if ".hg" in subdirs:
> +                            subdirs.remove(".hg")
> +                        if ignore(d):
> +                            del subdirs[:]
> +                            continue

You want to filter subdirs, not d. Something like:

for sd in subdirs:
    if ignore(sd): subdirs.remove(sd)

>                          for fn in fl:
>                              fn = util.pconvert(os.path.join(d, fn))
> -                            yield fn
> +                            all.append(fn)

And this is where all your performance is going. Go back to using
yield, please.

We might as well check ignore(fn) here so that we don't redundantly
check it later.

>                  else:
> -                    yield f[len(self.root) + 1:]
> -
> -        for fn in util.unique(walk(files)):
> +                    all.append(f[len(self.root) + 1:])
> +
> +            return all
> +
> +        for fn in util.unique(walk(files) + dc.keys()):

And this hurts too. Just add the following to the end of walk:

for k in dc:
  yield k

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial mailing list