Commit Graph

81 Commits

Author SHA1 Message Date
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
Adrian Buehlmann
8149bc6545 store: explain "aux.foo" versus "foo.aux" in doc of _auxencode() 2012-09-15 21:41:53 +02:00
Adrian Buehlmann
93e8048296 store: add 'com0' and 'lpt0' doctest cases for _auxencode()
These are already covered by test-hybridencode.py, but they are so noteworthy
that I think they deserve being shown right in that doctest.
2012-09-15 21:41:45 +02:00
Bryan O'Sullivan
b5119e949d store: reduce string concatenation when joining
This improves stream_out performance by a couple of percent.
2012-09-14 12:09:05 -07:00
Bryan O'Sullivan
ecc7d720f1 scmutil: delegate mustaudit property to the real opener
This will be used by an upcoming patch.
2012-09-14 12:04:46 -07:00
Bryan O'Sullivan
14c8cfede7 store: only one kind of OSError means "nonexistent entry" 2012-08-15 16:31:25 -07:00
Bryan O'Sullivan
d5c4b2870d store: sort the results of fncachestore.datafiles() 2012-08-15 16:30:32 -07:00
Pierre-Yves.David@ens-lyon.org
08abbc7fb2 clone: copy obsolete markers during local clone
This change adds `obsstore` to the list of files copied by local clone,
until now changesets were copied without their obsolete markers.

Note: extinct changesets were and are still included by such clones to
enable hardlinking. There is no obvious reason to prevent their exchange
here.

Rebased by Patrick Mezard <patrick@mezard.eu>
2012-07-25 19:02:35 +02:00
Bryan O'Sullivan
9c4291ed97 store: abstract out how we retrieve a file's size 2012-06-25 15:14:06 -07:00
Bryan O'Sullivan
47b1cf0c50 store: sort filenames in place 2012-06-25 15:14:05 -07:00
Bryan O'Sullivan
1672ae6377 store: speed up read and write of large fncache files
In my tests of an fncache containing 300,000 entries, this improves
read time from 567ms to 307, and write time from 1328ms to 533.

These numbers aren't so great, since the fncache file is only 17MB
in size, but they're an improvement.
2012-04-12 15:21:54 -07:00
Pierre-Yves David
7e4f710bf6 phases: prevent rebase to rebase immutable changeset. 2011-12-27 00:11:22 +01:00
Pierre-Yves David
4c85722ec4 phases: copy phases data on local clone 2011-12-26 13:47:37 +01:00
Greg Ward
bc1dfb1ac9 atomictempfile: make close() consistent with other file-like objects.
The usual contract is that close() makes your writes permanent, so
atomictempfile's use of close() to *discard* writes (and rename() to
keep them) is rather unexpected. Thus, change it so close() makes
things permanent and add a new discard() method to throw them away.
discard() is only used internally, in __del__(), to ensure that writes
are discarded when an atomictempfile object goes out of scope.

I audited mercurial.*, hgext.*, and ~80 third-party extensions, and
found no one using the existing semantics of close() to discard
writes, so this should be safe.
2011-08-25 20:21:04 -04:00
Adrian Buehlmann
2a166c5eb3 store: change names to comply with project coding standards
as stated at http://mercurial.selenic.com/wiki/CodingStyle
(see also http://selenic.com/pipermail/mercurial-devel/2011-May/031139.html )

name changes done at module scope:

  _build_lower_encodefun      -> _buildlowerencodefun
  _windows_reserved_filenames -> _winreservednames      (see 42a6bcfc9d44)
  MAX_PATH_LEN_IN_HGSTORE     -> _maxstorepathlen
  DIR_PREFIX_LEN              -> _dirprefixlen
  _MAX_SHORTENED_DIRS_LEN     -> _maxshortdirslen

  (no users of these outside the store module)

changed locals:

  win_reserved  -> winreserved
  space_left    -> spaceleft
2011-05-08 23:27:48 +02:00
Adrian Buehlmann
f6cb5815f6 store: break up reference cycle introduced in e11fd6385080
see also 5ec0a41ce2c5
2011-05-04 12:58:59 +02:00
Dan Villiom Podlaski Christiansen
557e7a0a5a store: use a subclass, not a function for fncacheopener 2011-05-02 09:11:35 +02:00
Dan Villiom Podlaski Christiansen
17cec00272 store: rename the 'opener' argument to 'openertype'
The 'opener' argument wasn't, in fact, an actual opener instance, but
rather something expected to return an opener. The normal argument,
from localrepository, is the scmutil.opener type; hence 'openertype'.
2011-04-30 19:36:48 +02:00
Dan Villiom Podlaski Christiansen
9b9141450f add filteropener abstraction for store openers 2011-04-30 19:37:13 +02:00
Adrian Buehlmann
d3fe813516 store: add some doctests 2011-04-17 17:55:34 +02:00
Adrian Buehlmann
82c4b3eebe store: remove pointless pathjoiner parameter
We can stop pretending that we have to support anything else
than '/' for concatenating path elements anywhere.

Windows deals just fine with '/' in file paths and we already
have plenty of places which produce paths containing '/'
anyway when running on Windows.
2011-02-16 15:02:30 +01:00
Adrian Buehlmann
35765bcb3b fncachestore: defer updating the fncache file to a single file open
Defers updating the fncache file with newly added entries to the end of
the transaction (on e.g. pull), doing a single open call on the fncache
file, instead of opening and closing it each time a new entry is added
to the store.

Implemented by adding a new abstract write() function on store.basicstore
and registering it as a release function on the store lock in
localrepo.lock (compare with dirstate.write).

store.fncachestore overrides write() from basicstore and calls a new
write function on the fncache object, which writes all entries to the
fncache file if it's dirty.

store.fncache.add() now just marks itself as dirty if a new name is added.
2011-01-28 13:38:34 +01:00
Adrian Buehlmann
9638578b5c fncachestore: copy dh directory before the manifest
Before this patch, the copy order on clone was:

  requires
  00changelog.i
  store\data
  store\00manifest.d
  store\00manifest.i
  store\00changelog.d
  store\00changelog.i
  store\dh
  store\fncache

Which provides a theoretical non-zero probability of a race during clone where
a very early reader might see a repository with missing revlog files if it sees
00changelog.i before all files inside dh have been copied.

The dh directory is similar to the data directory -- just for files with long
names (which are hashed). The manifest refers to files in data *and* dh, so dh
should be copied before the manifest.

This patch improves the copy order to:

  requires
  00changelog.i
  store\data
  store\dh
  store\fncache
  store\00manifest.d
  store\00manifest.i
  store\00changelog.d
  store\00changelog.i

I'm putting fncache to before the manifest while I'm at it, since fncache
provides a mechanism to enumerate all repository files without visiting the
manifest revisions. fncache depends only on data and dh.

Note that data must be copied first, since copying data triggers the creation
of the repository write lock in the destination repo (see hg.clone).
2010-12-17 10:40:26 +01:00
Adrian Buehlmann
04f7530508 store: encode first period or space in filenames (issue1713)
- Mac OS X has problems with filenames starting with '._'
  (e.g. '.FOO' -> '._f_o_o' is now encoded as '~2e_f_o_o')

- Explorer of Windows Vista and Windows 7 strip leading spaces of
  path elements of filenames when copying trees

Above problems are avoided by encoding the first space (as '~20') or
period (as '~2e') of all path elements.

This introduces a new entry 'dotencode' in .hg/requires, that is,
a new repository filename layout (inside .hg/store).

Newly created repositories require 'dotencode' by default. Specifying

  [format]
  dotencode = False

in a config file will use the old format instead.

Prior Mercurial versions will abort with the message

   abort: requirement 'dotencode' not supported!

when trying to access a local repository that requires 'dotencode'.

New 'dotencode' repositories can be converted to the previous
repository format with

  hg --config format.dotencode=0 clone --pull repoA repoB
2010-10-09 21:54:50 +02:00
Thomas Arendsen Hein
e21e9414bc store: Removed extra space in _data list 2010-09-05 21:00:04 +02:00
Nicolas Dumazet
d7e4800c8b store: skip decodir check if path does not contain '.hg/'
The three replace calls are slower than this simple __contains__,
and anyway we should not have this many paths ending with .i, .d, or .hg
compared to the normal, un-encoded other paths.
2010-08-12 16:45:47 +09:00
Adrian Buehlmann
48a03e4f27 store: only add new entries to the fncache file
Newly added fncache entries were not added to the in-memory cache,
making it possible for 'hg convert' to cause duplicates in
.hg/store/fncache.

Duplicates in the fncache file are harmless, but excessive numbers
of duplicates from large converted repositories may slow down
execution speed considerably.
2010-03-03 14:50:35 +01:00
Benoit Boissinot
4371f512b2 fix spaces/identation issues 2010-02-05 18:50:08 +01:00
Matt Mackall
8d99be19f0 many, many trivial check-code fixups 2010-01-25 00:05:27 -06:00