[PATCH 5 of 6 v2] dirstate: speed up _addpath by switching from _dirs to _sortedfiles

Kevin Bullock kbullock+mercurial at ringworld.org
Tue Jun 26 21:53:22 CDT 2012


(comments inline below, as usual)

On 26 Jun 2012, at 2:04 PM, Joshua Redstone wrote:

> # HG changeset patch
> # User Joshua Redstone <joshua.redstone at fb.com>
> # Date 1340034409 25200
> # Node ID 592a6e3e9f4df3e2e3b8a137cb3aaa5143a96451
> # Parent  8435841e0e7fc4bd06f28c881b4fd74a666f9688
> dirstate: speed up _addpath by switching from _dirs to _sortedfiles
> 
> _addpath used to use _dirs, the construction of which is expensive.
> Now it uses _sortedfiles which is much cheaper.
> 
> diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
> --- a/mercurial/dirstate.py
> +++ b/mercurial/dirstate.py
> @@ -332,7 +332,7 @@
>         oldstate = self[f]
>         if check or oldstate == "r":
>             scmutil.checkfilename(f)
> -            if f in self._dirs:
> +            if util.prefixmatch(f + "/", self._sortedfiles) == f + "/":
>                 raise util.Abort(_('directory %r already in dirstate') % f)
>             # shadows
>             for d in _finddirs(f):
> diff --git a/tests/test-dirstate.t b/tests/test-dirstate.t
> --- a/tests/test-dirstate.t
> +++ b/tests/test-dirstate.t
> @@ -14,6 +14,21 @@
>   moving a/b/c/d/x to z/b/c/d/x (glob)
>   moving a/b/c/d/y to z/b/c/d/y (glob)
>   moving a/b/c/d/z to z/b/c/d/z (glob)
> +
> +Test name collisions
> +
> +  $ rm z/b/c/d/x
> +  $ mkdir z/b/c/d/x
> +  $ touch z/b/c/d/x/y
> +  $ hg add z/b/c/d/x/y
> +  abort: file 'z/b/c/d/x' in dirstate clashes with 'z/b/c/d/x/y'
> +  [255]
> +  $ rm -rf z/b/c/d
> +  $ touch z/b/c/d
> +  $ hg add z/b/c/d
> +  abort: directory 'z/b/c/d' already in dirstate
> +  [255]
> +

This looks like something that should be added _before_ switching to the new implementation, in a separate patch.

>   $ cd ..
> 
> Issue1790: dirstate entry locked into unset if file mtime is set into
> @@ -38,4 +53,3 @@
>   $ hg debugstate
>   n 644          2 2021-01-01 12:00:00 a
>   $ cd ..
> -

Unrelated whitespace change.

pacem in terris / мир / शान्ति / ‎‫سَلاَم‬ / 平和
Kevin R. Bullock

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20120626/fa392a5d/attachment.html>


More information about the Mercurial-devel mailing list