~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_dirstate_helpers_pyx.pyx

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

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
 
941
947
            # re-writing a dirstate for just this
942
948
            worth_saving = 0
943
949
    elif minikind == c'l':
 
950
        if saved_minikind == c'l':
 
951
            # If the object hasn't changed kind, it isn't worth saving the
 
952
            # dirstate just for a symlink. The default is 'fast symlinks' which
 
953
            # save the target in the inode entry, rather than separately. So to
 
954
            # stat, we've already read everything off disk.
 
955
            worth_saving = 0
944
956
        link_or_sha1 = self._read_link(abspath, saved_link_or_sha1)
945
957
        if self._cutoff_time is None:
946
958
            self._sha_cutoff_time()
952
964
            entry[1][0] = ('l', '', stat_value.st_size,
953
965
                           False, DirState.NULLSTAT)
954
966
    if worth_saving:
955
 
        self._dirblock_state = DirState.IN_MEMORY_MODIFIED
 
967
        # Note, even though _mark_modified will only set
 
968
        # IN_MEMORY_HASH_MODIFIED, it still isn't worth 
 
969
        self._mark_modified([entry])
956
970
    return link_or_sha1
957
971
 
958
972
 
1785
1799
                advance_entry = -1
1786
1800
                advance_path = -1
1787
1801
                result = None
 
1802
                changed = None
1788
1803
                path_handled = 0
1789
1804
                if current_entry is None:
1790
1805
                    # unversioned -  the check for path_handled when the path