/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/transform.py

Added TreeTransform.final_kind

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import os
2
 
from bzrlib.errors import DuplicateKey, MalformedTransform
 
2
from bzrlib.errors import DuplicateKey, MalformedTransform, NoSuchFile
 
3
from osutils import file_kind
3
4
def unique_add(map, key, value):
4
5
    if key in map:
5
6
        raise DuplicateKey(key=key)
21
22
        self._new_contents = {}
22
23
        self._new_id = {}
23
24
        self._tree_path_ids = {}
 
25
        self._tree_id_paths = {}
24
26
        self._new_root = self.get_id_tree(tree.get_root_id())
25
27
 
26
28
    def finalize(self):
59
61
        path = os.path.realpath(path)
60
62
        if path not in self._tree_path_ids:
61
63
            self._tree_path_ids[path] = self._assign_id()
 
64
            self._tree_id_paths[self._tree_path_ids[path]] = path
62
65
        return self._tree_path_ids[path]
63
66
 
64
67
    def create_file(self, contents, trans_id):
82
85
        new_paths.sort()
83
86
        return new_paths
84
87
 
 
88
    def final_kind(self, trans_id):
 
89
        """Determine the final file kind, after any changes applied.
 
90
        
 
91
        Raises NoSuchFile if the file does not exist/has no contents.
 
92
        (It is conceivable that a path would be created without the
 
93
        corresponding contents insertion command)
 
94
        """
 
95
        if trans_id in self._new_contents:
 
96
            return self._new_contents[trans_id][0]
 
97
        else:
 
98
            path = self._tree_id_paths.get(trans_id)
 
99
            if path is None:
 
100
                raise NoSuchFile(None)
 
101
            try:
 
102
                return file_kind(path)
 
103
            except OSError, e:
 
104
                if e.errno != errno.ENOENT:
 
105
                    raise
 
106
                else:
 
107
                    raise NoSuchFile(path)
 
108
 
85
109
    def find_conflicts(self):
86
110
        """Find any violations of inventory of filesystem invariants"""
87
111
        # No directory may have two entries with the same name