~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

[merge] bzr.dev 2294

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)
1321
1325
                yield stem
1322
1326
 
1323
1327
    @needs_write_lock
1324
 
    def pull(self, source, overwrite=False, stop_revision=None):
 
1328
    def pull(self, source, overwrite=False, stop_revision=None,
 
1329
             change_reporter=None):
1325
1330
        top_pb = bzrlib.ui.ui_factory.nested_progress_bar()
1326
1331
        source.lock_read()
1327
1332
        try:
1328
1333
            pp = ProgressPhase("Pull phase", 2, top_pb)
1329
1334
            pp.next_phase()
1330
 
            old_revision_history = self.branch.revision_history()
 
1335
            old_revision_info = self.branch.last_revision_info()
1331
1336
            basis_tree = self.basis_tree()
1332
1337
            count = self.branch.pull(source, overwrite, stop_revision)
1333
 
            new_revision_history = self.branch.revision_history()
1334
 
            if new_revision_history != old_revision_history:
 
1338
            new_revision_info = self.branch.last_revision_info()
 
1339
            if new_revision_info != old_revision_info:
1335
1340
                pp.next_phase()
1336
 
                if len(old_revision_history):
1337
 
                    other_revision = old_revision_history[-1]
1338
 
                else:
1339
 
                    other_revision = None
1340
1341
                repository = self.branch.repository
1341
1342
                pb = bzrlib.ui.ui_factory.nested_progress_bar()
1342
1343
                basis_tree.lock_read()
1347
1348
                                new_basis_tree,
1348
1349
                                basis_tree,
1349
1350
                                this_tree=self,
1350
 
                                pb=pb)
 
1351
                                pb=pb,
 
1352
                                change_reporter=change_reporter)
1351
1353
                    if (basis_tree.inventory.root is None and
1352
1354
                        new_basis_tree.inventory.root is not None):
1353
1355
                        self.set_root_id(new_basis_tree.inventory.root.file_id)
1543
1545
    @needs_tree_write_lock
1544
1546
    def set_last_revision(self, new_revision):
1545
1547
        """Change the last revision in the working tree."""
 
1548
        new_revision = osutils.safe_revision_id(new_revision)
1546
1549
        if self._change_last_revision(new_revision):
1547
1550
            self._cache_basis_inventory(new_revision)
1548
1551
 
1571
1574
 
1572
1575
    def _create_basis_xml_from_inventory(self, revision_id, inventory):
1573
1576
        """Create the text that will be saved in basis-inventory"""
1574
 
        inventory.revision_id = revision_id
 
1577
        # TODO: jam 20070209 This should be redundant, as the revision_id
 
1578
        #       as all callers should have already converted the revision_id to
 
1579
        #       utf8
 
1580
        inventory.revision_id = osutils.safe_revision_id(revision_id)
1575
1581
        return xml6.serializer_v6.write_inventory_to_string(inventory)
1576
1582
 
1577
1583
    def _cache_basis_inventory(self, new_revision):
1650
1656
        for f in files:
1651
1657
            fid = inv.path2id(f)
1652
1658
            if not fid:
1653
 
                # TODO: Perhaps make this just a warning, and continue?
1654
 
                # This tends to happen when 
1655
 
                raise errors.NotVersionedError(path=f)
1656
 
            if verbose:
1657
 
                # having remove it, it must be either ignored or unknown
1658
 
                if self.is_ignored(f):
1659
 
                    new_status = 'I'
1660
 
                else:
1661
 
                    new_status = '?'
1662
 
                textui.show_status(new_status, inv[fid].kind, f,
1663
 
                                   to_file=to_file)
1664
 
            del inv[fid]
 
1659
                note("%s is not versioned."%f)
 
1660
            else:
 
1661
                if verbose:
 
1662
                    # having remove it, it must be either ignored or unknown
 
1663
                    if self.is_ignored(f):
 
1664
                        new_status = 'I'
 
1665
                    else:
 
1666
                        new_status = '?'
 
1667
                    textui.show_status(new_status, inv[fid].kind, f,
 
1668
                                       to_file=to_file)
 
1669
                del inv[fid]
1665
1670
 
1666
1671
        self._write_inventory(inv)
1667
1672
 
2143
2148
    def _last_revision(self):
2144
2149
        """See Mutable.last_revision."""
2145
2150
        try:
2146
 
            return self._control_files.get_utf8('last-revision').read()
 
2151
            return osutils.safe_revision_id(
 
2152
                        self._control_files.get('last-revision').read())
2147
2153
        except errors.NoSuchFile:
2148
2154
            return None
2149
2155
 
2324
2330
            raise errors.NotLocalUrl(a_bzrdir.transport.base)
2325
2331
        branch = a_bzrdir.open_branch()
2326
2332
        if revision_id is not None:
 
2333
            revision_id = osutils.safe_revision_id(revision_id)
2327
2334
            branch.lock_write()
2328
2335
            try:
2329
2336
                revision_history = branch.revision_history()
2415
2422
        branch = a_bzrdir.open_branch()
2416
2423
        if revision_id is None:
2417
2424
            revision_id = branch.last_revision()
 
2425
        else:
 
2426
            revision_id = osutils.safe_revision_id(revision_id)
2418
2427
        # WorkingTree3 can handle an inventory which has a unique root id.
2419
2428
        # as of bzr 0.12. However, bzr 0.11 and earlier fail to handle
2420
2429
        # those trees. And because there isn't a format bump inbetween, we