~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
    """
55
55
    
56
56
    def changes_from(self, other, want_unchanged=False, specific_files=None,
57
 
        extra_trees=None, require_versioned=False):
 
57
        extra_trees=None, require_versioned=False, include_root=False):
58
58
        """Return a TreeDelta of the changes from other to this tree.
59
59
 
60
60
        :param other: A tree to compare with.
81
81
            specific_files=specific_files,
82
82
            extra_trees=extra_trees,
83
83
            require_versioned=require_versioned,
 
84
            include_root=include_root
84
85
            )
85
86
    
86
87
    def conflicts(self):
119
120
    def id2path(self, file_id):
120
121
        return self.inventory.id2path(file_id)
121
122
 
 
123
    def is_control_filename(self, filename):
 
124
        """True if filename is the name of a control file in this tree.
 
125
        
 
126
        :param filename: A filename within the tree. This is a relative path
 
127
        from the root of this tree.
 
128
 
 
129
        This is true IF and ONLY IF the filename is part of the meta data
 
130
        that bzr controls in this tree. I.E. a random .bzr directory placed
 
131
        on disk will not be a control file for this tree.
 
132
        """
 
133
        return self.bzrdir.is_control_filename(filename)
 
134
 
122
135
    def iter_entries_by_dir(self):
123
136
        """Walk the tree in 'by_dir' order.
124
137
 
135
148
    def _get_inventory(self):
136
149
        return self._inventory
137
150
    
 
151
    def get_file(self, file_id):
 
152
        """Return a file object for the file file_id in the tree."""
 
153
        raise NotImplementedError(self.get_file)
 
154
    
138
155
    def get_file_by_path(self, path):
139
156
        return self.get_file(self._inventory.path2id(path))
140
157
 
147
164
        fp = fingerprint_file(f)
148
165
        f.seek(0)
149
166
        
150
 
        if ie.text_size != None:
 
167
        if ie.text_size is not None:
151
168
            if ie.text_size != fp['size']:
152
169
                raise BzrError("mismatched size for file %r in %r" % (ie.file_id, self._store),
153
170
                        ["inventory expects %d bytes" % ie.text_size,
160
177
                     "file is actually %s" % fp['sha1'],
161
178
                     "store is probably damaged/corrupt"])
162
179
 
 
180
    def path2id(self, path):
 
181
        """Return the id for path in this tree."""
 
182
        return self._inventory.path2id(path)
163
183
 
164
184
    def print_file(self, file_id):
165
185
        """Print file with id `file_id` to stdout."""
198
218
class EmptyTree(Tree):
199
219
 
200
220
    def __init__(self):
201
 
        self._inventory = Inventory()
 
221
        self._inventory = Inventory(root_id=None)
202
222
        warn('EmptyTree is deprecated as of bzr 0.9 please use '
203
223
            'repository.revision_tree instead.',
204
224
            DeprecationWarning, stacklevel=2)
216
236
        assert self._inventory[file_id].kind == "directory"
217
237
        return "directory"
218
238
 
219
 
    def list_files(self):
 
239
    def list_files(self, include_root=False):
220
240
        return iter([])
221
241
    
222
242
    def __contains__(self, file_id):
375
395
    will pass through to InterTree as appropriate.
376
396
    """
377
397
 
378
 
    _optimisers = set()
 
398
    _optimisers = []
379
399
 
380
400
    @needs_read_lock
381
401
    def compare(self, want_unchanged=False, specific_files=None,
382
 
        extra_trees=None, require_versioned=False):
 
402
        extra_trees=None, require_versioned=False, include_root=False):
383
403
        """Return the changes from source to target.
384
404
 
385
405
        :return: A TreeDelta.
407
427
            # _compare_trees would think we want a complete delta
408
428
            return delta.TreeDelta()
409
429
        return delta._compare_trees(self.source, self.target, want_unchanged,
410
 
            specific_file_ids)
 
430
            specific_file_ids, include_root)