Commit Graph

142 Commits

Author SHA1 Message Date
Yuya Nishihara
cd2add86f9 py3: iterate bytes as a byte string in store.lowerencode() 2017-09-03 17:28:47 +09:00
Yuya Nishihara
12ba8b8351 py3: use bytechr() in store._buildlowerencodefun() 2017-09-03 17:27:50 +09:00
Yuya Nishihara
1c1ae74c58 store: give name to lowerencode function
lambda function isn't easy to track in traceback.
2017-09-03 17:26:10 +09:00
Yuya Nishihara
21687d1395 doctest: do not embed non-ascii characters in docstring
Since the outer docstring is parsed as a unicode on Python 3, we have to
either double-escape or construct non-ascii string from ascii string.
2017-09-03 15:47:17 +09:00
Yuya Nishihara
a71f259bd2 doctest: bulk-replace string literals with b'' for Python 3
Our code transformer can't rewrite string literals in docstrings, and I
don't want to make the transformer more complex.
2017-09-03 14:32:11 +09:00
Yuya Nishihara
12efb6fc0b vfs: rename auditvfs to proxyvfs
Since we've removed mustaudit property, auditvfs has no auditing business.
It's just a utility class for vfs wrappers.
2017-07-07 23:40:00 +09:00
Yuya Nishihara
4563e16232 parsers: switch to policy importer
# no-check-commit
2016-08-13 12:23:56 +09:00
Augie Fackler
8c2dacbd98 store: fix many single-byte ops to use slicing in _auxencode 2017-03-12 00:50:44 -05:00
Yuya Nishihara
7c6e9b463e py3: factor out bytechr() function
I also changed xrange(127) to range(127) as the number is relatively small.
2017-03-08 22:30:12 +09:00
Pierre-Yves David
7658034ccd vfs: use 'vfs' module directly in 'mercurial.store'
Now that the 'vfs' classes moved in their own module, lets use the new module
directly. We update code iteratively to help with possible bisect needs in the
future.
2017-03-02 13:30:10 +01:00
Pulkit Goyal
e51666942e store: slice over a bytestring to get characters instead of ascii values
On Python 2,

>>> a = b'abc'
>>> a[1]
'b'

Whereas on python 3,

>>> a = b'abc'
>>> a[1]
98
>>> a[1:2]
b'b'

This does not change behaviour on python 2.
2017-03-08 00:40:15 +05:30
Pulkit Goyal
8146369713 py3: fix the way we produce bytes list in store.py
bytes(range(127)) does not produce a list whereas we need a list. This patch
fixes that.
2017-02-07 23:25:37 +05:30
Jun Wu
a41c076155 store: migrate to util.iterfile 2016-11-14 23:15:01 +00:00
Martijn Pieters
25a79def1c store: py26 compat, don't use a dict comprehension 2016-10-09 12:58:22 +02:00
Mateusz Kwapich
c9434eddcf py3: make encodefun in store.py compatible with py3k
This ensures that the filename encoding functions always map bytestrings
to bytestrings regardless of python version.
2016-10-08 08:54:05 -07:00
Mateusz Kwapich
411ad51cc8 py3: make the string unicode so its iterable in py3k 2016-10-08 08:45:28 -07:00
Augie Fackler
a829db2256 store: use hashlib.sha1 directly instead of through util
Also remove module-local alias to _sha, since it's not used that much.
2016-06-10 00:10:06 -04:00
timeless
d41c3c219d store: treat range as a generator instead of a list for py3 compat 2016-04-10 07:28:26 +00:00
Martin von Zweigbergk
e50c296659 treemanifests: fix streaming clone
Similar to the previous patch, the .hg/store/meta/ directory does not
get copied when when using "hg clone --uncompressed". Fix by including
"meta/" in store.datafiles(). This seems safe to do, as there are only
a few users of this method. "hg manifest" already filters the paths by
"data/" prefix. The calls from largefiles also seem safe. The use in
verify needs updating to prevent it from mistaking dirlogs for
orphaned filelogs. That change is included in this patch.

Since the dirlogs will now be in the fncache when using fncachestore,
let's also update debugrebuildfncache(). That will also allow any
existing treemanifest repos to get their dirlogs into the fncache.

Also update test-treemanifest.t to use an a directory name that
requires dot-encoding and uppercase-encoding so we test that the path
encoding works.
2016-02-04 08:34:07 -08:00
Martin von Zweigbergk
bb8190a058 treemanifests: fix local clone
When doing a local clone with treemanifests, the .hg/store/meta/
directory currently does not get copied. To fix it, all we need to do
is to add it to the list of directories to copy.
2016-02-02 17:31:17 -08:00
Gregory Szorc
dfef101207 store: use absolute_import 2015-12-21 21:19:57 -08:00
timeless@mozdev.org
716b455ed5 l10n: use %d instead of %s for numbers 2015-10-14 22:29:03 -04:00
Pierre-Yves David
30913031d4 error: get Abort from 'error' instead of 'util'
The home of 'Abort' is 'error' not 'util' however, a lot of code seems to be
confused about that and gives all the credit to 'util' instead of the
hardworking 'error'. In a spirit of equity, we break the cycle of injustice and
give back to 'error' the respect it deserves. And screw that 'util' poser.

For great justice.
2015-10-08 12:55:45 -07:00
Gregory Szorc
5380dea2a7 global: mass rewrite to use modern exception syntax
Python 2.6 introduced the "except type as instance" syntax, replacing
the "except type, instance" syntax that came before. Python 3 dropped
support for the latter syntax. Since we no longer support Python 2.4 or
2.5, we have no need to continue supporting the "except type, instance".

This patch mass rewrites the exception syntax to be Python 2.6+ and
Python 3 compatible.

This patch was produced by running `2to3 -f except -w -n .`.
2015-06-23 22:20:08 -07:00
Gregory Szorc
3aa1c73868 global: mass rewrite to use modern octal syntax
Python 2.6 introduced a new octal syntax: "0oXXX", replacing "0XXX". The
old syntax is not recognized in Python 3 and will result in a parse
error.

Mass rewrite all instances of the old octal syntax to the new syntax.

This patch was generated by `2to3 -f numliterals -w -n .` and the diff
was selectively recorded to exclude changes to "<N>l" syntax conversion,
which will be handled separately.
2015-06-23 22:30:33 -07:00
Martin von Zweigbergk
1acf6c029c treemanifest: store submanifest revlog per directory
With this change, when tree manifests are enabled (in .hg/requires),
commits will be written with one manifest revlog per directory. The
manifest revlogs are stored in
.hg/store/meta/$dir/00manifest.[id].

Flat manifests can still be read and interacted with as usual (they
are also read into treemanifest instances). The functionality for
writing treemanifest as a flat manifest to disk is still left in the
code; tests still pass with '_treeinmem=True' hardcoded.

Exchange is not yet implemented.
2015-04-13 23:21:02 -07:00
Adrian Buehlmann
3e5a964272 store: add comment in _hashencode with reason for skipping the first 5 chars 2015-05-13 20:36:56 +02:00
Martin von Zweigbergk
0bba8308de pathencode: for long paths, strip first 5 chars, not first dir
When encoding long paths, the pure Python code strips the first
directory from the path, while the native code currently strips the
first 5 characters. This discrepancy has not been a problem so far,
since we have not stored anything in directories other than
data/. However, we will soon be storing submanifest revlogs in
metadata/, so the discrepancy will have to go [1]. Since file
collisions are avoided by the hashing alone (which is done on the full
unencoded path), it doesn't really matter whether we drop the first
dir, the first 5 characters, or special-case non-data/. To avoid
touching the C code, let's always strip the first 5 characters.

 [1] Or maybe elsewhere, but the discrepancy is ugly either way.
2015-05-06 15:58:14 -07:00
Matt Mackall
9f82e04c09 store: drop unused existing list 2014-04-03 12:59:12 -05:00
Durham Goode
3075ab82ec fncache: clean up fncache during strips
Previously the fncache was cleaned up at read time by noticing when it was out
of sync. This caused writes to happen outside the scope of transactions and
could have caused race conditions. With this change, we'll keep the fncache
up-to-date as we go by removing old entries during repair.strip.
2014-03-24 15:43:15 -07:00
Durham Goode
b9e3b76bea caches: invalidate store caches when lock is taken
The fncache was not being properly invalidated each time the lock was taken, so
in theory it could contain old data from prior to the caller having the lock.
This changes it to be invalidated as soon as the lock is taken (same as all our
other caches).
2014-03-24 15:35:07 -07:00
Durham Goode
950d3b4dd3 fncache: move fncache writing to be in a transaction
Previously the fncache was written at lock.release time. This meant it was not
tracked by a transaction, and if an error occurred during the fncache write it
would fail to update the fncache, but would not rollback the transaction,
resulting in an fncache that was not in sync with the files on disk (which
causes verify to fail, and causes streaming clones to not copy all the revlogs).

This uses the new transaction backup mechanism to make the fncache transacted.
It also moves the fncache from being written at lock.release time, to being
written at transaction.close time.
2014-03-24 15:42:13 -07:00
Durham Goode
2f98d8b12a fncache: remove the rewriting logic
The fncache could rewrite itself during a read operation if it noticed any
entries that were no longer on disk. This was problematic because it caused
Mercurial to perform write operations outside the scope of a lock or
transaction, which could interefere with any other pending writes.

This will be replaced in a future patch by logic that cleans up the fncache
as files are deleted during strips.
2014-03-24 15:31:47 -07:00
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