Patchwork [2,of,3] merge: use dirstate.notincluded in _checkunknown

login
register
mail settings
Submitter Siddharth Agarwal
Date Feb. 1, 2013, 10:41 p.m.
Message ID <802db8814a53d3e1c0bd.1359758485@sid0x220>
Download mbox | patch
Permalink /patch/793/
State Superseded
Commit 26627c30735a610f59979a36885b327b25d8dbff
Headers show

Comments

Siddharth Agarwal - Feb. 1, 2013, 10:41 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1359674799 28800
# Branch stable
# Node ID 802db8814a53d3e1c0bd4d444e9a70158bd48396
# Parent  9139388e66b4c6295c85989f27357c280a40025d
merge: use dirstate.notincluded in _checkunknown

On a repository with over 150,000 files, this speeds up update by around 0.4
seconds.
Matt Mackall - Feb. 1, 2013, 11:36 p.m.
On Fri, 2013-02-01 at 14:41 -0800, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1359674799 28800
> # Branch stable
> # Node ID 802db8814a53d3e1c0bd4d444e9a70158bd48396
> # Parent  9139388e66b4c6295c85989f27357c280a40025d
> merge: use dirstate.notincluded in _checkunknown
> 
> On a repository with over 150,000 files, this speeds up update by around 0.4
> seconds.
> 
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -101,8 +101,8 @@ def _checkunknown(repo, wctx, mctx):
>      "check for collisions between unknown files and files in mctx"
>  
>      error = False
> -    for f in mctx:
> -        if f not in wctx and _checkunknownfile(repo, wctx, mctx, f):
> +    for f in repo.dirstate.notincluded(mctx):
> +        if _checkunknownfile(repo, wctx, mctx, f):
>              error = True
>              wctx._repo.ui.warn(_("%s: untracked file differs\n") % f)
>      if error:

I think we should restructure the unknown and collision checks instead.

In particular, I think we should do manifestmerge, then take the
resulting action list and figure out all the "interesting" files that
we're going to touch or remove and decide if they create problems. The
"interesting list" will generally be shorter and thus be less of an
overhead here. Also, because it's after the merge, we won't have false
positives that the merge would remove.

We'll want Mads' code to defer prompting to make this work.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -101,8 +101,8 @@  def _checkunknown(repo, wctx, mctx):
     "check for collisions between unknown files and files in mctx"
 
     error = False
-    for f in mctx:
-        if f not in wctx and _checkunknownfile(repo, wctx, mctx, f):
+    for f in repo.dirstate.notincluded(mctx):
+        if _checkunknownfile(repo, wctx, mctx, f):
             error = True
             wctx._repo.ui.warn(_("%s: untracked file differs\n") % f)
     if error: