Commit Graph

28 Commits

Author SHA1 Message Date
Dan Villiom Podlaski Christiansen
ec590d5cd4 explicitly close files
Add missing calls to close() to many places where files are
opened. Relying on reference counting to catch them soon-ish is not
portable and fails in environments with a proper GC, such as PyPy.
2010-12-24 15:23:01 +01:00
Adrian Buehlmann
77ab03f101 port win32.py to using the Python ctypes library
The pywin32 package is no longer needed.

ctypes is now required for running Mercurial on Windows.

ctypes is included in Python since version 2.5. For Python 2.4, ctypes is
available as an extra installer package for Windows.

Moved spawndetached() from windows.py to win32.py and fixed it, using
ctypes as well. spawndetached was defunct with Python 2.6.6 because Python
removed their undocumented subprocess.CreateProcess. This fixes
'hg serve -d' on Windows.
2011-02-14 11:12:26 +01:00
Adrian Buehlmann
c83b01e7a1 reintroduces util.unlink, for POSIX and Windows.
windows: factor it out of rename
posix: add alias 'unlink' for os.unlink

Note that this new unlink function now has different semantics than the
unlink() we had before changeset 5c424b3de62c ("rename util.unlink to
unlinkpath").
2011-01-11 14:10:16 +01:00
Dan Villiom Podlaski Christiansen
d256bab10f posix: remove is-comparison between integers
Comparing integers by identity relies on a CPython implementation
detail of caching integers between -5 and 256.[1]

[1] <http://docs.python.org/c-api/int.html#PyInt_FromLong>
2010-11-16 21:35:58 +01:00
Augie Fackler
42c8b2cf07 termwidth: move to ui.ui from util 2010-10-10 10:06:36 -05:00
Patrick Mezard
842d65c40f acl: grp module is not available on windows 2010-05-10 21:09:48 +02:00
Patrick Mezard
d05da88022 Merge with crew-stable 2010-04-26 22:42:46 +02:00
Patrick Mezard
b7c02777e0 util: fix default termwidth() under Windows
sys.stdout.write('-'*80 + '\n')

or

  sys.stdout.write('-'*80 + '\r')

do not work on Windows as they do on unix. On a 80 columns Windows console, the
extra CR or LF are interpreted as if belonging to the next line, so the first
command displays 2 lines (only one on unix) and the second one leave the line
visible and move back to the following line. To avoid this, we sacrifice one
column under Windows.
2010-04-26 22:30:40 +02:00
Ronny Pfannschmidt
66fa69cb0e posix: move a global fcntl import to keep it from breaking jython
Only needed on darwin, anyway.
2010-03-23 11:37:01 +01:00
Matt Mackall
cd3ef170f7 Merge with stable 2010-01-19 22:45:09 -06:00
Matt Mackall
595d66f424 Update license to GPLv2+ 2010-01-19 22:20:08 -06:00
Patrick Mezard
48eee05938 Find right hg command for detached process
On Windows, Mercurial can be run from the python script of from a frozen
executable. In the first case, we have to call the python interpreter since the
script is not executable. Frozen executable can be called directly.

Fix 3/3 for issue421
2010-01-06 21:11:58 +01:00
Siddharth Agarwal
eab3968819 Add support for relinking on Windows.
Test and minor code change by Patrick Mézard <pmezard@gmail.com>
2010-01-08 18:48:39 +05:30
Adrian Buehlmann
db3cee7306 util: move rename into posix.py and windows.py 2009-10-07 20:32:07 +02:00
Mads Kiilerich
097282895a util.system: Use subprocess instead of os.system
subprocess allows the environment and working directory to be specified
directly, so the hacks for making temporary changes while forking is no longer
necessary.

This also fixes failures on solaris where the temporary changes can't be undone
because there is no unsetenv.
2009-09-20 22:19:18 +02:00
Dan Villiom Podlaski Christiansen
5cd95d0ef8 util: add realpath() for getting the 'true' path.
The function is implemented for Mac OS X using the F_GETPATH fcntl,
and a basic implementation for Windows is provided as well. On other
POSIX systems, vanilla os.path.realpath() is used.
2009-07-26 17:25:08 +02:00
Alejandro Santos
77d606ac51 compat: use open() instead of file() everywhere 2009-07-05 11:01:30 +02:00
timeless
fb33de67af Generally replace "file name" with "filename" in help and comments. 2009-06-09 09:25:17 -04:00
Martin Geisler
cac71647b1 posix: do not use fstat in isowner
The fstat function was undefined, but never used since a stat object
was always passed in the optional st argument. Passing st is now
mandatory.

This bug crept in when util was split up into posix and windows
modules. The fstat function is still defined in util, but importing it
into posix would create an import cycle which seems unnecessary.
2009-05-30 23:42:35 +02:00
Matt Mackall
a30eb02911 cmdutils: Take over glob expansion duties from util 2009-05-24 16:38:29 -05:00
Patrick Mezard
e8790c2140 serve: add and use portable spawnvp replacement
There is no standard python command to really detach a process under Windows.
Instead we use the low level API wrapped by subprocess module with all
necessary options to avoid any kind of context inheritance. Unfortunately, this
version still opens a new window for the child process.

The following have been tried:
- os.spawnv(os.P_NOWAIT): works but the child process is killed when parent
  console terminates.
- os.spawnv(os.P_DETACH): works on python25, hang on python26 when writing to
  the hgweb output socket.
- subprocess.CreateProcess() hack without shell mode: similar to
  os.spawnv(os.P_DETACH).

Fix 1/3 for issue421
2009-04-10 21:20:25 +02:00
Simon Heimberg
09ac1e6c92 separate import lines from mercurial and general python modules 2009-04-28 17:40:46 +02:00
Martin Geisler
8e4bc1e9ad put license and copyright info into comment blocks 2009-04-26 01:13:08 +02:00
Martin Geisler
750183bdad updated license to be explicit about GPL version 2 2009-04-26 01:08:54 +02:00
Peter Arrenbrecht
7b457d8a6a whitespace cleanup 2009-04-27 09:12:07 +02:00
Matt Mackall
bcbc752a6f posix: kill some trailing newlines 2009-04-03 12:37:07 -05:00
Rocco Rutte
895d037e99 Add missing imports for posix.py for OS X
These don't seem to do harm on Linux.
2009-03-27 17:56:18 +01:00
Matt Mackall
0952760f82 util: split out posix, windows, and win32 modules 2009-03-26 13:54:44 -05:00