45
45
self._rules_searcher = None
47
47
def supports_tree_reference(self):
48
return getattr(self._repository._format, "supports_tree_reference",
50
51
def get_parent_ids(self):
51
52
"""See Tree.get_parent_ids.
86
87
default_revision=revision.CURRENT_REVISION):
87
88
"""See Tree.annotate_iter"""
88
89
text_key = (file_id, self.inventory[file_id].revision)
89
annotations = self._repository.texts.annotate(text_key)
90
annotator = self._repository.texts.get_annotator()
91
annotations = annotator.annotate_flat(text_key)
90
92
return [(key[-1], line) for key, line in annotations]
92
94
def get_file_size(self, file_id):
102
104
def get_file_mtime(self, file_id, path=None):
103
105
ie = self._inventory[file_id]
104
revision = self._repository.get_revision(ie.revision)
107
revision = self._repository.get_revision(ie.revision)
108
except errors.NoSuchRevision:
109
raise errors.FileTimestampUnavailable(self.id2path(file_id))
105
110
return revision.timestamp
107
112
def is_executable(self, file_id, path=None):
113
118
def has_filename(self, filename):
114
119
return bool(self.inventory.path2id(filename))
116
def list_files(self, include_root=False):
121
def list_files(self, include_root=False, from_dir=None, recursive=True):
117
122
# The only files returned by this are those from the version
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:
127
from_dir_id = inv.path2id(from_dir)
128
if from_dir_id is None:
129
# Directory not versioned
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:
121
133
# skip the root for compatability with the current apis.
123
135
for path, entry in entries:
126
138
def get_symlink_target(self, file_id):
127
139
ie = self._inventory[file_id]
128
return ie.symlink_target;
140
# Inventories store symlink targets in unicode
141
return ie.symlink_target
130
143
def get_reference_revision(self, file_id, path=None):
131
144
return self.inventory[file_id].reference_revision
232
245
lookup_trees = [self.source]
234
247
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 = {}
235
251
if specific_files == []:
236
252
specific_file_ids = []
238
254
specific_file_ids = self.target.paths2ids(specific_files,
239
255
lookup_trees, require_versioned=require_versioned)
241
256
# FIXME: It should be possible to delegate include_unchanged handling
242
257
# to CHKInventory.iter_changes and do a better job there -- vila
244
if include_unchanged:
245
changed_file_ids = []
259
changed_file_ids = set()
246
260
for result in self.target.inventory.iter_changes(self.source.inventory):
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.
261
if specific_file_ids is not None:
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
267
discarded_changes[result[0]] = result
269
new_parent_id = result[4][1]
270
precise_file_ids.add(new_parent_id)
253
if include_unchanged:
254
# Keep track of yielded results (cheaper than building the
256
changed_file_ids.append(result[0])
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):
257
277
if include_unchanged:
258
278
# CHKMap avoid being O(tree), so we go to O(tree) only if
260
280
# Now walk the whole inventory, excluding the already yielded
262
def not_a_change(file_id, relpath, parent, kind, executable):
264
(relpath, relpath), # Not renamed
265
False, # Not modified
266
(True, True), # Still versioned
267
(executable, executable))
268
282
changed_file_ids = set(changed_file_ids)
269
283
for relpath, entry in self.target.inventory.iter_entries():
270
284
if (specific_file_ids is not None
273
287
if not entry.file_id in changed_file_ids:
274
288
yield (entry.file_id,
289
(relpath, relpath), # Not renamed
290
False, # Not modified
291
(True, True), # Still versioned
278
292
(entry.parent_id, entry.parent_id),
279
293
(entry.name, entry.name),
280
294
(entry.kind, entry.kind),