Commit Graph

109 Commits

Author SHA1 Message Date
FUJIWARA Katsunori
0b2abf8689 store: use "vfs.exists()" instead of "os.path.exists()" 2013-10-15 00:51:05 +09:00
Durham Goode
407a7da938 store: move top file walk to a separate function
Some extensions find it useful to be able to walk the non-data files in the
repo, so I'm moving that part of the walk to a separate function.

In particular, this allows an extension to interact with only the non-filelog
store data (for instance, when cloning everything but filelogs).
2013-05-08 14:22:00 -07:00
Bryan O'Sullivan
c4e1eeb2a3 store: switch to C-based hashed path encoding 2012-12-12 13:09:37 -08:00
Bryan O'Sullivan
dea2c50032 store: implement lowerencode in C 2012-12-12 13:09:33 -08:00
Mads Kiilerich
ac8e1fc147 check-code: there must also be whitespace between ')' and operator
The check pattern only checked for whitespace between keyword and operator.

Now it also warns:
 >     x = f(),7
 missing whitespace after ,
 >     x = f()+7
 missing whitespace in expression
2012-12-09 23:33:16 +01:00
Bryan O'Sullivan
b59090c617 scmutil: abstract out mustaudit delegation 2012-10-22 11:59:11 -07:00
Adrian Buehlmann
ac772dd620 store: fncache may contain non-existent entries (fixes e76e2e89c766) 2012-10-12 10:52:33 +02:00
Adrian Buehlmann
637c55b9a8 store: add new _exists helper function on fncachestore 2012-10-12 10:52:32 +02:00
Adrian Buehlmann
f86ce05929 store: move __contains__() implementation from class fncache into fncachestore
This restores the previous semantics of fncache.__contains__().

(a followup to e76e2e89c766)
2012-10-12 10:40:09 +02:00
FUJIWARA Katsunori
bcd74985e5 store: invoke "osutil.listdir()" via vfs
This patch invokes "osutil.listdir()" via vfs object.

The function added newly to "abstractvfs" is named not as "listdir()"
but as "readdir()", because:

  - "os.listdir()" seems to be more familiar as "listdir()" than
    "osutil.listdir()"

  - "osutil.listdir()" returns also type of each files like
    "readdir()" POSIX API: even though "d_type" field of "dirent"
    structure is defined mainly only on BSD/Linux

This patch invokes "osutil.listdir()" via "rawvfs" object to avoid
filename encoding, because the path passed to "osutil.listdir()"
shouldn't be encoded.

This patch also omits importing "osutil" module, because it is no
longer used.
2012-10-09 16:17:55 +09:00
smuralid
ef33964734 store: add a contains method to fncachestore
Adds a __contains__ method to fncachestore to check for file/dir existence (using fncache.__contains__).
Also extends fncache.__contains__ to check for directories (by prefix matching)
2012-09-13 17:57:43 -07:00
smuralid
49e0e33106 store: add a contains method to basicstore
Adds a __contains__ method to basicstore that checks if a file/dir is present in the store
2012-09-13 17:00:34 -07:00
Mads Kiilerich
588e53b65c spelling: fix minor spell checker issues 2012-10-10 01:29:56 +02:00
Matt Mackall
1fc6275c72 store: restore getsize method
This method was created for subclassing.
2012-10-08 16:46:11 -05:00
FUJIWARA Katsunori
adaaef3263 store: invoke "os.path.isdir()" via vfs
This patch invokes "os.path.isdir()" via "rawvfs" object to avoid
filename encoding, because the path passed to "os.path.isdir()"
shouldn't be encoded.

This patch newly adds "self.rawvfs" field only to "basicstore" and
"encodedstore", because "fncachestore" has "self.rawvfs" already.
2012-10-09 01:41:55 +09:00
FUJIWARA Katsunori
e94a854ac3 store: replace invocation of "getsize()" by "vfs.stat()"
This patch replaces invocation of "getsize()", which calls "os.stat()"
internally, by "vfs.stat()".

The object referred by "self.rawvfs" is used internally by
"_fncachevfs" and doesn't encode filename for each file API invocation.

This patch invokes "os.stat()" via "self.rawvfs" to avoid redundant
filename encoding: invocation of "os.stat()" via "self.vfs" hides
filename encoding and encoding result from caller, so it is not
appropriate, when both encoded and non-encoded filenames should be
yield.

Even though changeset 89eacc6262af improved stream_out performance by
"self.pathsep + path", this patch replaces it by
"os.path.join(self.base, path)" of vfs. So, this may increase cost to
join path components.

But this shouldn't have large impact, because:

  - such cost is much less than cost of "os.stat()" which causes
    system call invocation

  - "datafiles()" of store object is invoked only for "hg manifest
    --all" or "hg verify" which are both heavy functions
2012-10-09 01:41:55 +09:00
FUJIWARA Katsunori
e100683d0e store: invoke "os.stat()" for "createmode" initialization via vfs
This just replaces "os.stat()" invocation: refactoring around
"self.createmode" and "vfs.createmode" initialization is omitted.

This patch also newly adds "stat()" function to "abstractvfs".
2012-10-09 01:41:55 +09:00
FUJIWARA Katsunori
f503d56231 vfs: define "join()" in each classes derived from "abstractvfs"
This patch defines "join()" in each classes derived from "abstractvfs"
except "vfs", which already defines it.

This allows all vfs instances to be used for indirect file API
invocation.
2012-10-09 01:41:55 +09:00
FUJIWARA Katsunori
2e01d06780 store: initialize vfs field first to use it for initialization of others
This patch initializes "vfs" field in the constructor of each store
classes to use it for initialization of others.

In this patch, "self.vfs.base" is used to initialize "self.path",
because redo join of path components for "self.path" is redundant.
2012-10-09 01:41:55 +09:00
FUJIWARA Katsunori
92325ab8e2 store: rename field name from "opener" to "vfs" in internal classes for fncache
These fields are used only in store module, so keeping "self.opener"
for backward compatibility like as "localrepository" class is not
needed.
2012-10-09 01:41:55 +09:00
FUJIWARA Katsunori
5a20ad61ef store: rename argument name from "op"(ener) to "vfs" 2012-10-09 01:41:55 +09:00
Adrian Buehlmann
14553ab848 store: optimize _pathencode by checking the length of the unencoded path
If the input path is already longer than _maxstorepathlen, then we can skip
doing the basic encoding (encodedir, _encodefname and _auxencode) and directly
proceed to the hashed encoding. Those encodings, if at all, will make the path
only longer.
2012-09-30 23:53:56 +02:00
FUJIWARA Katsunori
405ef27bab store: initialize "vfs" fields by "vfs" constructors
For backwards compatibility, "opener" fields are still left as aliases
for "vfs" ones.
2012-08-31 02:06:29 +09:00
FUJIWARA Katsunori
076ab3b9e8 store: rename "op" variables to "vfs" 2012-08-31 02:06:29 +09:00
FUJIWARA Katsunori
afccfdd4e0 store: rename "openertype" argument to "vfstype" 2012-08-31 02:06:29 +09:00
FUJIWARA Katsunori
97278fdfa7 scmutil: rename classes from "opener" to "vfs"
For backwards compatibility, aliases for the old names are added,
except for "abstractopener", "statichttpopener" and "_fncacheopener",
because these are not used in Mercurial core implementation after this
patch.

"_fncacheopener" was only referred in "fncachestore" constructor, so
this patch also renames from "_fncacheopener" to "_fncachevfs" there.
2012-08-31 02:06:29 +09:00
Adrian Buehlmann
666b8531e6 store: add a fallback _pathencode Python function
which does the equivalent of parsers.pathencode, so it can be used as a
default
2012-09-19 14:00:23 +02:00
Adrian Buehlmann
976f01af3f store: move _plainhybridencode and _dothybridencode higher up in the file
no functional change
2012-09-19 13:58:51 +02:00
Adrian Buehlmann
114ea39f3e store: fix _hashencode call in _dothybridencode
Fixes b9ebea2d1672
2012-09-19 11:39:07 +02:00
Bryan O'Sullivan
c85d8166d1 store: use native fncache encoding function if available
This currently falls back to Python for hashed encoding.
2012-09-18 16:25:20 -07:00
Bryan O'Sullivan
024c511c7b store: refactor hashed encoding into its own function 2012-09-18 14:37:32 -07:00
Adrian Buehlmann
fc4c657eab store: reuse direncoded path in _hybridencode
For a netbeans clone on Windows 7 x64:

  Before:
    $ hg perffncacheencode
    ! wall 3.516000 comb 3.525623 user 3.525623 sys 0.000000 (best of 3)

  After:
    $ hg perffncacheencode
    ! wall 3.443000 comb 3.447622 user 3.447622 sys 0.000000 (best of 3)
2012-09-18 19:51:59 +02:00
Adrian Buehlmann
6935b60c2a store: extract functions _encodefname and _decodefname 2012-09-18 19:51:48 +02:00
Adrian Buehlmann
6123a70068 store: use fast C implementation of encodedir() if it's available
For a netbeans clone on Windows 7 x64:

  Encoding all paths in the fncache:

    Before:
      $ hg perffncacheencode
      ! wall 3.639000 comb 3.634823 user 3.634823 sys 0.000000 (best of 3)
    After:
      $ hg perffncacheencode
      ! wall 3.470000 comb 3.463222 user 3.463222 sys 0.000000 (best of 3)

  Writing fncache:

    Before:
      $ hg perffncachewrite
      ! wall 0.103000 comb 0.093601 user 0.093601 sys 0.000000 (best of 95)
    After:
      $ hg perffncachewrite
      ! wall 0.081000 comb 0.078001 user 0.062400 sys 0.015600 (best of 100)
2012-09-18 11:44:16 +02:00
Adrian Buehlmann
2dfd0c409a store: add multiline doctest case for encodedir()
a followup to 7090b12b599b
2012-09-18 07:58:50 +02:00
Adrian Buehlmann
7bf349fd77 store: optimize fncache._load a bit by dirdecoding the contents in one go
For a netbeans clone on Windows 7 x64:

  Before:
    $ hg perffncacheload
    ! wall 0.124000 comb 0.124801 user 0.124801 sys 0.000000 (best of 76)

  After:
    $ hg perffncacheload
    ! wall 0.096000 comb 0.093601 user 0.078001 sys 0.015600 (best of 97)
2012-09-17 11:00:38 +02:00
Adrian Buehlmann
039dd48b84 store: optimize fncache._write by direncoding the contents in one go
For a netbeans clone on Windows 7 x64:

  Before:
    $ hg perffncachewrite
    ! wall 0.210000 comb 0.218401 user 0.202801 sys 0.015600 (best of 47)

  After:
    $ hg perffncachewrite
    ! wall 0.104000 comb 0.109201 user 0.078000 sys 0.031200 (best of 95)
2012-09-17 08:58:35 +02:00
Adrian Buehlmann
c239e1837f store: move encode lambda logic into fncachestore
and define two named functions at module scope.

This again also speeds up perffncacheencode a little bit.
2012-09-16 11:41:02 +02:00
Adrian Buehlmann
e773964ca6 store: eliminate one level of lambda functions on _hybridencode 2012-09-16 11:36:14 +02:00
Adrian Buehlmann
bbb1196b99 store: parameter path of _auxencode is now a list of strings 2012-09-16 11:36:06 +02:00
Adrian Buehlmann
55185b8e33 store: keep an accumulated length for the shorted dirs in _hybridencode
so we don't have to repeatedly do  '/'.join(sdirs)  inside the loop
2012-09-16 11:36:00 +02:00
Adrian Buehlmann
1184227af0 store: reorder basename assignment in _hybridencode 2012-09-16 11:35:55 +02:00
Adrian Buehlmann
40f2dc614d store: remove uneeded startswith('data/') checks in encodedir() and decodedir()
I don't think we will ever have anything in the store that resides inside a
directory that ends in .i or .d under store/ that we wouldn't want to have
direncoded. The files not under data/ surely don't need direncoding, but it
doesn't harm to let these few run through it. It hurts more to check whether the
thousands of other files start with 'data/'. They do anyway.

See also 67e6074ba430 (fixed with 0c522fe42894), which moved the direncoding
from filelog into store
2012-09-15 21:44:08 +02:00
Adrian Buehlmann
574c96ecb1 store: remove uneeded startswith('data/') check in _hybridencode() 2012-09-15 21:43:56 +02:00
Adrian Buehlmann
5b06fb5a39 store: refactor splitting off of "data/" in _hybridencode()
encodefilename() already calls encodedir(). Note that encodedir() skips the
encoding if the path doesn't start with "data/".
2012-09-15 21:43:14 +02:00
Adrian Buehlmann
007324cd1e store: let _auxencode() return the list of path segments
so we can spare us splitting the path again in _hybridencode()
2012-09-15 21:43:05 +02:00
Adrian Buehlmann
95efee1bf9 store: eliminate unneded last assignment to n in _auxencode()
The check for period or space at the end of the string is the last one, the
local variable n is thus not used anymore.
2012-09-15 21:42:58 +02:00
Adrian Buehlmann
d900f301da store: unindent most of the contents of the for loop in _auxencode()
by refactoring

    for i, n in enumerate(res):
        if n:
            <main code block>

to

    for i, n in enumerate(res):
        if not n:
            continue
        <main code block>

(no functional change)
2012-09-15 21:42:52 +02:00
Adrian Buehlmann
77d1f7ae29 store: optimize _auxencode() by assigning to the list elements of the path 2012-09-15 21:42:43 +02:00
Adrian Buehlmann
c774df44ee store: optimze _auxencode() a bit by grouping the reserved names by length
This reduces perffncacheencode wall time on Windows 7 x64 for my netbeans clone
here from 4.3 to 4.0 (7% faster).
2012-09-15 21:41:09 +02:00