/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/_dirstate_helpers_pyx.pyx

  • Committer: Robert Collins
  • Date: 2009-08-26 01:18:13 UTC
  • mto: This revision was merged to the branch mainline in revision 4656.
  • Revision ID: robertc@robertcollins.net-20090826011813-46x8kcuzwz97opoi
Deserialise IncompatibleRepositories errors in the client, generating
nicer feedback when the smart server encounters such a situation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008, 2010 Canonical Ltd
 
1
# Copyright (C) 2007, 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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): # cannot_raise
 
122
cdef void* _my_memrchr(void *s, int c, size_t n):
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
156
156
        return None
157
157
    return <char*>found - <char*>_s
158
158
 
159
 
 
160
159
cdef object safe_string_from_size(char *s, Py_ssize_t size):
161
160
    if size < 0:
 
161
        # XXX: On 64-bit machines the <int> cast causes a C compiler warning.
162
162
        raise AssertionError(
163
 
            'tried to create a string with an invalid size: %d'
164
 
            % (size))
 
163
            'tried to create a string with an invalid size: %d @0x%x'
 
164
            % (size, <int>s))
165
165
    return PyString_FromStringAndSize(s, size)
166
166
 
167
167
 
168
 
cdef int _is_aligned(void *ptr): # cannot_raise
 
168
cdef int _is_aligned(void *ptr):
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): # cannot_raise
 
176
cdef int _cmp_by_dirs(char *path1, int size1, char *path2, int size2):
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): # cannot_raise
 
298
                                      char *path2, int path2_len):
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): # cannot_raise
 
771
cdef int minikind_from_mode(int mode):
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
 
# TODO: Do we want to worry about exceptions here?
919
 
cdef char _minikind_from_string(object string) except? -1:
 
918
cdef char _minikind_from_string(object string):
920
919
    """Convert a python string to a char."""
921
920
    return PyString_AsString(string)[0]
922
921
 
954
953
    raise KeyError(PyString_FromStringAndSize(_minikind, 1))
955
954
 
956
955
 
957
 
cdef int _versioned_minikind(char minikind): # cannot_raise
 
956
cdef int _versioned_minikind(char minikind):
958
957
    """Return non-zero if minikind is in fltd"""
959
958
    return (minikind == c'f' or
960
959
            minikind == c'd' or
1203
1202
                        content_change = 0
1204
1203
                    target_exec = False
1205
1204
                else:
1206
 
                    if path is None:
1207
 
                        path = self.pathjoin(old_dirname, old_basename)
1208
 
                    raise errors.BadFileKindError(path, path_info[2])
 
1205
                    raise Exception, "unknown kind %s" % path_info[2]
1209
1206
            if source_minikind == c'd':
1210
1207
                if path is None:
1211
1208
                    old_path = path = self.pathjoin(old_dirname, old_basename)
1374
1371
    def iter_changes(self):
1375
1372
        return self
1376
1373
 
1377
 
    cdef int _gather_result_for_consistency(self, result) except -1:
 
1374
    cdef void _gather_result_for_consistency(self, result):
1378
1375
        """Check a result we will yield to make sure we are consistent later.
1379
1376
        
1380
1377
        This gathers result's parents into a set to output later.
1382
1379
        :param result: A result tuple.
1383
1380
        """
1384
1381
        if not self.partial or not result[0]:
1385
 
            return 0
 
1382
            return
1386
1383
        self.seen_ids.add(result[0])
1387
1384
        new_path = result[1][1]
1388
1385
        if new_path:
1392
1389
            # Add the root directory which parent_directories does not
1393
1390
            # provide.
1394
1391
            self.search_specific_file_parents.add('')
1395
 
        return 0
1396
1392
 
1397
 
    cdef int _update_current_block(self) except -1:
 
1393
    cdef void _update_current_block(self):
1398
1394
        if (self.block_index < len(self.state._dirblocks) and
1399
1395
            osutils.is_inside(self.current_root, self.state._dirblocks[self.block_index][0])):
1400
1396
            self.current_block = self.state._dirblocks[self.block_index]
1403
1399
        else:
1404
1400
            self.current_block = None
1405
1401
            self.current_block_list = None
1406
 
        return 0
1407
1402
 
1408
1403
    def __next__(self):
1409
1404
        # Simple thunk to allow tail recursion without pyrex confusion