Jun Wu
2ae56b14de
codemod: use pycompat.iswindows
...
This is done by:
sed -i "s/pycompat\.osname == 'nt'/pycompat.iswindows/" **/*.py
sed -i "s/pycompat\.osname != 'nt'/not pycompat.iswindows/" **/*.py
sed -i 's/pycompat.osname == "nt"/pycompat.iswindows/' **/*.py
Differential Revision: https://phab.mercurial-scm.org/D1034
2017-10-12 23:30:46 -07:00
Alex Gaynor
dd422bc1d6
style: never put multiple statements on one line
...
Differential Revision: https://phab.mercurial-scm.org/D905
2017-09-29 15:49:20 +00:00
Alex Gaynor
3f0d5f185a
style: always use x is not None
instead of not x is None
...
Differential Revision: https://phab.mercurial-scm.org/D842
2017-09-29 15:49:43 +00:00
Yuya Nishihara
0284e70ec0
py3: use 'surrogatepass' error handler to process U+DCxx transparently
...
It's disallowed by default on Python 3.
https://docs.python.org/3/library/codecs.html#error-handlers
2017-09-16 22:55:48 +09:00
Yuya Nishihara
cab88e001f
py3: don't pass bytes to array.array()
2017-09-16 22:42:19 +09:00
Yuya Nishihara
a22ffac20b
encoding: add function to test if a str consists of ASCII characters
...
Most strings are ASCII. Let's optimize for it.
Using uint64_t is slightly faster than uint32_t on 64bit system, but there
isn't huge difference.
2017-04-23 12:59:42 +09:00
Yuya Nishihara
961b46e864
encoding: extract stub for fast JSON escape
...
This moves JSON character maps to pure/charencode.py because they will be
used only when the fast-path fails.
2017-04-23 16:10:51 +09:00
Yuya Nishihara
854edbfe8b
encoding: drop circular import by proxying through '<policy>.charencode'
...
I decided not to split charencode.c to new C extension module because it
would duplicate binary codes unnecessarily.
2017-07-31 23:13:47 +09:00
Yuya Nishihara
720bf3b0d8
cffi: split modules from pure
...
The copyright lines are updated per change history.
cffi/osutil.py isn't tested since I have no access to OS X machine right now,
sorry.
2017-05-02 21:15:31 +09:00
Yuya Nishihara
fa3c51ef73
cffi: put compiled modules into mercurial.cffi package
...
Don't pollute the top-level namespace.
2017-05-02 21:08:38 +09:00
Yuya Nishihara
4563e16232
parsers: switch to policy importer
...
# no-check-commit
2016-08-13 12:23:56 +09:00
Yuya Nishihara
5fe7742660
mpatch: switch to policy importer
2016-08-13 12:18:58 +09:00
Yuya Nishihara
50b316b748
bdiff: switch to policy importer
...
# no-check-commit
2016-08-13 12:12:50 +09:00
Yuya Nishihara
70995f9aa9
osutil: switch to policy importer
...
"make clean" is recommended to test this change, though C API compatibility
should be preserved.
2016-08-12 11:35:17 +09:00
Yuya Nishihara
2a7deb97d4
py3: abuse r'' to preserve str-ness of literals passed to __setattr__()
2017-03-26 16:33:12 +09:00
Yuya Nishihara
7109431581
py3: use bytes() to cast to immutable bytes in pure.bdiff.bdiff()
2017-03-26 16:16:45 +09:00
Yuya Nishihara
b24f9e13b8
bdiff: drop support for array.array argument from pure.bdiff.bdiff()
...
Thanks to 54d8e724da64, we no longer pass array.array('c') object to
bdiff().
2017-03-26 16:14:04 +09:00
Martin von Zweigbergk
299fc67d57
pure: use int instead of long
...
Similar to the recent 09e07907253b (revlog: use int instead of long,
2017-03-19).
2017-03-20 21:40:28 -07:00
Pulkit Goyal
dd7f41320f
parsers: alias long to int on Python 3
2017-03-08 00:45:19 +05:30
Pulkit Goyal
56031921a5
py3: convert the mode argument of os.fdopen to unicodes (2 of 2)
2017-02-13 22:15:28 +05:30
Pulkit Goyal
d35cffe17d
py3: replace sys.platform with pycompat.sysplatform (part 2 of 2)
2016-12-19 02:26:41 +05:30
Pulkit Goyal
4780c32e4c
py3: replace os.name with pycompat.osname (part 1 of 2)
...
os.name returns unicodes on py3 and we have pycompat.osname which returns
bytes. This series of 2 patches will change every ocurrence of os.name with
pycompat.osname.
2016-12-19 00:16:52 +05:30
Pulkit Goyal
af51d6f213
py3: use pycompat.ossep at certain places
...
Certain instances of os.sep has been converted to pycompat.ossep where it was
sure to use bytes only. There are more such instances which needs some more
attention and will get surely.
2016-11-06 04:10:33 +05:30
Maciej Fijalkowski
6efacdd6af
lazymanifest: write a more efficient, pypy friendly version of lazymanifest
2016-09-12 13:37:14 +02:00
Maciej Fijalkowski
9fdc692e77
bdiff: implement cffi version of bdiff
2016-08-20 23:06:01 +02:00
Maciej Fijalkowski
a33764dd71
bdiff: implement cffi version of blocks
2016-07-28 14:17:08 +02:00
Maciej Fijalkowski
521b1aecb5
osutil: fix the bug on OS X when we return more in listdir
...
The pointer arithmetic somehow got ommitted during the recent change to use
a struct.
2016-08-20 23:05:18 +02:00
Pulkit Goyal
7a4ee4f18a
py3: use unicode literals in pure/osutil.py
...
The first element of _fields_ tuples must be a str in Python 3.
Also fix some function calls that were also expecting str.
2016-08-04 00:32:19 +05:30
Maciej Fijalkowski
c98b11e3dd
mpatch: write a cffi version of mpatch.patches
2016-07-25 15:10:52 +02:00
Maciej Fijalkowski
b0e2d543a3
osutil: add darwin-only version of os.listdir using cffi
2016-07-11 11:05:08 +02:00
Maciej Fijalkowski
f3ac5246cf
pure: write a really lazy version of pure indexObject
...
On PyPy this version performs reasonably well compared to C version.
Example command is "hg id" which gets faster, depending on details
of your operating system and hard drive (it's bottlenecked on stat mostly)
There is potential for improvements by storing extra as a condensed struct too.
2016-04-24 14:21:38 +03:00
timeless
f77cdcd3b1
pycompat: switch to util.stringio for py3 compat
2016-04-10 20:55:37 +00:00
timeless
4fca2b2f02
mpatch: unify mpatchError (issue5182)
...
The pure version was mpatch was throwing struct.error or ValueError
for errors, whereas the C version was throwing an "mpatch.mpatchError".
Introducing an mpatch.mpatchError into pure and using it consistently
is fairly easy, but the actual form for it is mercurial.mpatch.mpatchError,
so with this commit, we change the C implementation to match the naming
convention too.
2016-03-31 02:05:28 +00:00
Augie Fackler
7347261bf4
mpatch: move collect() to module level
...
This helps the code read a little more clearly.
2016-03-19 16:45:52 -04:00
Augie Fackler
4f3e191469
mpatch: un-nest the move() method
...
This helps the code read a little more clearly.
2016-03-19 16:43:16 -04:00
Augie Fackler
ff76ed3734
mpatch: move pull() method to top level
...
There was no need for this to be nested.
2016-03-19 16:37:30 -04:00
timeless
156f8d111d
bdiff: (pure) support array.array arrays (issue5130)
2016-03-08 17:26:12 +00:00
Yuya Nishihara
9d11e83caf
osutil: do not abort loading pure module just because libc has no recvmsg()
...
On Solaris, recvmsg() is provided by libsocket.so. We could try hard to look
for the library which provides 'recvmsg' symbol, but it would make little sense
now since recvfds() won't work anyway on Solaris. So this patch just disables
_recvmsg() on such platforms.
Thanks to FUJIWARA Katsunori for spotting this problem.
2016-02-03 22:47:27 +09:00
Gregory Szorc
d467f4fac0
osutil: implement __enter__ and __exit__ on posixfile
...
So they can be used as context managers.
2016-01-02 16:41:57 -08:00
Bryan O'Sullivan
65b74b5b62
osutil: c_ssize_t is only available in Python >= 2.7
2015-12-22 21:38:06 -08:00
Yuya Nishihara
bece6296b6
osutil: implement pure version of recvfds() for PyPy
...
This is less portable than the C version, but PyPy can't load CPython
extensions. So for now, this will be used on PyPy.
I've tested it on Linux amd64 and Mac OS X.
2015-12-17 23:53:09 +09:00
Gregory Szorc
98bb2fb083
parsers: use absolute_import
2015-12-12 13:39:29 -05:00
Gregory Szorc
3fccff1c87
osutil: use absolute_import
2015-12-12 13:46:32 -05:00
Gregory Szorc
132a5b6d98
mpatch: use absolute_import
...
While I was here, I removed the try..except around importing cStringIO
because cStringIO should always be importable on modern Python versions.
We already do an unconditional import in other files.
2015-12-12 13:37:56 -05:00
Gregory Szorc
d6131e9cde
diffhelpers: use absolute_import
2015-12-12 13:35:41 -05:00
Gregory Szorc
38f154a7ae
bdiff: use absolute_import
2015-12-12 13:34:55 -05:00
Gregory Szorc
631c25fecc
base85: use absolute_import
2015-12-12 13:33:47 -05:00
Gregory Szorc
fc448078d4
osutil: remove Python 2.4 errno conversion workaround
2015-06-22 10:11:31 -07:00
Drew Gottlieb
430b150d78
parsers: remove unused dependency on util
...
Parsers.py had a reference to util.sha1 which was unused. This commit removes
this reference as well as the unused import of util to simplify the dependency
graph. This is important for the next commit which actually relocates part
of a module to eliminate a cycle.
2015-04-06 13:59:36 -07:00
Matt Mackall
3da0ef53cd
manifest: move pure parsing code out of pure
...
This lets us transition more smoothly.
2015-03-06 17:00:42 -06:00