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