[PATCH] match: fix bug in match.visitdir()

Martin von Zweigbergk martinvonz at google.com
Fri May 22 16:45:05 CDT 2015


On Fri, May 22, 2015 at 2:41 PM Drew Gottlieb <drgott at google.com> wrote:

> # HG changeset patch
> # User Drew Gottlieb <drgott at google.com>
> # Date 1432330774 25200
> #      Fri May 22 14:39:34 2015 -0700
> # Node ID 5b93e1cbb45cde9ede354ec6473f22734e1311e1
> # Parent  f2b98dacb37ddd6713b11a1a871fcdbbc5fd8bb2
> match: fix bug in match.visitdir()
>
> There was a bug in my recent change to visitdir (8545bd381504) due to
> the stored generator being iterated over twice. Making the generator into a
> list at the start fixes this.
>
> diff --git a/mercurial/match.py b/mercurial/match.py
> --- a/mercurial/match.py
> +++ b/mercurial/match.py
> @@ -197,7 +197,7 @@
>          parentdirs = None
>          if (self._includeroots and dir not in self._includeroots and
>                  dir not in self._includedirs):
> -            parentdirs = util.finddirs(dir)
> +            parentdirs = list(util.finddirs(dir))
>

To whomever will pick up this patch: It may or may not be faster to just
call util.finddirs twice where it's used, but I'm planning to rewrite this
piece of the function once I'm done with the match.files() stuff anyway
(combining _fileroots and _includeroots), so I think it's fine to just
accept this version without thinking too much about it.

             if not any(parent in self._includeroots for parent in
> parentdirs):
>                  return False
>          return (not self._fileroots or '.' in self._fileroots or
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150522/795c83bd/attachment.html>


More information about the Mercurial-devel mailing list