161
162
def _diff(self, text_diff, from_label, tree, to_label, to_entry, to_tree,
162
163
output_to, reverse=False):
163
164
"""Perform a diff between two entries of the same kind."""
165
def find_previous_heads(self, previous_inventories,
166
versioned_file_store,
169
"""Return the revisions and entries that directly precede this.
171
Returned as a map from revision to inventory entry.
173
This is a map containing the file revisions in all parents
174
for which the file exists, and its revision is not a parent of
175
any other. If the file is new, the set will be empty.
177
:param versioned_file_store: A store where ancestry data on this
178
file id can be queried.
179
:param transaction: The transaction that queries to the versioned
180
file store should be completed under.
181
:param entry_vf: The entry versioned file, if its already available.
166
def parent_candidates(self, previous_inventories):
167
"""Find possible per-file graph parents.
169
This is currently defined by:
170
- Select the last changed revision in the parent inventory.
171
- Do deal with a short lived bug in bzr 0.8's development two entries
172
that have the same last changed but different 'x' bit settings are
183
def get_ancestors(weave, entry):
184
return set(weave.get_ancestry(entry.revision, topo_sorted=False))
185
175
# revision:ie mapping for each ie found in previous_inventories.
187
# revision:ie mapping with one revision for each head.
189
# revision: ancestor list for each head
191
177
# identify candidate head revision ids.
192
178
for inv in previous_inventories:
193
179
if self.file_id in inv:
194
180
ie = inv[self.file_id]
195
181
assert ie.file_id == self.file_id
196
if ie.kind != self.kind:
197
# Can't be a candidate if the kind has changed.
199
182
if ie.revision in candidates:
200
183
# same revision value in two different inventories:
201
184
# correct possible inconsistencies:
213
196
# add this revision as a candidate.
214
197
candidates[ie.revision] = ie
200
@deprecated_method(zero_ninetyone)
201
def find_previous_heads(self, previous_inventories,
202
versioned_file_store,
205
"""Return the revisions and entries that directly precede this.
207
Returned as a map from revision to inventory entry.
209
This is a map containing the file revisions in all parents
210
for which the file exists, and its revision is not a parent of
211
any other. If the file is new, the set will be empty.
213
:param versioned_file_store: A store where ancestry data on this
214
file id can be queried.
215
:param transaction: The transaction that queries to the versioned
216
file store should be completed under.
217
:param entry_vf: The entry versioned file, if its already available.
219
candidates = self.parent_candidates(previous_inventories)
221
# revision:ie mapping with one revision for each head.
216
223
# common case optimisation
217
224
if len(candidates) == 1:
218
225
# if there is only one candidate revision found
219
# then we can opening the versioned file to access ancestry:
226
# then we can avoid opening the versioned file to access ancestry:
220
227
# there cannot be any ancestors to eliminate when there is
221
228
# only one revision available.
222
heads[ie.revision] = ie
231
# --- what follows is now encapsulated in repository.get_graph.heads(),
232
# but that is not accessible from here as we have no repository
233
# pointer. Note that the repository.get_graph.heads() call can return
234
# different results *at the moment* because of the kind-changing check
235
# we have in parent_candidates().
225
237
# eliminate ancestors amongst the available candidates:
226
238
# heads are those that are not an ancestor of any other candidate
227
239
# - this provides convergence at a per-file level.
240
def get_ancestors(weave, entry):
241
return set(weave.get_ancestry(entry.revision, topo_sorted=False))
242
# revision: ancestor list for each head
228
244
for ie in candidates.values():
229
245
# may be an ancestor of a known head:
230
246
already_present = 0 != len(