~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/dirstate.py

  • Committer: Frank Aspell
  • Date: 2009-02-17 11:40:05 UTC
  • mto: (4054.1.1 doc)
  • mto: This revision was merged to the branch mainline in revision 4056.
  • Revision ID: frankaspell@googlemail.com-20090217114005-ojufrp6rqht664um
Fixed typos.

Fixed some typos in bzr doc's using "aspell -l en -c FILENAME".

Show diffs side-by-side

added added

removed removed

Lines of Context:
415
415
            raise AssertionError(
416
416
                "must be a utf8 file_id not %s" % (type(file_id), ))
417
417
        # Make sure the file_id does not exist in this tree
418
 
        file_id_entry = self._get_entry(0, fileid_utf8=file_id)
 
418
        rename_from = None
 
419
        file_id_entry = self._get_entry(0, fileid_utf8=file_id, include_deleted=True)
419
420
        if file_id_entry != (None, None):
420
 
            path = osutils.pathjoin(file_id_entry[0][0], file_id_entry[0][1])
421
 
            kind = DirState._minikind_to_kind[file_id_entry[1][0][0]]
422
 
            info = '%s:%s' % (kind, path)
423
 
            raise errors.DuplicateFileId(file_id, info)
 
421
            if file_id_entry[1][0][0] == 'a':
 
422
                if file_id_entry[0] != (dirname, basename, file_id):
 
423
                    # set the old name's current operation to rename
 
424
                    self.update_minimal(file_id_entry[0],
 
425
                        'r',
 
426
                        path_utf8='',
 
427
                        packed_stat='',
 
428
                        fingerprint=utf8path
 
429
                    )
 
430
                    rename_from = file_id_entry[0][0:2]
 
431
            else:
 
432
                path = osutils.pathjoin(file_id_entry[0][0], file_id_entry[0][1])
 
433
                kind = DirState._minikind_to_kind[file_id_entry[1][0][0]]
 
434
                info = '%s:%s' % (kind, path)
 
435
                raise errors.DuplicateFileId(file_id, info)
424
436
        first_key = (dirname, basename, '')
425
437
        block_index, present = self._find_block_index_from_key(first_key)
426
438
        if present:
453
465
            packed_stat = pack_stat(stat)
454
466
        parent_info = self._empty_parent_info()
455
467
        minikind = DirState._kind_to_minikind[kind]
 
468
        if rename_from is not None:
 
469
            if rename_from[0]:
 
470
                old_path_utf8 = '%s/%s' % rename_from
 
471
            else:
 
472
                old_path_utf8 = rename_from[1]
 
473
            parent_info[0] = ('r', old_path_utf8, 0, False, '')
456
474
        if kind == 'file':
457
475
            entry_data = entry_key, [
458
476
                (minikind, fingerprint, size, False, packed_stat),
1570
1588
        #       already in memory. However, this really needs to be done at a
1571
1589
        #       higher level, because there either won't be anything on disk,
1572
1590
        #       or the thing on disk will be a file.
1573
 
        return os.readlink(abspath)
 
1591
        return os.readlink(abspath.encode(osutils._fs_enc))
1574
1592
 
1575
1593
    def get_ghosts(self):
1576
1594
        """Return a list of the parent tree revision ids that are ghosts."""
1722
1740
            entry_index += 1
1723
1741
        return block_index, entry_index, True, False
1724
1742
 
1725
 
    def _get_entry(self, tree_index, fileid_utf8=None, path_utf8=None):
 
1743
    def _get_entry(self, tree_index, fileid_utf8=None, path_utf8=None, include_deleted=False):
1726
1744
        """Get the dirstate entry for path in tree tree_index.
1727
1745
 
1728
1746
        If either file_id or path is supplied, it is used as the key to lookup.
1736
1754
            trees.
1737
1755
        :param fileid_utf8: A utf8 file_id to look up.
1738
1756
        :param path_utf8: An utf8 path to be looked up.
 
1757
        :param include_deleted: If True, and performing a lookup via
 
1758
            fileid_utf8 rather than path_utf8, return an entry for deleted
 
1759
            (absent) paths.
1739
1760
        :return: The dirstate entry tuple for path, or (None, None)
1740
1761
        """
1741
1762
        self._read_dirblocks_if_needed()
1782
1803
                        return entry
1783
1804
                    if entry[1][tree_index][0] == 'a':
1784
1805
                        # there is no home for this entry in this tree
 
1806
                        if include_deleted:
 
1807
                            return entry
1785
1808
                        return None, None
1786
1809
                    if entry[1][tree_index][0] != 'r':
1787
1810
                        raise AssertionError(