Commit Graph

31 Commits

Author SHA1 Message Date
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
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
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
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
b0e2d543a3 osutil: add darwin-only version of os.listdir using cffi 2016-07-11 11:05:08 +02: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
3fccff1c87 osutil: use absolute_import 2015-12-12 13:46:32 -05:00
Gregory Szorc
fc448078d4 osutil: remove Python 2.4 errno conversion workaround 2015-06-22 10:11:31 -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
Mads Kiilerich
48016eb3fc declare local constants instead of using magic values and comments 2012-08-27 23:16:22 +02:00
Brodie Rao
a7ef0a0cc5 cleanup: "not x in y" -> "x not in y" 2012-05-12 16:00:57 +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
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
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
Benoit Boissinot
3db7df2869 style: use consistent variable names (*mod) with imports which would shadow 2010-03-11 17:43:44 +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
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
1c820b3f61 move mercurial.osutil to mercurial.pure.osutil 2009-01-24 00:13:49 +01:00