~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_dirstate_helpers_pyx.pyx

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
    object PyTuple_GetItem_void_object "PyTuple_GET_ITEM" (void* tpl, int index)
98
98
    object PyTuple_GET_ITEM(object tpl, Py_ssize_t index)
99
99
 
 
100
    unsigned long PyInt_AsUnsignedLongMask(object number) except? -1
100
101
 
101
102
    char *PyString_AsString(object p)
102
103
    char *PyString_AsString_obj "PyString_AsString" (PyObject *string)
811
812
_encode = binascii.b2a_base64
812
813
 
813
814
 
814
 
from struct import pack
815
815
cdef _pack_stat(stat_value):
816
816
    """return a string representing the stat value's key fields.
817
817
 
821
821
    cdef char result[6*4] # 6 long ints
822
822
    cdef int *aliased
823
823
    aliased = <int *>result
824
 
    aliased[0] = htonl(stat_value.st_size)
825
 
    aliased[1] = htonl(int(stat_value.st_mtime))
826
 
    aliased[2] = htonl(int(stat_value.st_ctime))
827
 
    aliased[3] = htonl(stat_value.st_dev)
828
 
    aliased[4] = htonl(stat_value.st_ino & 0xFFFFFFFF)
829
 
    aliased[5] = htonl(stat_value.st_mode)
 
824
    aliased[0] = htonl(PyInt_AsUnsignedLongMask(stat_value.st_size))
 
825
    # mtime and ctime will often be floats but get converted to PyInt within
 
826
    aliased[1] = htonl(PyInt_AsUnsignedLongMask(stat_value.st_mtime))
 
827
    aliased[2] = htonl(PyInt_AsUnsignedLongMask(stat_value.st_ctime))
 
828
    aliased[3] = htonl(PyInt_AsUnsignedLongMask(stat_value.st_dev))
 
829
    aliased[4] = htonl(PyInt_AsUnsignedLongMask(stat_value.st_ino))
 
830
    aliased[5] = htonl(PyInt_AsUnsignedLongMask(stat_value.st_mode))
830
831
    packed = PyString_FromStringAndSize(result, 6*4)
831
832
    return _encode(packed)[:-1]
832
833
 
833
834
 
 
835
def pack_stat(stat_value):
 
836
    """Convert stat value into a packed representation quickly with pyrex"""
 
837
    return _pack_stat(stat_value)
 
838
 
 
839
 
834
840
def update_entry(self, entry, abspath, stat_value):
835
841
    """Update the entry based on what is actually on disk.
836
842
 
1793
1799
                advance_entry = -1
1794
1800
                advance_path = -1
1795
1801
                result = None
 
1802
                changed = None
1796
1803
                path_handled = 0
1797
1804
                if current_entry is None:
1798
1805
                    # unversioned -  the check for path_handled when the path