summaryrefslogtreecommitdiff
path: root/mercurial/pure
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2011-10-01 20:49:36 +0000
committerLorry <lorry@roadtrain.codethink.co.uk>2012-09-27 13:27:51 +0000
commit921ced43c48c1d170452a7b251b94cc96ec8dd44 (patch)
tree3c4a89176ea67fe4c7bf7b375488361a823c95fa /mercurial/pure
parent9039c805b0a7e36220101323f82735f08a104b37 (diff)
downloadmercurial-tarball-master.tar.gz
Imported from /srv/lorry/lorry-area/mercurial-tarball/mercurial-1.9.3.tar.gz.HEADmercurial-1.9.3master
Diffstat (limited to 'mercurial/pure')
-rw-r--r--mercurial/pure/__init__.py0
-rw-r--r--mercurial/pure/base85.py5
-rw-r--r--mercurial/pure/bdiff.py9
-rw-r--r--mercurial/pure/mpatch.py4
-rw-r--r--mercurial/pure/osutil.py21
-rw-r--r--mercurial/pure/parsers.py4
6 files changed, 26 insertions, 17 deletions
diff --git a/mercurial/pure/__init__.py b/mercurial/pure/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/mercurial/pure/__init__.py
+++ /dev/null
diff --git a/mercurial/pure/base85.py b/mercurial/pure/base85.py
index 8b93192..930d251 100644
--- a/mercurial/pure/base85.py
+++ b/mercurial/pure/base85.py
@@ -54,10 +54,9 @@ def b85decode(text):
try:
acc = acc * 85 + _b85dec[c]
except KeyError:
- raise ValueError('bad base85 character at position %d'
- % (i + j))
+ raise TypeError('Bad base85 character at byte %d' % (i + j))
if acc > 4294967295:
- raise ValueError('Base85 overflow in hunk starting at byte %d' % i)
+ raise OverflowError('Base85 overflow in hunk starting at byte %d' % i)
out.append(acc)
# Pad final chunk if necessary
diff --git a/mercurial/pure/bdiff.py b/mercurial/pure/bdiff.py
index 06f0bd3..0e457d3 100644
--- a/mercurial/pure/bdiff.py
+++ b/mercurial/pure/bdiff.py
@@ -5,7 +5,7 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
-import struct, difflib, re
+import struct, difflib
def splitnewlines(text):
'''like str.splitlines, but only split on newlines.'''
@@ -78,10 +78,3 @@ def blocks(a, b):
d = _normalizeblocks(an, bn, d)
return [(i, i + n, j, j + n) for (i, j, n) in d]
-def fixws(text, allws):
- if allws:
- text = re.sub('[ \t\r]+', '', text)
- else:
- text = re.sub('[ \t\r]+', ' ', text)
- text = text.replace(' \n', '\n')
- return text
diff --git a/mercurial/pure/mpatch.py b/mercurial/pure/mpatch.py
index 1738d97..760740d 100644
--- a/mercurial/pure/mpatch.py
+++ b/mercurial/pure/mpatch.py
@@ -85,10 +85,10 @@ def patches(a, bins):
p1, p2, l = struct.unpack(">lll", m.read(12))
pull(new, frags, p1 - last) # what didn't change
pull([], frags, p2 - p1) # what got deleted
- new.append((l, pos + 12)) # what got added
+ new.append((l, pos + 12)) # what got added
pos += l + 12
last = p2
- frags.extend(reversed(new)) # what was left at the end
+ frags.extend(reversed(new)) # what was left at the end
t = collect(b2, frags)
diff --git a/mercurial/pure/osutil.py b/mercurial/pure/osutil.py
index 2476bd6..28bbbc5 100644
--- a/mercurial/pure/osutil.py
+++ b/mercurial/pure/osutil.py
@@ -58,7 +58,7 @@ def listdir(path, stat=False, skip=None):
if os.name != 'nt':
posixfile = open
else:
- import ctypes, msvcrt
+ import ctypes, ctypes.util
_kernel32 = ctypes.windll.kernel32
@@ -68,6 +68,15 @@ else:
_INVALID_HANDLE_VALUE = _HANDLE(-1).value
+ def _crtname():
+ try:
+ # find_msvcrt was introduced in Python 2.6
+ return ctypes.util.find_msvcrt()
+ except AttributeError:
+ return 'msvcr71.dll' # CPython 2.5 and 2.4
+
+ _crt = ctypes.PyDLL(_crtname())
+
# CreateFile
_FILE_SHARE_READ = 0x00000001
_FILE_SHARE_WRITE = 0x00000002
@@ -96,6 +105,9 @@ else:
_DWORD, _DWORD, _HANDLE]
_kernel32.CreateFileA.restype = _HANDLE
+ _crt._open_osfhandle.argtypes = [_HANDLE, ctypes.c_int]
+ _crt._open_osfhandle.restype = ctypes.c_int
+
def _raiseioerror(name):
err = ctypes.WinError()
raise IOError(err.errno, '%s: %s' % (name, err.strerror))
@@ -119,7 +131,7 @@ else:
flags = _O_TEXT
m0 = mode[0]
- if m0 == 'r' and '+' not in mode:
+ if m0 == 'r' and not '+' in mode:
flags |= _O_RDONLY
access = _GENERIC_READ
else:
@@ -144,7 +156,10 @@ else:
if fh == _INVALID_HANDLE_VALUE:
_raiseioerror(name)
- fd = msvcrt.open_osfhandle(fh, flags)
+ # for CPython we must use the same CRT as Python uses,
+ # or the os.fdopen call below will abort with
+ # "OSError: [Errno 9] Bad file descriptor"
+ fd = _crt._open_osfhandle(fh, flags)
if fd == -1:
_kernel32.CloseHandle(fh)
_raiseioerror(name)
diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py
index c4fe285..868dba5 100644
--- a/mercurial/pure/parsers.py
+++ b/mercurial/pure/parsers.py
@@ -36,7 +36,7 @@ def parse_index2(data, inline):
s = struct.calcsize(indexformatng)
index = []
cache = None
- off = 0
+ n = off = 0
l = len(data) - s
append = index.append
@@ -45,6 +45,7 @@ def parse_index2(data, inline):
while off <= l:
e = _unpack(indexformatng, data[off:off + s])
append(e)
+ n += 1
if e[1] < 0:
break
off += e[1] + s
@@ -52,6 +53,7 @@ def parse_index2(data, inline):
while off <= l:
e = _unpack(indexformatng, data[off:off + s])
append(e)
+ n += 1
off += s
if off != len(data):