~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Martin Pool
  • Date: 2006-04-19 05:11:59 UTC
  • mto: (1662.1.8 bzr.mbp.integration)
  • mto: This revision was merged to the branch mainline in revision 1675.
  • Revision ID: mbp@sourcefrog.net-20060419051159-856e022c4b11fcd4
verbose commit now specifically identifies modified/renamed/reparented files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# (C) 2005 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
348
348
        raise BzrCheckError('unknown entry kind %r in revision {%s}' % 
349
349
                            (self.kind, rev_id))
350
350
 
351
 
 
352
351
    def copy(self):
353
352
        """Clone this inventory entry."""
354
353
        raise NotImplementedError
355
354
 
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.
 
357
 
 
358
        :param previous_entries: Dictionary from revision_id to inventory entry.
 
359
 
 
360
        :returns: One-word description: "merged", "added", "renamed", "modified".
 
361
        """
 
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?
 
365
        #
 
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.
 
369
        #
357
370
        if len(previous_entries) > 1:
358
371
            return 'merged'
359
372
        elif len(previous_entries) == 0:
360
373
            return 'added'
361
 
        else:
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
 
377
            return 'renamed'
 
378
        elif self.name != the_parent.name:
 
379
            return 'renamed'
 
380
        return 'modified'
363
381
 
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)
389
 
 
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)
 
407
 
 
408
    def _snapshot_into_revision(self, revision, previous_entries, work_tree,
 
409
                                weave_store, transaction):
 
410
        """Record this revision unconditionally into a store.
 
411
 
 
412
        The entry's last-changed revision property (`revision`) is updated to 
 
413
        that of the new revision.
 
414
        
 
415
        :param revision: id of the new revision that is being recorded.
 
416
 
 
417
        :returns: String description of the commit (e.g. "merged", "modified"), etc.
 
418
        """
 
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,
397
423
                            transaction)
398
424
        return change