24
26
from bzrlib.dirstate import DirState
29
def pack_stat(st, _b64=binascii.b2a_base64, _pack=struct.Struct('>6L').pack):
30
"""Convert stat values into a packed representation
32
Not all of the fields from the stat included are strictly needed, and by
33
just encoding the mtime and mode a slight speed increase could be gained.
34
However, using the pyrex version instead is a bigger win.
36
# base64 encoding always adds a final newline, so strip it off
37
return _b64(_pack(st.st_size & 0xFFFFFFFF, int(st.st_mtime) & 0xFFFFFFFF,
38
int(st.st_ctime) & 0xFFFFFFFF, st.st_dev & 0xFFFFFFFF,
39
st.st_ino & 0xFFFFFFFF, st.st_mode))[:-1]
42
def _unpack_stat(packed_stat):
43
"""Turn a packed_stat back into the stat fields.
45
This is meant as a debugging tool, should not be used in real code.
47
(st_size, st_mtime, st_ctime, st_dev, st_ino,
48
st_mode) = struct.unpack('>6L', binascii.a2b_base64(packed_stat))
49
return dict(st_size=st_size, st_mtime=st_mtime, st_ctime=st_ctime,
50
st_dev=st_dev, st_ino=st_ino, st_mode=st_mode)
27
53
def _bisect_path_left(paths, path):
28
54
"""Return the index where to insert path into paths.