348
348
raise BzrCheckError('unknown entry kind %r in revision {%s}' %
349
349
(self.kind, rev_id))
353
352
"""Clone this inventory entry."""
354
353
raise NotImplementedError
356
def _get_snapshot_change(self, previous_entries):
355
def _describe_snapshot_change(self, previous_entries):
356
"""Describe how this entry will have changed in a new commit.
358
:param previous_entries: Dictionary from revision_id to inventory entry.
360
:returns: One-word description: "merged", "added", "renamed", "modified".
362
# XXX: This assumes that the file *has* changed -- it should probably
363
# be fused with whatever does that detection. Why not just a single
364
# thing to compare the entries?
366
# TODO: Return some kind of object describing all the possible
367
# dimensions that can change, not just a string. That can then give
368
# both old and new names for renames, etc.
357
370
if len(previous_entries) > 1:
359
372
elif len(previous_entries) == 0:
362
return 'modified/renamed/reparented'
374
the_parent, = previous_entries.values()
375
if self.parent_id != the_parent.parent_id:
376
# actually, moved to another directory
378
elif self.name != the_parent.name:
364
382
def __repr__(self):
365
383
return ("%s(%r, %r, parent_id=%r)"
384
402
mutter("found unchanged entry")
385
403
self.revision = parent_ie.revision
386
404
return "unchanged"
387
return self.snapshot_revision(revision, previous_entries,
388
work_tree, weave_store, transaction)
390
def snapshot_revision(self, revision, previous_entries, work_tree,
391
weave_store, transaction):
392
"""Record this revision unconditionally."""
393
mutter('new revision for {%s}', self.file_id)
405
return self._snapshot_into_revision(revision, previous_entries,
406
work_tree, weave_store, transaction)
408
def _snapshot_into_revision(self, revision, previous_entries, work_tree,
409
weave_store, transaction):
410
"""Record this revision unconditionally into a store.
412
The entry's last-changed revision property (`revision`) is updated to
413
that of the new revision.
415
:param revision: id of the new revision that is being recorded.
417
:returns: String description of the commit (e.g. "merged", "modified"), etc.
419
mutter('new revision {%s} for {%s}', revision, self.file_id)
394
420
self.revision = revision
395
change = self._get_snapshot_change(previous_entries)
421
change = self._describe_snapshot_change(previous_entries)
396
422
self._snapshot_text(previous_entries, work_tree, weave_store,