Commit Graph

47 Commits

Author SHA1 Message Date
Siddharth Agarwal
cf3f4a0258 pack_dirstate: only invalidate mtime for files written in the last second
Previously we'd place files written in the last second in the lookup set. This
can lead to pathological cases where a file always remains in the lookup set if
it gets modified before the next time status is run.

With this patch, only the mtime of those files is invalidated. This means that
if a file's size or mode changes, we can immediately declare it as modified
without needing to compare file contents.
2013-08-17 20:48:49 -07:00
Shun-ichi GOTO
c8431c4292 osutil: consider WindowsError's behaviour to support python 2.4 on Windows
This change treat the ESRCH error as ENOENT like WindowsError class
does in python 2.5 or later. Without this change, some try..execpt
code which expects errno is ENOENT may fail. Actually hg command does
not work with python 2.4 on Windows.

CreateFile() will fail with error code ESRCH
when parent directory of specified path is not exist,
or ENOENT when parent directory exist but file is not exist.
Two errors are same in the mean of "file is not exist".
So WindowsError class treats error code ESRCH as ENOENT
in python 2.5 or later, but python 2.4 does not.

Actual results with python 2.4:
>>> errno.ENOENT
2
>>> errno.ESRCH
3
>>> WindowsError(3, 'msg').errno
3
>>> WindowsError(3, 'msg').args
(3, 'msg')

And with python 2.5 (or later):
>>> errno.ENOENT
2
>>> errno.ESRCH
3
>>> WindowsError(3, 'msg').errno
2
>>> WindowsError(3, 'msg').args
(3, 'msg')

Note that there is no need to fix osutil.c because it never be used
with python 2.4.
2013-07-12 11:14:42 +09:00
Mads Kiilerich
b7f720181a check-code: catch trailing space in comments 2013-04-15 01:37:23 +02:00
Siddharth Agarwal
9334236621 dirstate: move pure python dirstate packing to pure/parsers.py 2013-01-17 23:46:08 -08:00
Mads Kiilerich
48016eb3fc declare local constants instead of using magic values and comments 2012-08-27 23:16:22 +02:00
Mads Kiilerich
2372d51b68 fix wording and not-completely-trivial spelling errors and bad docstrings 2012-08-15 22:39:18 +02:00
Brodie Rao
a7ef0a0cc5 cleanup: "not x in y" -> "x not in y" 2012-05-12 16:00:57 +02:00
Brodie Rao
d6a6abf2b0 cleanup: eradicate long lines 2012-05-12 15:54:54 +02:00
Patrick Mezard
742f6b3850 pure/base85: align exception type/msg on base85.c
brendan mentioned on IRC that b64decode raises a TypeError too, but while the
previous exception type may be better in general, it is much easier to make it
behave like the related C code and changes nothing for mercurial itself.
2012-05-07 21:49:45 +02:00
Adrian Buehlmann
104162e2b1 pure/osutil: use Python's msvcrt module (issue3380)
As proposed by Christophe Gouiran <christophe.gouiran@eurocopter.com>
2012-04-19 17:08:12 +02:00
Steven Stallion
379dfc3a8c pure: quiesce build warnings
The following patch fixes the following warning when building pure:
package init file 'mercurial/pure/__init__.py' not found (or not a regular file)
2012-04-16 08:50:40 -07:00
Patrick Mezard
c4cef76e25 mdiff: replace wscleanup() regexps with C loops
On my system it reduces:

  hg annotate -w mercurial/commands.py

from 36s to less than 8s, to be compared with 6.3s when run without whitespace
options.
2011-11-18 14:23:03 +01:00
Martin Geisler
ff2f8288c9 merge with stable 2011-08-17 14:17:35 +02:00
Shun-ichi GOTO
dad35e5a06 win32: msvcr71.dll should be used for python 2.4 and 2.5
Following is list of C-Runtime for versions of CPython on windows:
 - python 2.4.5 => MSVCR71.dll
 - python 2.5.4 => MSVCR71.dll
 - python 2.6.6 => MSVCR90.dll
 - python 2.7   => MSVCR90.dll
 - python 3.1.2 => MSVCR90.dll
2011-08-08 14:32:27 +09:00
py4fun
194ff703d6 parsers: remove redundant 'n' variable in parsers.parse_index2() (issue2935) 2011-07-31 22:12:13 +02:00
Augie Fackler
14a08e5514 pure parsers: properly detect corrupt index files
This new Python code should be equivalent in behavior to the if
statement at line 312 of parsers.c. Without this, the pure-python
parsers improperly ignore truncated revlogs as created in
test-verify.t.
2011-05-24 13:30:10 -05:00
Adrian Buehlmann
8728d73db7 pure: provide more correct implementation of posixfile for Windows
requires ctypes

Why is posixfile a class?

Because the implementation needs to use the Python library call os.fdopen [1],
which sets the 'name' attribute on the Python file object it creates to the
mostly meaningless string '<fdopen>', since file descriptors don't have a name.

But users of posixfile depend on the name attribute [2] being set to a proper
value, like Python's built-in 'open' function sets it on file objects.

Python file's name attribute is read-only, so we can't just assign to it after
the file object has alrady been created.

To solve this problem, we save the name of the file on a wrapper object,
and delegate the file function calls to the wrapped (private) file object
using __getattr__.

[1] http://docs.python.org/library/os.html#os.fdopen
[2] http://docs.python.org/library/stdtypes.html#file.name
2011-05-18 09:12:27 +02:00
Dan Villiom Podlaski Christiansen
f5b77121bc pure bdiff: don't use a generator
Generators are slow, and currently defeat the PyPy JIT.
2011-04-30 15:05:36 +02:00
Dan Villiom Podlaski Christiansen
5ae771a2fc pure mpatch: avoid using list.insert(0, ...)
In Python lists are implemented as arrays with overallocation. As a
result, list.insert(0, ...) is O(n), whereas list.append() has an
amortised running time of O(1). Reversing the internal representation
of the list should cause a slight speedup for pure Python builds.
2011-04-30 15:05:34 +02:00
Alexander Solovyov
0eb3836642 remove unused imports and variables 2011-04-30 13:59:14 +02:00
Wagner Bruna
da9841899b pure: fix index parsing on empty repositories 2011-02-17 13:37:52 -02:00
Matt Mackall
3d98b5db9a pure: update index parsing 2011-01-12 13:54:39 -06:00
Matt Mackall
efaaee2894 revlog: remove lazy index 2011-01-04 14:12:52 -06:00
Brodie Rao
7362459729 cleanup: use x in (a, b) instead of x == a or x == b 2010-09-23 00:02:31 -05:00
Matt Mackall
f37d605b14 clean up remaining generic exceptions 2010-05-07 16:59:00 -05:00
Benoit Boissinot
3db7df2869 style: use consistent variable names (*mod) with imports which would shadow 2010-03-11 17:43:44 +01:00
Benoit Boissinot
e58438a035 fix test-mq-eol under --pure (mimic diffhelper.c behaviour)
bug discovered by apycot (apycot.hg-scm.org)
2010-02-26 16:52:43 +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
Alejandro Santos
77d606ac51 compat: use open() instead of file() everywhere 2009-07-05 11:01:30 +02:00
Alejandro Santos
3183e52503 compat: use // for integer division 2009-07-05 11:00:44 +02:00
Martin Geisler
5b4e5428df replace "i in range(len(xs))" with "i, x in enumerate(xs)"
The remaining occurrences should be the ones where "xs" is mutated or
where "i" is used for index arithmetic.
2009-05-26 22:59:52 +02:00
Sune Foldager
adc90b2605 posixfile: remove posixfile_nt and fix import bug in windows.py
The posixfile_nt class has been superseded by posixfile in osutils.c,
which works on Windows NT and above. All other systems get the regular
python file class which is assigned to posixfile in posix.py (for POSIX)
and in the pure python version of osutils.py (for Win 9x or Windows NT
in pure mode).
2009-05-13 21:36:16 +02:00
Martin Geisler
59adad78ff pure/osutil: add copyright and license header 2009-04-26 01:57:12 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Matt Mackall
019a0b138e pure/parsers: fix circular imports, import mercurial modules properly 2009-04-03 12:37:38 -05:00
Matt Mackall
c36ce7ba2b pure/bdiff: fix circular import 2009-04-03 12:37:30 -05:00
Dirkjan Ochtman
7b5b0945c3 kill another trailing space 2009-03-23 13:49:16 +01:00
Peter Arrenbrecht
bc21361ed2 cleanup: drop unused imports 2009-03-23 13:12:07 +01:00
Mads Kiilerich
e39fe5275e Optimization of pure.base85.b85encode
This makes pure python base85 encoding 3x faster than before. Now it is only
40x slower than the C version.
2009-03-04 23:23:59 +01:00
Martin Geisler
0c5c608631 pure/mpatch: use StringIO instead of mmap (issue1493)
This is more portable than memory mapping /dev/zero: Windows obviously
does not have /dev/zero and mapping /dev/zero failed on Mac OS X.
2009-02-16 00:09:47 +01:00
Martin Geisler
1c820b3f61 move mercurial.osutil to mercurial.pure.osutil 2009-01-24 00:13:49 +01:00
Martin Geisler
06c9d07d91 pure Python implementation of bdiff.c 2009-01-24 00:12:20 +01:00
Martin Geisler
acbc15eded pure Python implementation of diffhelpers.c 2009-01-24 00:12:19 +01:00
Brendan Cully
6cdf9dd11f Pure python base85 fallback
Encoding takes about 100x longer than native on a large binary.
2008-12-30 18:58:58 -08:00
Martin Geisler
00f6dbb2f7 pure Python implementation of parsers.c 2009-01-24 00:12:18 +01:00
Martin Geisler
203d953203 pure Python implementation of mpatch.c 2009-01-24 00:12:17 +01:00