Mercurial > hg
changeset 16110:41417443b7d0 stable
largefiles: check whether specified patterns are related to largefiles strictly
current 'lfiles_repo.status()' implementation examines whether
specified patterns are related to largefiles in working directory (not
to STANDIN) or not by NOT-EMPTY-NESS of below list:
[f for f in match.files() if f in lfdirstate]
but it can not be assumed that all in 'match.files()' are file itself
exactly, because user may only specify part of path to match whole
under subdirectories recursively.
above examination will mis-recognize such pattern as 'not related to
largefiles', and executes normal 'status()' procedure. so, 'hg status'
shows '?'(unknown) status for largefiles in working directory unexpectedly.
this patch examines relation of pattern to largefiles by applying
'match()' on each entries in lfdirstate and checking wheter there is
no matched entry.
it may increase cost of examination, because it causes of full scan of
entries in lfdirstate.
so this patch uses normal for-loop instead of list comprehensions, to
decrease cost when matching is found.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 15 Feb 2012 23:01:09 +0900 |
parents | f7e0d95d0a0b |
children | 131d1a09108a |
files | hgext/largefiles/reposetup.py tests/test-largefiles.t |
diffstat | 2 files changed, 50 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/reposetup.py Fri Feb 10 16:52:32 2012 -0600 +++ b/hgext/largefiles/reposetup.py Wed Feb 15 23:01:09 2012 +0900 @@ -118,8 +118,10 @@ # handle it -- thus gaining a big performance boost. lfdirstate = lfutil.openlfdirstate(ui, self) if match.files() and not match.anypats(): - matchedfiles = [f for f in match.files() if f in lfdirstate] - if not matchedfiles: + for f in lfdirstate: + if match(f): + break + else: return super(lfiles_repo, self).status(node1, node2, match, listignored, listclean, listunknown, listsubrepos)
--- a/tests/test-largefiles.t Fri Feb 10 16:52:32 2012 -0600 +++ b/tests/test-largefiles.t Wed Feb 15 23:01:09 2012 +0900 @@ -948,4 +948,50 @@ $ test -L largelink $ cd .. +test for pattern matching on 'hg status': +to boost performance, largefiles checks whether specified patterns are +related to largefiles in working directory (NOT to STANDIN) or not. + $ hg init statusmatch + $ cd statusmatch + + $ mkdir -p a/b/c/d + $ echo normal > a/b/c/d/e.normal.txt + $ hg add a/b/c/d/e.normal.txt + $ echo large > a/b/c/d/e.large.txt + $ hg add --large a/b/c/d/e.large.txt + $ mkdir -p a/b/c/x + $ echo normal > a/b/c/x/y.normal.txt + $ hg add a/b/c/x/y.normal.txt + $ hg commit -m 'add files' + Invoking status precommit hook + A a/b/c/d/e.large.txt + A a/b/c/d/e.normal.txt + A a/b/c/x/y.normal.txt + +(1) no pattern: no performance boost + $ hg status -A + C a/b/c/d/e.large.txt + C a/b/c/d/e.normal.txt + C a/b/c/x/y.normal.txt + +(2) pattern not related to largefiles: performance boost + $ hg status -A a/b/c/x + C a/b/c/x/y.normal.txt + +(3) pattern related to largefiles: no performance boost + $ hg status -A a/b/c/d + C a/b/c/d/e.large.txt + C a/b/c/d/e.normal.txt + +(4) pattern related to STANDIN (not to largefiles): performance boost + $ hg status -A .hglf/a + C .hglf/a/b/c/d/e.large.txt + +(5) mixed case: no performance boost + $ hg status -A a/b/c/x a/b/c/d + C a/b/c/d/e.large.txt + C a/b/c/d/e.normal.txt + C a/b/c/x/y.normal.txt + + $ cd ..