merged in changes from stepancheg patch queues

This commit is contained in:
Scott Chacon 2009-05-08 11:35:42 -07:00
commit b3ebb60d97
3 changed files with 31 additions and 7 deletions

View File

@ -20,12 +20,19 @@
These utilities can all be deleted when dulwich decides it wants to stop
support for python 2.4.
"""
from mercurial import demandimport
import __builtin__
orig_import = __builtin__.__import__
demandimport.disable()
try:
import hashlib
except ImportError:
import sha
import struct
__builtin__.__import__ = orig_import
class defaultdict(dict):
"""A python 2.4 equivalent of collections.defaultdict."""

View File

@ -467,7 +467,7 @@ class Commit(ShaFile):
assert text[count] == ' ', "Invalid commit object, " \
"author information must be followed by space not %s" % text[count]
count += 1
self._author_time = int(text[count:count+10])
self._author_time = int(text[count:].split(" ", 1)[0])
while text[count] != ' ':
count += 1
self._author_timezone = int(text[count:count+6])

View File

@ -30,6 +30,11 @@ match for the object name. You then use the pointer got from this as
a pointer in to the corresponding packfile.
"""
from mercurial import demandimport
import __builtin__
orig_import = __builtin__.__import__
demandimport.disable()
try:
from collections import defaultdict
except ImportError:
@ -61,6 +66,8 @@ from objects import (
)
from misc import make_sha
__builtin__.__import__ = orig_import
supports_mmap_offset = (sys.version_info[0] >= 3 or
(sys.version_info[0] == 2 and sys.version_info[1] >= 6))
@ -107,9 +114,14 @@ def simple_mmap(f, offset, size, access=mmap.ACCESS_READ):
:param access: Access mechanism.
:return: MMAP'd area.
"""
mem = mmap.mmap(f.fileno(), size+offset, access=access)
return mem, offset
print f, offset, size
if supports_mmap_offset:
mem = mmap.mmap(f.fileno(), size + offset % mmap.PAGESIZE, access=access,
offset=offset / mmap.PAGESIZE * mmap.PAGESIZE)
return mem, offset % mmap.PAGESIZE
else:
mem = mmap.mmap(f.fileno(), size+offset, access=access)
return mem, offset
def load_pack_index(filename):
f = open(filename, 'r')
@ -451,9 +463,12 @@ class PackData(object):
"""Calculate the checksum for this pack."""
map, map_offset = simple_mmap(self._file, 0, self._size - 20)
try:
return make_sha(map[map_offset:self._size-20]).digest()
finally:
r = make_sha(map[map_offset:self._size-20]).digest()
map.close()
return r
except:
map.close()
raise
def resolve_object(self, offset, type, obj, get_ref, get_offset=None):
"""Resolve an object, possibly resolving deltas when necessary.
@ -500,8 +515,10 @@ class PackData(object):
offset += total_size
if progress:
progress(i, num)
finally:
map.close()
except:
map.close()
raise
def iterentries(self, ext_resolve_ref=None, progress=None):
found = {}