103
103
self._inventory = inv
105
105
def get_file_mtime(self, file_id, path=None):
106
ie = self._inventory[file_id]
106
inv, inv_file_id = self._unpack_file_id(file_id)
107
ie = inv[inv_file_id]
108
109
revision = self._repository.get_revision(ie.revision)
109
110
except errors.NoSuchRevision:
111
112
return revision.timestamp
113
114
def get_file_size(self, file_id):
114
return self._inventory[file_id].text_size
115
inv, inv_file_id = self._unpack_file_id(file_id)
116
return inv[inv_file_id].text_size
116
118
def get_file_sha1(self, file_id, path=None, stat_value=None):
117
ie = self._inventory[file_id]
119
inv, inv_file_id = self._unpack_file_id(file_id)
120
ie = inv[inv_file_id]
118
121
if ie.kind == "file":
119
122
return ie.text_sha1
122
125
def get_file_revision(self, file_id, path=None):
123
ie = self._inventory[file_id]
126
inv, inv_file_id = self._unpack_file_id(file_id)
127
ie = inv[inv_file_id]
124
128
return ie.revision
126
130
def is_executable(self, file_id, path=None):
127
ie = self._inventory[file_id]
131
inv, inv_file_id = self._unpack_file_id(file_id)
132
ie = inv[inv_file_id]
128
133
if ie.kind != "file":
130
135
return ie.executable
132
137
def has_filename(self, filename):
133
return bool(self.inventory.path2id(filename))
138
return bool(self.path2id(filename))
135
140
def list_files(self, include_root=False, from_dir=None, recursive=True):
136
141
# The only files returned by this are those from the version
138
142
if from_dir is None:
139
143
from_dir_id = None
144
inv = self.root_inventory
141
from_dir_id = inv.path2id(from_dir)
146
inv, from_dir_id = self._path2inv_file_id(from_dir)
142
147
if from_dir_id is None:
143
148
# Directory not versioned
150
155
yield path, 'V', entry.kind, entry.file_id, entry
152
157
def get_symlink_target(self, file_id, path=None):
153
ie = self._inventory[file_id]
158
inv, inv_file_id = self._unpack_file_id(file_id)
159
ie = inv[inv_file_id]
154
160
# Inventories store symlink targets in unicode
155
161
return ie.symlink_target
157
163
def get_reference_revision(self, file_id, path=None):
158
return self.inventory[file_id].reference_revision
164
inv, inv_file_id = self._unpack_file_id(file_id)
165
return inv[inv_file_id].reference_revision
160
167
def get_root_id(self):
161
if self.inventory.root:
162
return self.inventory.root.file_id
168
if self.root_inventory.root:
169
return self.root_inventory.root.file_id
164
171
def kind(self, file_id):
165
return self._inventory[file_id].kind
172
inv, inv_file_id = self._unpack_file_id(file_id)
173
return inv[inv_file_id].kind
167
175
def path_content_summary(self, path):
168
176
"""See Tree.path_content_summary."""
169
id = self.inventory.path2id(path)
177
inv, file_id = self._path2inv_file_id(path)
171
179
return ('missing', None, None, None)
172
entry = self._inventory[id]
173
181
kind = entry.kind
174
182
if kind == 'file':
175
183
return (kind, entry.text_size, entry.executable, entry.text_sha1)
245
252
and isinstance(target, RevisionTree)):
247
254
# Only CHK inventories have id_to_entry attribute
248
source.inventory.id_to_entry
249
target.inventory.id_to_entry
255
source.root_inventory.id_to_entry
256
target.root_inventory.id_to_entry
251
258
except AttributeError:
270
277
# to CHKInventory.iter_changes and do a better job there -- vila
272
279
changed_file_ids = set()
273
for result in self.target.inventory.iter_changes(self.source.inventory):
280
# FIXME: nested tree support
281
for result in self.target.root_inventory.iter_changes(
282
self.source.root_inventory):
274
283
if specific_file_ids is not None:
275
284
file_id = result[0]
276
285
if file_id not in specific_file_ids:
293
302
# Now walk the whole inventory, excluding the already yielded
304
# FIXME: Support nested trees
295
305
changed_file_ids = set(changed_file_ids)
296
for relpath, entry in self.target.inventory.iter_entries():
306
for relpath, entry in self.target.root_inventory.iter_entries():
297
307
if (specific_file_ids is not None
298
308
and not entry.file_id in specific_file_ids):