~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-02-17 02:58:22 UTC
  • mfrom: (2249.5.20 knit_utf8_revision_ids)
  • Revision ID: pqm@pqm.ubuntu.com-20070217025822-306d98c244b53b08
(John Arbash Meinel) Clean up most internals to use utf-8 revision ids instead of Unicode.

Show diffs side-by-side

added added

removed removed

Lines of Context:
503
503
        else:
504
504
            parents = [last_rev]
505
505
        try:
506
 
            merges_file = self._control_files.get_utf8('pending-merges')
 
506
            merges_file = self._control_files.get('pending-merges')
507
507
        except errors.NoSuchFile:
508
508
            pass
509
509
        else:
510
510
            for l in merges_file.readlines():
511
 
                parents.append(l.rstrip('\n'))
 
511
                revision_id = osutils.safe_revision_id(l.rstrip('\n'))
 
512
                parents.append(revision_id)
512
513
        return parents
513
514
 
514
515
    @needs_read_lock
719
720
        :param revision_ids: The revision_ids to set as the parent ids of this
720
721
            working tree. Any of these may be ghosts.
721
722
        """
 
723
        revision_ids = [osutils.safe_revision_id(r) for r in revision_ids]
722
724
        self._check_parents_for_ghosts(revision_ids,
723
725
            allow_leftmost_as_ghost=allow_leftmost_as_ghost)
724
726
 
732
734
    @needs_tree_write_lock
733
735
    def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False):
734
736
        """See MutableTree.set_parent_trees."""
735
 
        parent_ids = [rev for (rev, tree) in parents_list]
 
737
        parent_ids = [osutils.safe_revision_id(rev) for (rev, tree) in parents_list]
736
738
 
737
739
        self._check_parents_for_ghosts(parent_ids,
738
740
            allow_leftmost_as_ghost=allow_leftmost_as_ghost)
795
797
            merger.check_basis(check_clean=True, require_commits=False)
796
798
            if to_revision is None:
797
799
                to_revision = branch.last_revision()
 
800
            else:
 
801
                to_revision = osutils.safe_revision_id(to_revision)
798
802
            merger.other_rev_id = to_revision
799
803
            if merger.other_rev_id is None:
800
804
                raise error.NoCommits(branch)
1532
1536
    @needs_tree_write_lock
1533
1537
    def set_last_revision(self, new_revision):
1534
1538
        """Change the last revision in the working tree."""
 
1539
        new_revision = osutils.safe_revision_id(new_revision)
1535
1540
        if self._change_last_revision(new_revision):
1536
1541
            self._cache_basis_inventory(new_revision)
1537
1542
 
1560
1565
 
1561
1566
    def _create_basis_xml_from_inventory(self, revision_id, inventory):
1562
1567
        """Create the text that will be saved in basis-inventory"""
1563
 
        inventory.revision_id = revision_id
 
1568
        # TODO: jam 20070209 This should be redundant, as the revision_id
 
1569
        #       as all callers should have already converted the revision_id to
 
1570
        #       utf8
 
1571
        inventory.revision_id = osutils.safe_revision_id(revision_id)
1564
1572
        return xml6.serializer_v6.write_inventory_to_string(inventory)
1565
1573
 
1566
1574
    def _cache_basis_inventory(self, new_revision):
1953
1961
    def _last_revision(self):
1954
1962
        """See Mutable.last_revision."""
1955
1963
        try:
1956
 
            return self._control_files.get_utf8('last-revision').read()
 
1964
            return osutils.safe_revision_id(
 
1965
                        self._control_files.get('last-revision').read())
1957
1966
        except errors.NoSuchFile:
1958
1967
            return None
1959
1968
 
2133
2142
            raise errors.NotLocalUrl(a_bzrdir.transport.base)
2134
2143
        branch = a_bzrdir.open_branch()
2135
2144
        if revision_id is not None:
 
2145
            revision_id = osutils.safe_revision_id(revision_id)
2136
2146
            branch.lock_write()
2137
2147
            try:
2138
2148
                revision_history = branch.revision_history()
2224
2234
        branch = a_bzrdir.open_branch()
2225
2235
        if revision_id is None:
2226
2236
            revision_id = branch.last_revision()
 
2237
        else:
 
2238
            revision_id = osutils.safe_revision_id(revision_id)
2227
2239
        # WorkingTree3 can handle an inventory which has a unique root id.
2228
2240
        # as of bzr 0.12. However, bzr 0.11 and earlier fail to handle
2229
2241
        # those trees. And because there isn't a format bump inbetween, we