~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: John Arbash Meinel
  • Date: 2007-02-09 18:11:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2294.
  • Revision ID: john@arbash-meinel.com-20070209181144-3cxnt3e4jre3e317
Update WorkingTree to use safe_revision_id when appropriate

Show diffs side-by-side

added added

removed removed

Lines of Context:
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)
1534
1538
    @needs_tree_write_lock
1535
1539
    def set_last_revision(self, new_revision):
1536
1540
        """Change the last revision in the working tree."""
 
1541
        new_revision = osutils.safe_revision_id(new_revision)
1537
1542
        if self._change_last_revision(new_revision):
1538
1543
            self._cache_basis_inventory(new_revision)
1539
1544
 
1562
1567
 
1563
1568
    def _create_basis_xml_from_inventory(self, revision_id, inventory):
1564
1569
        """Create the text that will be saved in basis-inventory"""
1565
 
        inventory.revision_id = revision_id
 
1570
        # TODO: jam 20070209 This should be redundant, as the revision_id
 
1571
        #       as all callers should have already converted the revision_id to
 
1572
        #       utf8
 
1573
        inventory.revision_id = osutils.safe_revision_id(revision_id)
1566
1574
        return xml6.serializer_v6.write_inventory_to_string(inventory)
1567
1575
 
1568
1576
    def _cache_basis_inventory(self, new_revision):
1955
1963
    def _last_revision(self):
1956
1964
        """See Mutable.last_revision."""
1957
1965
        try:
1958
 
            return self._control_files.get('last-revision').read()
 
1966
            return osutils.safe_revision_id(
 
1967
                        self._control_files.get('last-revision').read())
1959
1968
        except errors.NoSuchFile:
1960
1969
            return None
1961
1970
 
2135
2144
            raise errors.NotLocalUrl(a_bzrdir.transport.base)
2136
2145
        branch = a_bzrdir.open_branch()
2137
2146
        if revision_id is not None:
 
2147
            revision_id = osutils.safe_revision_id(revision_id)
2138
2148
            branch.lock_write()
2139
2149
            try:
2140
2150
                revision_history = branch.revision_history()
2226
2236
        branch = a_bzrdir.open_branch()
2227
2237
        if revision_id is None:
2228
2238
            revision_id = branch.last_revision()
 
2239
        else:
 
2240
            revision_id = osutils.safe_revision_id(revision_id)
2229
2241
        # WorkingTree3 can handle an inventory which has a unique root id.
2230
2242
        # as of bzr 0.12. However, bzr 0.11 and earlier fail to handle
2231
2243
        # those trees. And because there isn't a format bump inbetween, we