44
44
# TODO: Update hashcache before and after - or does the WorkingTree
47
# This code requires all merge parents to be present in the branch.
48
# We could relax this but for the sake of simplicity the constraint is
49
# here for now. It's not totally clear to me how we'd know which file
50
# need new text versions if some parents are absent. -- mbp 20050915
52
47
# TODO: Rather than mashing together the ancestry and storing it back,
53
48
# perhaps the weave should have single method which does it all in one
54
49
# go, avoiding a lot of redundant work.
292
287
self.parents += pending_merges
293
288
for revision in self.parents:
294
289
if self.branch.has_revision(revision):
295
self.parent_trees.append(self.branch.revision_tree(revision))
290
self.parent_invs.append(self.branch.get_inventory(revision))
296
291
self.present_parents.append(revision)
298
293
def _check_parents_present(self):
346
341
del self.work_inv[file_id]
347
342
self.branch._write_inventory(self.work_inv)
350
def _find_entry_parents(self, file_id):
351
"""Return the text versions and hashes for all file parents.
353
Returned as a map from text version to inventory entry.
355
This is a set containing the file versions in all parents
356
revisions containing the file. If the file is new, the set
359
for tree in self.parent_trees:
360
if file_id in tree.inventory:
361
ie = tree.inventory[file_id]
362
assert ie.file_id == file_id
364
assert r[ie.revision] == ie
369
344
def _store_snapshot(self):
370
345
"""Pass over inventory and record a snapshot.
372
347
Entries get a new revision when they are modified in
373
348
any way, which includes a merge with a new set of
374
parents that have the same entry. Currently we do not
375
check for that set being ancestors of each other - and
376
we should - only parallel children should count for this
377
test see find_entry_parents to correct this. FIXME <---
378
I.e. if we are merging in revision FOO, and our
379
copy of file id BAR is identical to FOO.BAR, we should
380
generate a new revision of BAR IF and only IF FOO is
381
neither a child of our current tip, nor an ancestor of
382
our tip. The presence of FOO in our store should not
383
affect this logic UNLESS we are doing a merge of FOO,
349
parents that have the same entry.
386
351
# XXX: Need to think more here about when the user has
387
352
# made a specific decision on a particular value -- c.f.
389
354
for path, ie in self.new_inv.iter_entries():
390
previous_entries = self._find_entry_parents(ie. file_id)
355
previous_entries = ie.find_previous_heads(
357
self.weave_store.get_weave_or_empty(ie.file_id))
391
358
if ie.revision is None:
392
359
change = ie.snapshot(self.rev_id, path, previous_entries,
393
360
self.work_tree, self.weave_store)