/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2011-12-30 00:03:32 UTC
  • mto: This revision was merged to the branch mainline in revision 6464.
  • Revision ID: jelmer@samba.org-20111230000332-4bqtm3fb2bqywtly
UseĀ _path2inv_file_id.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2178
2178
    def get_file_mtime(self, file_id, path=None):
2179
2179
        """See Tree.get_file_mtime."""
2180
2180
        if not path:
2181
 
            path = self.inventory.id2path(file_id)
 
2181
            path = self.id2path(file_id)
2182
2182
        try:
2183
2183
            return os.lstat(self.abspath(path)).st_mtime
2184
2184
        except OSError, e:
2336
2336
            for s in _mod_rio.RioReader(hashfile):
2337
2337
                # RioReader reads in Unicode, so convert file_ids back to utf8
2338
2338
                file_id = osutils.safe_file_id(s.get("file_id"), warn=False)
2339
 
                if not self.inventory.has_id(file_id):
 
2339
                if not self.has_id(file_id):
2340
2340
                    continue
2341
2341
                text_hash = s.get("hash")
2342
2342
                if text_hash == self.get_file_sha1(file_id):
2602
2602
        rename_entries = []
2603
2603
        rename_tuples = []
2604
2604
 
 
2605
        invs_to_write = set()
 
2606
 
2605
2607
        # check for deprecated use of signature
2606
2608
        if to_dir is None:
2607
2609
            raise TypeError('You must supply a target directory')
2608
2610
        # check destination directory
2609
2611
        if isinstance(from_paths, basestring):
2610
2612
            raise ValueError()
2611
 
        inv = self.inventory
2612
2613
        to_abs = self.abspath(to_dir)
2613
2614
        if not isdir(to_abs):
2614
2615
            raise errors.BzrMoveFailedError('',to_dir,
2616
2617
        if not self.has_filename(to_dir):
2617
2618
            raise errors.BzrMoveFailedError('',to_dir,
2618
2619
                errors.NotInWorkingDirectory(to_dir))
2619
 
        to_dir_id = inv.path2id(to_dir)
 
2620
        to_inv, to_dir_id = self._path2inv_file_id(to_dir)
2620
2621
        if to_dir_id is None:
2621
2622
            raise errors.BzrMoveFailedError('',to_dir,
2622
2623
                errors.NotVersionedError(path=to_dir))
2623
2624
 
2624
 
        to_dir_ie = inv[to_dir_id]
 
2625
        to_dir_ie = to_inv[to_dir_id]
2625
2626
        if to_dir_ie.kind != 'directory':
2626
2627
            raise errors.BzrMoveFailedError('',to_dir,
2627
2628
                errors.NotADirectory(to_abs))
2629
2630
        # create rename entries and tuples
2630
2631
        for from_rel in from_paths:
2631
2632
            from_tail = splitpath(from_rel)[-1]
2632
 
            from_id = inv.path2id(from_rel)
 
2633
            from_inv, from_id = self._path2inv_file_id(from_rel)
2633
2634
            if from_id is None:
2634
2635
                raise errors.BzrMoveFailedError(from_rel,to_dir,
2635
2636
                    errors.NotVersionedError(path=from_rel))
2636
2637
 
2637
 
            from_entry = inv[from_id]
 
2638
            from_entry = from_inv[from_id]
2638
2639
            from_parent_id = from_entry.parent_id
2639
2640
            to_rel = pathjoin(to_dir, from_tail)
2640
2641
            rename_entry = InventoryWorkingTree._RenameEntry(
2659
2660
            # restore the inventory on error
2660
2661
            self._inventory_is_modified = original_modified
2661
2662
            raise
2662
 
        self._write_inventory(inv)
 
2663
        #FIXME: Should potentially also write the from_invs
 
2664
        self._write_inventory(to_inv)
2663
2665
        return rename_tuples
2664
2666
 
2665
2667
    @needs_tree_write_lock
2685
2687
 
2686
2688
        Everything else results in an error.
2687
2689
        """
2688
 
        inv = self.inventory
2689
2690
        rename_entries = []
2690
2691
 
2691
2692
        # create rename entries and tuples
2692
2693
        from_tail = splitpath(from_rel)[-1]
2693
 
        from_id = inv.path2id(from_rel)
 
2694
        from_inv, from_id = self._path2inv_file_id(from_rel)
2694
2695
        if from_id is None:
2695
2696
            # if file is missing in the inventory maybe it's in the basis_tree
2696
2697
            basis_tree = self.branch.basis_tree()
2700
2701
                    errors.NotVersionedError(path=from_rel))
2701
2702
            # put entry back in the inventory so we can rename it
2702
2703
            from_entry = basis_tree.inventory[from_id].copy()
2703
 
            inv.add(from_entry)
 
2704
            from_inv.add(from_entry)
2704
2705
        else:
2705
 
            from_entry = inv[from_id]
 
2706
            from_inv, from_inv_id = self._unpack_file_id(from_id)
 
2707
            from_entry = from_inv[from_inv_id]
2706
2708
        from_parent_id = from_entry.parent_id
2707
2709
        to_dir, to_tail = os.path.split(to_rel)
2708
 
        to_dir_id = inv.path2id(to_dir)
 
2710
        to_inv, to_dir_id = self._path2inv_file_id(to_dir)
2709
2711
        rename_entry = InventoryWorkingTree._RenameEntry(from_rel=from_rel,
2710
2712
                                     from_id=from_id,
2711
2713
                                     from_tail=from_tail,
2733
2735
               from_id, from_rel, to_rel, to_dir, to_dir_id)
2734
2736
 
2735
2737
        self._move(rename_entries)
2736
 
        self._write_inventory(inv)
 
2738
        self._write_inventory(to_inv)
2737
2739
 
2738
2740
    class _RenameEntry(object):
2739
2741
        def __init__(self, from_rel, from_id, from_tail, from_parent_id,