~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/revisiontree.py

  • Committer: Robert Collins
  • Date: 2009-04-27 03:27:46 UTC
  • mto: This revision was merged to the branch mainline in revision 4304.
  • Revision ID: robertc@robertcollins.net-20090427032746-vqmcsfbsbvbm04sk
Fixup tests broken by cleaning up the layering.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
        self._rules_searcher = None
46
46
 
47
47
    def supports_tree_reference(self):
48
 
        return getattr(self._repository._format, "supports_tree_reference",
49
 
            False)
 
48
        return True
50
49
 
51
50
    def get_parent_ids(self):
52
51
        """See Tree.get_parent_ids.
87
86
                      default_revision=revision.CURRENT_REVISION):
88
87
        """See Tree.annotate_iter"""
89
88
        text_key = (file_id, self.inventory[file_id].revision)
90
 
        annotator = self._repository.texts.get_annotator()
91
 
        annotations = annotator.annotate_flat(text_key)
 
89
        annotations = self._repository.texts.annotate(text_key)
92
90
        return [(key[-1], line) for key, line in annotations]
93
91
 
94
92
    def get_file_size(self, file_id):
103
101
 
104
102
    def get_file_mtime(self, file_id, path=None):
105
103
        ie = self._inventory[file_id]
106
 
        try:
107
 
            revision = self._repository.get_revision(ie.revision)
108
 
        except errors.NoSuchRevision:
109
 
            raise errors.FileTimestampUnavailable(self.id2path(file_id))
 
104
        revision = self._repository.get_revision(ie.revision)
110
105
        return revision.timestamp
111
106
 
112
107
    def is_executable(self, file_id, path=None):
118
113
    def has_filename(self, filename):
119
114
        return bool(self.inventory.path2id(filename))
120
115
 
121
 
    def list_files(self, include_root=False, from_dir=None, recursive=True):
 
116
    def list_files(self, include_root=False):
122
117
        # The only files returned by this are those from the version
123
 
        inv = self.inventory
124
 
        if from_dir is None:
125
 
            from_dir_id = None
126
 
        else:
127
 
            from_dir_id = inv.path2id(from_dir)
128
 
            if from_dir_id is None:
129
 
                # Directory not versioned
130
 
                return
131
 
        entries = inv.iter_entries(from_dir=from_dir_id, recursive=recursive)
132
 
        if inv.root is not None and not include_root and from_dir is None:
 
118
        entries = self.inventory.iter_entries()
 
119
        # skip the root for compatability with the current apis.
 
120
        if self.inventory.root is not None and not include_root:
133
121
            # skip the root for compatability with the current apis.
134
122
            entries.next()
135
123
        for path, entry in entries:
137
125
 
138
126
    def get_symlink_target(self, file_id):
139
127
        ie = self._inventory[file_id]
140
 
        # Inventories store symlink targets in unicode
141
 
        return ie.symlink_target
 
128
        return ie.symlink_target;
142
129
 
143
130
    def get_reference_revision(self, file_id, path=None):
144
131
        return self.inventory[file_id].reference_revision
245
232
        lookup_trees = [self.source]
246
233
        if extra_trees:
247
234
             lookup_trees.extend(extra_trees)
248
 
        # The ids of items we need to examine to insure delta consistency.
249
 
        precise_file_ids = set()
250
 
        discarded_changes = {}
251
235
        if specific_files == []:
252
236
            specific_file_ids = []
253
237
        else:
254
238
            specific_file_ids = self.target.paths2ids(specific_files,
255
239
                lookup_trees, require_versioned=require_versioned)
 
240
 
256
241
        # FIXME: It should be possible to delegate include_unchanged handling
257
242
        # to CHKInventory.iter_changes and do a better job there -- vila
258
243
        # 20090304
259
 
        changed_file_ids = set()
 
244
        if include_unchanged:
 
245
            changed_file_ids = []
260
246
        for result in self.target.inventory.iter_changes(self.source.inventory):
261
 
            if specific_file_ids is not None:
262
 
                file_id = result[0]
263
 
                if file_id not in specific_file_ids:
264
 
                    # A change from the whole tree that we don't want to show yet.
265
 
                    # We may find that we need to show it for delta consistency, so
266
 
                    # stash it.
267
 
                    discarded_changes[result[0]] = result
268
 
                    continue
269
 
                new_parent_id = result[4][1]
270
 
                precise_file_ids.add(new_parent_id)
 
247
            if (specific_file_ids is not None
 
248
                and not result[0] in specific_file_ids):
 
249
                # CHKMap.iter_changes is clean and fast. Better filter out
 
250
                # the specific files *after* it did its job.
 
251
                continue
271
252
            yield result
272
 
            changed_file_ids.add(result[0])
273
 
        if specific_file_ids is not None:
274
 
            for result in self._handle_precise_ids(precise_file_ids,
275
 
                changed_file_ids, discarded_changes=discarded_changes):
276
 
                yield result
 
253
            if include_unchanged:
 
254
                # Keep track of yielded results (cheaper than building the
 
255
                # whole inventory).
 
256
                changed_file_ids.append(result[0])
277
257
        if include_unchanged:
278
258
            # CHKMap avoid being O(tree), so we go to O(tree) only if
279
259
            # required to.