Patchwork [1,of,5] scmutil: skip checks in "casecollisionauditor" if filename is already checked

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Nov. 11, 2013, 3:15 p.m.
Message ID <2558f01d2f7f2a118679.1384182956@juju>
Download mbox | patch
Permalink /patch/2905/
State Superseded
Commit 9276014db8650492a5df142874d45846d44417c2
Headers show

Comments

Katsunori FUJIWARA - Nov. 11, 2013, 3:15 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1384182443 -32400
#      Tue Nov 12 00:07:23 2013 +0900
# Node ID 2558f01d2f7f2a118679f1ee68a743543039aff8
# Parent  c38c3fdc8b9317ba09e03ab09364c3800da7c50c
scmutil: skip checks in "casecollisionauditor" if filename is already checked

Before this patch, almost all of check code in
"casecollisionauditor.__call__()" is executed, even if specified
filename is already checked, because "f in self._newfiles" is examined
lastly.

In addition to it, adding "fl" to "self._loweredfiles" and "f" to
"self._newfiles" are also redundant in such case.

This patch checks "f in self._newfiles" first, and returns immediately
to avoid execution of check code for efficiency.
Matt Mackall - Nov. 13, 2013, 9 p.m.
On Tue, 2013-11-12 at 00:15 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
> # Date 1384182443 -32400
> #      Tue Nov 12 00:07:23 2013 +0900
> # Node ID 2558f01d2f7f2a118679f1ee68a743543039aff8
> # Parent  c38c3fdc8b9317ba09e03ab09364c3800da7c50c
> scmutil: skip checks in "casecollisionauditor" if filename is already checked

Queued for default, thanks.

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -97,9 +97,10 @@ 
         self._newfiles = set()
 
     def __call__(self, f):
+        if f in self._newfiles:
+            return
         fl = encoding.lower(f)
-        if (fl in self._loweredfiles and f not in self._dirstate and
-            f not in self._newfiles):
+        if fl in self._loweredfiles and f not in self._dirstate:
             msg = _('possible case-folding collision for %s') % f
             if self._abort:
                 raise util.Abort(msg)