~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Martin Pool
  • Date: 2011-06-14 01:43:10 UTC
  • mto: This revision was merged to the branch mainline in revision 6002.
  • Revision ID: mbp@canonical.com-20110614014310-g5ww9c5gieo2cg5k
test_fifo_cache shouldn't have a knownfailure for something that's impossible

Show diffs side-by-side

added added

removed removed

Lines of Context:
496
496
        finally:
497
497
            file.close()
498
498
 
 
499
    def _get_ancestors(self, default_revision):
 
500
        ancestors = set([default_revision])
 
501
        for parent_id in self.get_parent_ids():
 
502
            ancestors.update(self.branch.repository.get_ancestry(
 
503
                             parent_id, topo_sorted=False))
 
504
        return ancestors
 
505
 
499
506
    def get_parent_ids(self):
500
507
        """See Tree.get_parent_ids.
501
508
 
966
973
        file and change the file_id. That is the normal mode. Second, it can
967
974
        only change the file_id without touching any physical file.
968
975
 
969
 
        rename_one uses the second mode if 'after == True' and 'to_rel' is
970
 
        either not versioned or newly added, and present in the working tree.
 
976
        rename_one uses the second mode if 'after == True' and 'to_rel' is not
 
977
        versioned but present in the working tree.
971
978
 
972
979
        rename_one uses the second mode if 'after == False' and 'from_rel' is
973
980
        versioned but no longer in the working tree, and 'to_rel' is not
1378
1385
    def revert(self, filenames=None, old_tree=None, backups=True,
1379
1386
               pb=None, report_changes=False):
1380
1387
        from bzrlib.conflicts import resolve
 
1388
        if filenames == []:
 
1389
            filenames = None
 
1390
            symbol_versioning.warn('Using [] to revert all files is deprecated'
 
1391
                ' as of bzr 0.91.  Please use None (the default) instead.',
 
1392
                DeprecationWarning, stacklevel=2)
1381
1393
        if old_tree is None:
1382
1394
            basis_tree = self.basis_tree()
1383
1395
            basis_tree.lock_read()
2077
2089
            return True
2078
2090
        return self.inventory.has_id(file_id)
2079
2091
 
 
2092
    __contains__ = has_id
 
2093
 
2080
2094
    @symbol_versioning.deprecated_method(symbol_versioning.deprecated_in((2, 4, 0)))
2081
2095
    def __iter__(self):
2082
2096
        """Iterate through file_ids for this tree.
2258
2272
                parent_tree = self.branch.repository.revision_tree(parent_id)
2259
2273
            parent_tree.lock_read()
2260
2274
            try:
2261
 
                if not parent_tree.has_id(file_id):
 
2275
                if file_id not in parent_tree:
2262
2276
                    continue
2263
2277
                ie = parent_tree.inventory[file_id]
2264
2278
                if ie.kind != 'file':
2312
2326
            for s in _mod_rio.RioReader(hashfile):
2313
2327
                # RioReader reads in Unicode, so convert file_ids back to utf8
2314
2328
                file_id = osutils.safe_file_id(s.get("file_id"), warn=False)
2315
 
                if not self.inventory.has_id(file_id):
 
2329
                if file_id not in self.inventory:
2316
2330
                    continue
2317
2331
                text_hash = s.get("hash")
2318
2332
                if text_hash == self.get_file_sha1(file_id):
2559
2573
        inventory. The second mode only updates the inventory without
2560
2574
        touching the file on the filesystem.
2561
2575
 
2562
 
        move uses the second mode if 'after == True' and the target is
2563
 
        either not versioned or newly added, and present in the working tree.
 
2576
        move uses the second mode if 'after == True' and the target is not
 
2577
        versioned but present in the working tree.
2564
2578
 
2565
2579
        move uses the second mode if 'after == False' and the source is
2566
2580
        versioned but no longer in the working tree, and the target is not
2713
2727
 
2714
2728
    class _RenameEntry(object):
2715
2729
        def __init__(self, from_rel, from_id, from_tail, from_parent_id,
2716
 
                     to_rel, to_tail, to_parent_id, only_change_inv=False,
2717
 
                     change_id=False):
 
2730
                     to_rel, to_tail, to_parent_id, only_change_inv=False):
2718
2731
            self.from_rel = from_rel
2719
2732
            self.from_id = from_id
2720
2733
            self.from_tail = from_tail
2722
2735
            self.to_rel = to_rel
2723
2736
            self.to_tail = to_tail
2724
2737
            self.to_parent_id = to_parent_id
2725
 
            self.change_id = change_id
2726
2738
            self.only_change_inv = only_change_inv
2727
2739
 
2728
2740
    def _determine_mv_mode(self, rename_entries, after=False):
2740
2752
            to_rel = rename_entry.to_rel
2741
2753
            to_id = inv.path2id(to_rel)
2742
2754
            only_change_inv = False
2743
 
            change_id = False
2744
2755
 
2745
2756
            # check the inventory for source and destination
2746
2757
            if from_id is None:
2747
2758
                raise errors.BzrMoveFailedError(from_rel,to_rel,
2748
2759
                    errors.NotVersionedError(path=from_rel))
2749
2760
            if to_id is not None:
2750
 
                allowed = False
2751
 
                # allow it with --after but only if dest is newly added
2752
 
                if after:
2753
 
                    basis = self.basis_tree()
2754
 
                    basis.lock_read()
2755
 
                    try:
2756
 
                        if not basis.has_id(to_id):
2757
 
                            rename_entry.change_id = True
2758
 
                            allowed = True
2759
 
                    finally:
2760
 
                        basis.unlock()
2761
 
                if not allowed:
2762
 
                    raise errors.BzrMoveFailedError(from_rel,to_rel,
2763
 
                        errors.AlreadyVersionedError(path=to_rel))
 
2761
                raise errors.BzrMoveFailedError(from_rel,to_rel,
 
2762
                    errors.AlreadyVersionedError(path=to_rel))
2764
2763
 
2765
2764
            # try to determine the mode for rename (only change inv or change
2766
2765
            # inv and file system)
2837
2836
            except OSError, e:
2838
2837
                raise errors.BzrMoveFailedError(entry.from_rel,
2839
2838
                    entry.to_rel, e[1])
2840
 
        if entry.change_id:
2841
 
            to_id = inv.path2id(entry.to_rel)
2842
 
            inv.remove_recursive_id(to_id)
2843
2839
        inv.rename(entry.from_id, entry.to_parent_id, entry.to_tail)
2844
2840
 
2845
2841
    @needs_tree_write_lock
2853
2849
        :raises: NoSuchId if any fileid is not currently versioned.
2854
2850
        """
2855
2851
        for file_id in file_ids:
2856
 
            if not self._inventory.has_id(file_id):
 
2852
            if file_id not in self._inventory:
2857
2853
                raise errors.NoSuchId(self, file_id)
2858
2854
        for file_id in file_ids:
2859
2855
            if self._inventory.has_id(file_id):
3014
3010
    missing_parent_conflicts = False
3015
3011
    """If this format supports missing parent conflicts."""
3016
3012
 
3017
 
    supports_versioned_directories = None
3018
 
 
3019
3013
    @classmethod
3020
3014
    def find_format_string(klass, a_bzrdir):
3021
3015
        """Return format name for the working tree object in a_bzrdir."""