~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/dirstate.py

  • Committer: John Arbash Meinel
  • Date: 2009-09-24 19:26:45 UTC
  • mto: (4634.52.3 2.0)
  • mto: This revision was merged to the branch mainline in revision 4716.
  • Revision ID: john@arbash-meinel.com-20090924192645-hyy1ycnnk6u3j5j6
Catch a corner case that we were missing.
The CHKInventory tests were passing, but failed for test_inv because
we were passing None to _getitems(). That only failed for InternalNodes,
but we were using a structure that didn't have internal nodes.
So now the test is parameterized on a small CHKInventory page size
to force those things out into the open.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006, 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
1324
1324
                key = (dirname_utf8, basename, file_id)
1325
1325
                minikind = DirState._kind_to_minikind[inv_entry.kind]
1326
1326
                if minikind == 't':
1327
 
                    fingerprint = inv_entry.reference_revision or ''
 
1327
                    fingerprint = inv_entry.reference_revision
1328
1328
                else:
1329
1329
                    fingerprint = ''
1330
1330
                insertions[file_id] = (key, minikind, inv_entry.executable,
1339
1339
                    minikind = child[1][0][0]
1340
1340
                    fingerprint = child[1][0][4]
1341
1341
                    executable = child[1][0][3]
1342
 
                    old_child_path = osutils.pathjoin(child_dirname,
1343
 
                                                      child_basename)
 
1342
                    old_child_path = osutils.pathjoin(child[0][0],
 
1343
                                                      child[0][1])
1344
1344
                    removals[child[0][2]] = old_child_path
1345
1345
                    child_suffix = child_dirname[len(old_path):]
1346
1346
                    new_child_dirname = (new_path + child_suffix)
1347
1347
                    key = (new_child_dirname, child_basename, child[0][2])
1348
 
                    new_child_path = osutils.pathjoin(new_child_dirname,
1349
 
                                                      child_basename)
 
1348
                    new_child_path = os.path.join(new_child_dirname,
 
1349
                                                  child_basename)
1350
1350
                    insertions[child[0][2]] = (key, minikind, executable,
1351
1351
                                               fingerprint, new_child_path)
1352
1352
        self._check_delta_ids_absent(new_ids, delta, 0)
1997
1997
                entry_index, present = self._find_entry_index(key, block)
1998
1998
                if present:
1999
1999
                    entry = self._dirblocks[block_index][1][entry_index]
2000
 
                    # TODO: We might want to assert that entry[0][2] ==
2001
 
                    #       fileid_utf8.
2002
2000
                    if entry[1][tree_index][0] in 'fdlt':
2003
2001
                        # this is the result we are looking for: the
2004
2002
                        # real home of this file_id in this tree.
2356
2354
        self.update_minimal(('', '', new_id), 'd',
2357
2355
            path_utf8='', packed_stat=entry[1][0][4])
2358
2356
        self._dirblock_state = DirState.IN_MEMORY_MODIFIED
 
2357
        if self._id_index is not None:
 
2358
            self._id_index.setdefault(new_id, set()).add(entry[0])
2359
2359
 
2360
2360
    def set_parent_trees(self, trees, ghosts):
2361
2361
        """Set the parent trees for the dirstate.
3013
3013
            if absent_positions == tree_count:
3014
3014
                raise AssertionError(
3015
3015
                    "entry %r has no data for any tree." % (entry,))
3016
 
        if self._id_index is not None:
3017
 
            for file_id, entry_keys in self._id_index.iteritems():
3018
 
                for entry_key in entry_keys:
3019
 
                    if entry_key[2] != file_id:
3020
 
                        raise AssertionError(
3021
 
                            'file_id %r did not match entry key %s'
3022
 
                            % (file_id, entry_key))
3023
3016
 
3024
3017
    def _wipe_state(self):
3025
3018
        """Forget all state information about the dirstate."""
3335
3328
                        content_change = False
3336
3329
                    target_exec = False
3337
3330
                else:
3338
 
                    if path is None:
3339
 
                        path = pathjoin(old_dirname, old_basename)
3340
 
                    raise errors.BadFileKindError(path, path_info[2])
 
3331
                    raise Exception, "unknown kind %s" % path_info[2]
3341
3332
            if source_minikind == 'd':
3342
3333
                if path is None:
3343
3334
                    old_path = path = pathjoin(old_dirname, old_basename)
3978
3969
        ProcessEntryC as _process_entry,
3979
3970
        update_entry as update_entry,
3980
3971
        )
3981
 
except ImportError, e:
3982
 
    osutils.failed_to_load_extension(e)
 
3972
except ImportError:
3983
3973
    from bzrlib._dirstate_helpers_py import (
3984
3974
        _read_dirblocks,
3985
3975
        bisect_dirblock,