~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_dirstate_helpers_pyx.pyx

  • Committer: Andrew Bennetts
  • Date: 2010-01-15 03:58:20 UTC
  • mfrom: (4963 +trunk)
  • mto: (4973.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4975.
  • Revision ID: andrew.bennetts@canonical.com-20100115035820-ilb3t36swgzq6v1l
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
    # void *memrchr(void *s, int c, size_t len)
120
120
 
121
121
 
122
 
cdef void* _my_memrchr(void *s, int c, size_t n):
 
122
cdef void* _my_memrchr(void *s, int c, size_t n): # cannot_raise
123
123
    # memrchr seems to be a GNU extension, so we have to implement it ourselves
124
124
    cdef char *pos
125
125
    cdef char *start
165
165
    return PyString_FromStringAndSize(s, size)
166
166
 
167
167
 
168
 
cdef int _is_aligned(void *ptr):
 
168
cdef int _is_aligned(void *ptr): # cannot_raise
169
169
    """Is this pointer aligned to an integer size offset?
170
170
 
171
171
    :return: 1 if this pointer is aligned, 0 otherwise.
173
173
    return ((<intptr_t>ptr) & ((sizeof(int))-1)) == 0
174
174
 
175
175
 
176
 
cdef int _cmp_by_dirs(char *path1, int size1, char *path2, int size2):
 
176
cdef int _cmp_by_dirs(char *path1, int size1, char *path2, int size2): # cannot_raise
177
177
    cdef unsigned char *cur1
178
178
    cdef unsigned char *cur2
179
179
    cdef unsigned char *end1
295
295
 
296
296
 
297
297
cdef int _cmp_path_by_dirblock_intern(char *path1, int path1_len,
298
 
                                      char *path2, int path2_len):
 
298
                                      char *path2, int path2_len): # cannot_raise
299
299
    """Compare two paths by what directory they are in.
300
300
 
301
301
    see ``_cmp_path_by_dirblock`` for details.
768
768
    state._dirblock_state = DirState.IN_MEMORY_UNMODIFIED
769
769
 
770
770
 
771
 
cdef int minikind_from_mode(int mode):
 
771
cdef int minikind_from_mode(int mode): # cannot_raise
772
772
    # in order of frequency:
773
773
    if S_ISREG(mode):
774
774
        return c"f"
915
915
    return link_or_sha1
916
916
 
917
917
 
918
 
cdef char _minikind_from_string(object string):
 
918
# TODO: Do we want to worry about exceptions here?
 
919
cdef char _minikind_from_string(object string) except? -1:
919
920
    """Convert a python string to a char."""
920
921
    return PyString_AsString(string)[0]
921
922
 
953
954
    raise KeyError(PyString_FromStringAndSize(_minikind, 1))
954
955
 
955
956
 
956
 
cdef int _versioned_minikind(char minikind):
 
957
cdef int _versioned_minikind(char minikind): # cannot_raise
957
958
    """Return non-zero if minikind is in fltd"""
958
959
    return (minikind == c'f' or
959
960
            minikind == c'd' or
1373
1374
    def iter_changes(self):
1374
1375
        return self
1375
1376
 
1376
 
    cdef void _gather_result_for_consistency(self, result):
 
1377
    cdef int _gather_result_for_consistency(self, result) except -1:
1377
1378
        """Check a result we will yield to make sure we are consistent later.
1378
1379
        
1379
1380
        This gathers result's parents into a set to output later.
1381
1382
        :param result: A result tuple.
1382
1383
        """
1383
1384
        if not self.partial or not result[0]:
1384
 
            return
 
1385
            return 0
1385
1386
        self.seen_ids.add(result[0])
1386
1387
        new_path = result[1][1]
1387
1388
        if new_path:
1391
1392
            # Add the root directory which parent_directories does not
1392
1393
            # provide.
1393
1394
            self.search_specific_file_parents.add('')
 
1395
        return 0
1394
1396
 
1395
 
    cdef void _update_current_block(self):
 
1397
    cdef int _update_current_block(self) except -1:
1396
1398
        if (self.block_index < len(self.state._dirblocks) and
1397
1399
            osutils.is_inside(self.current_root, self.state._dirblocks[self.block_index][0])):
1398
1400
            self.current_block = self.state._dirblocks[self.block_index]
1401
1403
        else:
1402
1404
            self.current_block = None
1403
1405
            self.current_block_list = None
 
1406
        return 0
1404
1407
 
1405
1408
    def __next__(self):
1406
1409
        # Simple thunk to allow tail recursion without pyrex confusion