~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/dirstate.py

  • Committer: Robert Collins
  • Date: 2007-03-01 11:50:27 UTC
  • mto: (2255.11.3 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: robertc@robertcollins.net-20070301115027-7ch3pnc922va6fr5
Fix _get_entry, which got broken at some point, this fixes tests now, so it should not be breakable in future.

Show diffs side-by-side

added added

removed removed

Lines of Context:
342
342
                if block[entry_index][1][0][0] not in 'ar':
343
343
                    # this path is in the dirstate in the current tree.
344
344
                    raise Exception, "adding already added path!"
 
345
                entry_index += 1
345
346
        else:
346
347
            # The block where we want to put the file is not present. But it
347
348
            # might be because the directory was empty, or not loaded yet. Look
1199
1200
            if not possible_keys:
1200
1201
                return None, None
1201
1202
            for key in possible_keys:
1202
 
                (block_index, entry_index, dir_present,
1203
 
                 file_present) = self._get_block_entry_index(key[0], key[1],
1204
 
                                                             tree_index)
1205
 
                if file_present:
 
1203
                block_index, present = \
 
1204
                    self._find_block_index_from_key(key)
 
1205
                # strange, probably indicates an out of date
 
1206
                # id index - for now, allow this.
 
1207
                if not present:
 
1208
                    continue
 
1209
                # WARNING: DO not change this code to use _get_block_entry_index
 
1210
                # as that function is not suitable: it does not use the key
 
1211
                # to lookup, and thus the wront coordinates are returned.
 
1212
                block = self._dirblocks[block_index][1]
 
1213
                entry_index, present = self._find_entry_index(key, block)
 
1214
                if present:
1206
1215
                    entry = self._dirblocks[block_index][1][entry_index]
1207
 
                    # _get_block_entry_index only returns entries that are not
1208
 
                    # absent in the current tree. _get_id_index will return
1209
 
                    # both locations for a renamed file.  It is possible that a
1210
 
                    # new file was added at the same location that the old file
1211
 
                    # was renamed away. So _get_block_entry_index will actually
1212
 
                    # match the new file, skipping the fact that the real entry
1213
 
                    # we want is the rename. By just continuing here, we should
1214
 
                    # find the record at the target location, because
1215
 
                    # _get_id_index should return all locations.
1216
 
                    if entry[0][2] != fileid_utf8:
1217
 
                        continue
1218
 
                    assert entry[1][tree_index][0] not in ('a', 'r')
1219
 
                    assert key == entry[0], ('We were told that %s would be at'
1220
 
                            ' %s, %s, but we found %s' % (key, block_index,
1221
 
                                                          entry_index, entry))
1222
 
                    return entry
 
1216
                    if entry[1][tree_index][0] in 'fdl':
 
1217
                        # this is the result we are looking for: the  
 
1218
                        # real home of this file_id in this tree.
 
1219
                        return entry
 
1220
                    if entry[1][tree_index][0] == 'a':
 
1221
                        # there is no home for this entry in this tree
 
1222
                        return None, None
 
1223
                    assert entry[1][tree_index][0] == 'r'
 
1224
                    real_path = entry[1][tree_index][1]
 
1225
                    return self._get_entry(tree_index, fileid_utf8=fileid_utf8,
 
1226
                        path_utf8=real_path)
1223
1227
            return None, None
1224
1228
 
1225
1229
    @staticmethod