~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/dirstate.py

(jelmer) Use the absolute_import feature everywhere in bzrlib,
 and add a source test to make sure it's used everywhere. (Jelmer Vernooij)

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.root_inventory)
 
1295
                result.set_state_from_inventory(tree.inventory)
1296
1296
            finally:
1297
1297
                for revid, parent_tree in parent_trees:
1298
1298
                    parent_tree.unlock()
1561
1561
                    else:
1562
1562
                        source_path = child_basename
1563
1563
                    if new_path_utf8:
1564
 
                        target_path = \
1565
 
                            new_path_utf8 + source_path[len(old_path_utf8):]
 
1564
                        target_path = new_path_utf8 + source_path[len(old_path):]
1566
1565
                    else:
1567
 
                        if old_path_utf8 == '':
 
1566
                        if old_path == '':
1568
1567
                            raise AssertionError("cannot rename directory to"
1569
1568
                                                 " itself")
1570
 
                        target_path = source_path[len(old_path_utf8) + 1:]
 
1569
                        target_path = source_path[len(old_path) + 1:]
1571
1570
                    adds.append((None, target_path, entry[0][2], entry[1][1], False))
1572
1571
                    deletes.append(
1573
1572
                        (source_path, target_path, entry[0][2], None, False))
1574
 
                deletes.append(
1575
 
                    (old_path_utf8, new_path_utf8, file_id, None, False))
1576
 
 
 
1573
                deletes.append((old_path_utf8, new_path, file_id, None, False))
1577
1574
        self._check_delta_ids_absent(new_ids, delta, 1)
1578
1575
        try:
1579
1576
            # Finish expunging deletes/first half of renames.
1648
1645
            entry_key = st(dirname, basename, file_id)
1649
1646
            block_index, present = self._find_block_index_from_key(entry_key)
1650
1647
            if not present:
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
 
 
 
1648
                self._raise_invalid(new_path, file_id,
 
1649
                    "Unable to find block for this record."
 
1650
                    " Was the parent added?")
1663
1651
            block = self._dirblocks[block_index][1]
1664
1652
            entry_index, present = self._find_entry_index(entry_key, block)
1665
1653
            if real_add:
1933
1921
            # paths are produced by UnicodeDirReader on purpose.
1934
1922
            abspath = abspath.encode(fs_encoding)
1935
1923
        target = os.readlink(abspath)
1936
 
        if fs_encoding not in ('utf-8', 'ascii'):
 
1924
        if fs_encoding not in ('UTF-8', 'US-ASCII', 'ANSI_X3.4-1968'):
1937
1925
            # Change encoding if needed
1938
1926
            target = target.decode(fs_encoding).encode('UTF-8')
1939
1927
        return target
2575
2563
        self.update_minimal(('', '', new_id), 'd',
2576
2564
            path_utf8='', packed_stat=entry[1][0][4])
2577
2565
        self._mark_modified()
 
2566
        # XXX: This was added by Ian, we need to make sure there
 
2567
        #      are tests for it, because it isn't in bzr.dev TRUNK
 
2568
        #      It looks like the only place it is called is in setting the root
 
2569
        #      id of the tree. So probably we never had an _id_index when we
 
2570
        #      don't even have a root yet.
 
2571
        if self._id_index is not None:
 
2572
            self._add_to_id_index(self._id_index, entry[0])
2578
2573
 
2579
2574
    def set_parent_trees(self, trees, ghosts):
2580
2575
        """Set the parent trees for the dirstate.
3287
3282
        if self._id_index is not None:
3288
3283
            for file_id, entry_keys in self._id_index.iteritems():
3289
3284
                for entry_key in entry_keys:
3290
 
                    # Check that the entry in the map is pointing to the same
3291
 
                    # file_id
3292
3285
                    if entry_key[2] != file_id:
3293
3286
                        raise AssertionError(
3294
3287
                            'file_id %r did not match entry key %s'
3295
3288
                            % (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)
3304
3289
                if len(entry_keys) != len(set(entry_keys)):
3305
3290
                    raise AssertionError(
3306
3291
                        'id_index contained non-unique data for %s'