~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-09 20:23:07 UTC
  • mfrom: (4265.1.4 bbc-merge)
  • Revision ID: pqm@pqm.ubuntu.com-20090409202307-n0depb16qepoe21o
(jam) Change _fetch_uses_deltas = False for CHK repos until we can
        write a better fix.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
import os
21
21
from collections import deque
 
22
from cStringIO import StringIO
22
23
 
23
24
import bzrlib
24
25
from bzrlib import (
29
30
    osutils,
30
31
    revision as _mod_revision,
31
32
    rules,
 
33
    symbol_versioning,
32
34
    )
33
35
from bzrlib.decorators import needs_read_lock
34
 
from bzrlib.errors import BzrError, NoSuchId
 
36
from bzrlib.errors import BzrError, BzrCheckError, NoSuchId
35
37
from bzrlib import errors
36
 
from bzrlib.inventory import InventoryFile
 
38
from bzrlib.inventory import Inventory, InventoryFile
37
39
from bzrlib.inter import InterObject
38
40
from bzrlib.osutils import fingerprint_file
39
41
import bzrlib.revision
40
42
from bzrlib.symbol_versioning import deprecated_function, deprecated_in
41
 
from bzrlib.trace import note
 
43
from bzrlib.trace import mutter, note
42
44
 
43
45
 
44
46
class Tree(object):
133
135
        return self.has_id(file_id)
134
136
 
135
137
    def has_or_had_id(self, file_id):
 
138
        if file_id == self.inventory.root.file_id:
 
139
            return True
136
140
        return self.inventory.has_id(file_id)
137
141
 
138
142
    def is_ignored(self, filename):
198
202
            specific_file_ids=specific_file_ids)
199
203
 
200
204
    def iter_references(self):
201
 
        if self.supports_tree_reference():
202
 
            for path, entry in self.iter_entries_by_dir():
203
 
                if entry.kind == 'tree-reference':
204
 
                    yield path, entry.file_id
 
205
        for path, entry in self.iter_entries_by_dir():
 
206
            if entry.kind == 'tree-reference':
 
207
                yield path, entry.file_id
205
208
 
206
209
    def kind(self, file_id):
207
210
        raise NotImplementedError("Tree subclass %s must implement kind"
259
262
        """
260
263
        raise NotImplementedError(self.get_file)
261
264
 
262
 
    def get_file_with_stat(self, file_id, path=None):
263
 
        """Get a file handle and stat object for file_id.
264
 
 
265
 
        The default implementation returns (self.get_file, None) for backwards
266
 
        compatibility.
267
 
 
268
 
        :param file_id: The file id to read.
269
 
        :param path: The path of the file, if it is known.
270
 
        :return: A tuple (file_handle, stat_value_or_None). If the tree has
271
 
            no stat facility, or need for a stat cache feedback during commit,
272
 
            it may return None for the second element of the tuple.
273
 
        """
274
 
        return (self.get_file(file_id, path), None)
275
 
 
276
265
    def get_file_text(self, file_id, path=None):
277
266
        """Return the byte content of a file.
278
267
 
433
422
        raise NotImplementedError(self.annotate_iter)
434
423
 
435
424
    def _get_plan_merge_data(self, file_id, other, base):
436
 
        from bzrlib import versionedfile
 
425
        from bzrlib import merge, versionedfile
437
426
        vf = versionedfile._PlanMergeVersionedFile(file_id)
438
427
        last_revision_a = self._get_file_revision(file_id, vf, 'this:')
439
428
        last_revision_b = other._get_file_revision(file_id, vf, 'other:')
668
657
            return None
669
658
 
670
659
    def iter_search_rules(self, path_names, pref_names=None,
671
 
        _default_searcher=None):
 
660
        _default_searcher=rules._per_user_searcher):
672
661
        """Find the preferences for filenames in a tree.
673
662
 
674
663
        :param path_names: an iterable of paths to find attributes for.
678
667
        :return: an iterator of tuple sequences, one per path-name.
679
668
          See _RulesSearcher.get_items for details on the tuple sequence.
680
669
        """
681
 
        if _default_searcher is None:
682
 
            _default_searcher = rules._per_user_searcher
683
670
        searcher = self._get_rules_searcher(_default_searcher)
684
671
        if searcher is not None:
685
672
            if pref_names is not None:
823
810
        new_pending = set()
824
811
        for file_id in pending:
825
812
            for tree in trees:
826
 
                if not tree.has_or_had_id(file_id):
 
813
                if not tree.has_id(file_id):
827
814
                    continue
828
815
                for child_id in tree.iter_children(file_id):
829
816
                    if child_id not in interesting_ids: