2012/2/15 FUJIWARA Katsunori <span dir="ltr"><<a href="mailto:foozy@lares.dti.ne.jp">foozy@lares.dti.ne.jp</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
# HG changeset patch<br>
# User FUJIWARA Katsunori <<a href="mailto:foozy@lares.dti.ne.jp">foozy@lares.dti.ne.jp</a>><br>
# Date 1329314469 -32400<br>
# Branch stable<br>
# Node ID c0a0446aaa86e78626b3ae8c9a400320bb140c42<br>
# Parent  f7e0d95d0a0bc5545f3dad40b9ceaee362d7c553<br>
largefiles: check wheter specified patterns are related to largefiles strictly<br>
<br>
current 'lfiles_repo.status()' implementation examines whether<br>
specified patterns are related to largefiles in working directory (not<br>
to STANDIN) or not by NOT-EMPTY-NESS of below list:<br>
<br>
    [f for f in match.files() if f in lfdirstate]<br>
<br>
but it can not be assumed that all in 'match.files()' are file itself<br>
exactly, because user may only specify part of path to match whole<br>
under subdirectories recursively.<br>
<br>
above examination will mis-recognize such pattern as 'not related to<br>
largefiles', and executes normal 'status()' procedure. so, 'hg status'<br>
shows '?'(unknown) status for largefiles in working directory unexpectedly.<br>
<br>
this patch examines relation of pattern to largefiles by applying<br>
'match()' on each entries in lfdirstate and checking wheter there is<br>
no matched entry.<br>
<br>
it may increase cost of examination, because it causes of full scan of<br>
entries in lfdirstate.<br>
<br>
so this patch uses normal for-loop instead of list comprehensions, to<br>
decrease cost when matching is found.<br></blockquote><div><br>Did you do any performance testing before and after this patch?  What is the difference in performance?  What sort of repository did you test it on?<br><br>Na'Tosha<br>
 <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
diff -r f7e0d95d0a0b -r c0a0446aaa86 hgext/largefiles/reposetup.py<br>
--- a/hgext/largefiles/reposetup.py     Fri Feb 10 16:52:32 2012 -0600<br>
+++ b/hgext/largefiles/reposetup.py     Wed Feb 15 23:01:09 2012 +0900<br>
@@ -118,8 +118,10 @@<br>
                 # handle it -- thus gaining a big performance boost.<br>
                 lfdirstate = lfutil.openlfdirstate(ui, self)<br>
                 if match.files() and not match.anypats():<br>
-                    matchedfiles = [f for f in match.files() if f in lfdirstate]<br>
-                    if not matchedfiles:<br>
+                    for f in lfdirstate:<br>
+                        if match(f):<br>
+                            break<br>
+                    else:<br>
                         return super(lfiles_repo, self).status(node1, node2,<br>
                                 match, listignored, listclean,<br>
                                 listunknown, listsubrepos)<br>
diff -r f7e0d95d0a0b -r c0a0446aaa86 tests/test-largefiles.t<br>
--- a/tests/test-largefiles.t   Fri Feb 10 16:52:32 2012 -0600<br>
+++ b/tests/test-largefiles.t   Wed Feb 15 23:01:09 2012 +0900<br>
@@ -948,4 +948,50 @@<br>
   $ test -L largelink<br>
   $ cd ..<br>
<br>
+test for pattern matching on 'hg status':<br>
+to boost performance, largefiles checks whether specified patterns are<br>
+related to largefiles in working directory (NOT to STANDIN) or not.<br>
<br>
+  $ hg init statusmatch<br>
+  $ cd statusmatch<br>
+<br>
+  $ mkdir -p a/b/c/d<br>
+  $ echo normal > a/b/c/d/e.normal.txt<br>
+  $ hg add a/b/c/d/e.normal.txt<br>
+  $ echo large > a/b/c/d/e.large.txt<br>
+  $ hg add --large a/b/c/d/e.large.txt<br>
+  $ mkdir -p a/b/c/x<br>
+  $ echo normal > a/b/c/x/y.normal.txt<br>
+  $ hg add a/b/c/x/y.normal.txt<br>
+  $ hg commit -m 'add files'<br>
+  Invoking status precommit hook<br>
+  A a/b/c/d/e.large.txt<br>
+  A a/b/c/d/e.normal.txt<br>
+  A a/b/c/x/y.normal.txt<br>
+<br>
+(1) no pattern: no performance boost<br>
+  $ hg status -A<br>
+  C a/b/c/d/e.large.txt<br>
+  C a/b/c/d/e.normal.txt<br>
+  C a/b/c/x/y.normal.txt<br>
+<br>
+(2) pattern not related to largefiles: performance boost<br>
+  $ hg status -A a/b/c/x<br>
+  C a/b/c/x/y.normal.txt<br>
+<br>
+(3) pattern related to largefiles: no performance boost<br>
+  $ hg status -A a/b/c/d<br>
+  C a/b/c/d/e.large.txt<br>
+  C a/b/c/d/e.normal.txt<br>
+<br>
+(4) pattern related to STANDIN (not to largefiles): performance boost<br>
+  $ hg status -A .hglf/a<br>
+  C .hglf/a/b/c/d/e.large.txt<br>
+<br>
+(5) mixed case: no performance boost<br>
+  $ hg status -A a/b/c/x a/b/c/d<br>
+  C a/b/c/d/e.large.txt<br>
+  C a/b/c/d/e.normal.txt<br>
+  C a/b/c/x/y.normal.txt<br>
+<br>
+  $ cd ..<br>
_______________________________________________<br>
Mercurial-devel mailing list<br>
<a href="mailto:Mercurial-devel@selenic.com">Mercurial-devel@selenic.com</a><br>
<a href="http://selenic.com/mailman/listinfo/mercurial-devel" target="_blank">http://selenic.com/mailman/listinfo/mercurial-devel</a><br>
</blockquote></div><br><br clear="all"><br>-- <br><div><div><span style="color:rgb(153,153,153)"><b>Na'Tosha Bard</b></span></div><div><font color="#999999">Build & Infrastructure Developer | Unity Technologies - Copenhagen<br>
</font></div><div><font color="#999999"><br></font></div><div><font color="#999999"><b>E-Mail:</b> <a href="mailto:natosha@unity3d.com" target="_blank">natosha@unity3d.com</a></font></div><div><font color="#999999"><b>Skype:</b> natosha.bard</font></div>
</div><br>