~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/dirstate.py

  • Committer: Patch Queue Manager
  • Date: 2014-02-12 18:22:22 UTC
  • mfrom: (6589.2.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20140212182222-beouo25gaf1cny76
(vila) The XDG Base Directory Specification uses the XDG_CACHE_HOME,
 not XDG_CACHE_DIR. (Andrew Starr-Bochicchio)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1292
1292
                    parent_trees.append((parent_id, parent_tree))
1293
1293
                    parent_tree.lock_read()
1294
1294
                result.set_parent_trees(parent_trees, [])
1295
 
                result.set_state_from_inventory(tree.inventory)
 
1295
                result.set_state_from_inventory(tree.root_inventory)
1296
1296
            finally:
1297
1297
                for revid, parent_tree in parent_trees:
1298
1298
                    parent_tree.unlock()
1648
1648
            entry_key = st(dirname, basename, file_id)
1649
1649
            block_index, present = self._find_block_index_from_key(entry_key)
1650
1650
            if not present:
1651
 
                self._raise_invalid(new_path, file_id,
1652
 
                    "Unable to find block for this record."
1653
 
                    " Was the parent added?")
 
1651
                # The block where we want to put the file is not present.
 
1652
                # However, it might have just been an empty directory. Look for
 
1653
                # the parent in the basis-so-far before throwing an error.
 
1654
                parent_dir, parent_base = osutils.split(dirname)
 
1655
                parent_block_idx, parent_entry_idx, _, parent_present = \
 
1656
                    self._get_block_entry_index(parent_dir, parent_base, 1)
 
1657
                if not parent_present:
 
1658
                    self._raise_invalid(new_path, file_id,
 
1659
                        "Unable to find block for this record."
 
1660
                        " Was the parent added?")
 
1661
                self._ensure_block(parent_block_idx, parent_entry_idx, dirname)
 
1662
 
1654
1663
            block = self._dirblocks[block_index][1]
1655
1664
            entry_index, present = self._find_entry_index(entry_key, block)
1656
1665
            if real_add:
2566
2575
        self.update_minimal(('', '', new_id), 'd',
2567
2576
            path_utf8='', packed_stat=entry[1][0][4])
2568
2577
        self._mark_modified()
2569
 
        # XXX: This was added by Ian, we need to make sure there
2570
 
        #      are tests for it, because it isn't in bzr.dev TRUNK
2571
 
        #      It looks like the only place it is called is in setting the root
2572
 
        #      id of the tree. So probably we never had an _id_index when we
2573
 
        #      don't even have a root yet.
2574
 
        if self._id_index is not None:
2575
 
            self._add_to_id_index(self._id_index, entry[0])
2576
2578
 
2577
2579
    def set_parent_trees(self, trees, ghosts):
2578
2580
        """Set the parent trees for the dirstate.
3285
3287
        if self._id_index is not None:
3286
3288
            for file_id, entry_keys in self._id_index.iteritems():
3287
3289
                for entry_key in entry_keys:
 
3290
                    # Check that the entry in the map is pointing to the same
 
3291
                    # file_id
3288
3292
                    if entry_key[2] != file_id:
3289
3293
                        raise AssertionError(
3290
3294
                            'file_id %r did not match entry key %s'
3291
3295
                            % (file_id, entry_key))
 
3296
                    # And that from this entry key, we can look up the original
 
3297
                    # record
 
3298
                    block_index, present = self._find_block_index_from_key(entry_key)
 
3299
                    if not present:
 
3300
                        raise AssertionError('missing block for entry key: %r', entry_key)
 
3301
                    entry_index, present = self._find_entry_index(entry_key, self._dirblocks[block_index][1])
 
3302
                    if not present:
 
3303
                        raise AssertionError('missing entry for key: %r', entry_key)
3292
3304
                if len(entry_keys) != len(set(entry_keys)):
3293
3305
                    raise AssertionError(
3294
3306
                        'id_index contained non-unique data for %s'