Commit Graph

46 Commits

Author SHA1 Message Date
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
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Simon Heimberg
3c5d74607b store: eliminate reference cycle in fncachestore
no reference to self in fncacheopener
Inspired by Adrian Buehlmann
2009-07-14 14:05:07 +02:00
Benoit Boissinot
125a85ec87 use new style classes 2009-06-10 15:10:21 +02:00
Benoit Boissinot
d81f680b31 store encoding: .i/.d encoding for non-store repo (broken by 67e6074ba430) 2009-05-26 23:49:53 +02:00
Benoit Boissinot
5b1d4a56ec filelog encoding: move the encoding/decoding into store
the escaping of directories ending with .i or .d doesn't
really belong to filelog.

we put the encoding/decoding in store instead, for backwards
compat, streamclone and the fncache file format still uses the
partially encoded filenames.
2009-05-20 18:35:47 +02:00
Benoit Boissinot
ee58830640 store: refactor the fncache handling
put all the fncache file writing and reading in
the same place.
2009-05-20 18:35:41 +02:00
Martin Geisler
f7fa8ce35f store: create set directly from iterable 2009-05-17 16:56:20 +02:00
Benoit Boissinot
3f0d683495 store: use set instead of dict 2009-05-17 04:16:44 +02:00
Simon Heimberg
09ac1e6c92 separate import lines from mercurial and general python modules 2009-04-28 17:40:46 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Matt Mackall
f6c8930392 replace various uses of list.reverse() 2009-04-26 16:50:44 -05:00
Matt Mackall
2f9b02c62d replace util.sort with sorted built-in
This is marginally faster for small and moderately-sized lists
2009-04-26 16:50:44 -05:00
Matt Mackall
0952760f82 util: split out posix, windows, and win32 modules 2009-03-26 13:54:44 -05:00
Adrian Buehlmann
b2991e8893 store: encode trailing period and space on directory names (issue1417)
Windows won't create directories with names ending in period or space, so
we encode the last period/space character in directory names of non-hashed
paths in the store using reversible ~xx encoding (' ' -> '~20', '.' -> '~2e').

With this change it is possible to remove a directory ending in period or space
that was inadvertantly checked in on a linux system while still being able
to clone such a repository with its full history to Windows (see also issue793).
2008-12-13 18:32:29 +01:00
Adrian Buehlmann
9a0526b2cd store: don't create dirs ending in period or space for hashed paths (issue1417)
Windows won't create directories with names ending in period or space, so
we replace the last period/space character in truncated directory names of
hashed paths with some other character (underbar).
2008-12-13 17:39:56 +01:00
Benoit Boissinot
ea7fe6dacc remove unused variables 2008-10-28 19:25:26 +01:00
Thomas Arendsen Hein
912f59bb30 Remove trailing spaces. 2008-10-24 15:00:40 +02:00
Adrian Buehlmann
f3f0f9ecd6 introduce fncache repository layout
* adds a new entry 'fncache' to '.hg/requires' for new repos
* writes new file '.hg/store/fncache'
* hash-encodes filenames with long paths (issue839)
* encodes Windows reserved filenames (issue793)
2008-10-19 19:12:07 +02:00
Patrick Mezard
f6efcddc6c store: pathjoiner default value is os.path.join 2008-09-05 11:00:07 +02:00
Adrian Buehlmann
d71509e706 Fix for Issue1260 2008-08-31 00:22:20 +02:00
Matt Mackall
3bf58ba630 clone: get a list of files to clone from store 2008-08-13 20:18:44 -05:00
Matt Mackall
e691d8e8b0 store: drop self.encodefn 2008-08-13 20:18:44 -05:00
Matt Mackall
2793481364 store: change handling of decoding errors 2008-08-13 20:18:43 -05:00
Matt Mackall
dc1f28752b store: simplify walking
- fold in main walking function
- eliminate recursion (especially recursive yielding!)
- eliminate default args
2008-08-13 20:18:43 -05:00
Matt Mackall
9b20862a98 store: simplify class hierarchy 2008-08-13 20:18:43 -05:00
Matt Mackall
eac969c591 statichttp: use store class
This lets us nix store.encodefn.
2008-08-13 20:18:43 -05:00
Matt Mackall
7e9e494932 store: take opener as an argument 2008-08-13 20:18:42 -05:00
Adrian Buehlmann
a318975eaf verify: check repo.store 2008-08-13 20:18:41 -05:00
Adrian Buehlmann
0d98c22169 store.py: accept empty repos
Fixes a traceback on the server side when trying to streamclone
an empty repo (this was *not* introduced by 6590bef21ba3).
2008-08-13 20:18:41 -05:00
Adrian Buehlmann
904617b7d8 introduce store classes
move store walking from streamclone.py into store.py
2008-07-24 16:32:52 +02:00
Adrian Buehlmann
34afc460b4 move filename encoding functions from util.py to new store.py 2008-07-24 16:32:51 +02:00