~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

(mbp) 0.8.1 fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
from bzrlib.testament import Testament
90
90
from bzrlib.trace import mutter, note, warning
91
91
from bzrlib.xml5 import serializer_v5
92
 
from bzrlib.inventory import Inventory, ROOT_ID
 
92
from bzrlib.inventory import Inventory, ROOT_ID, InventoryEntry
93
93
from bzrlib.symbol_versioning import *
94
94
from bzrlib.workingtree import WorkingTree
95
95
 
124
124
    def missing(self, path):
125
125
        pass
126
126
 
 
127
    def renamed(self, change, old_path, new_path):
 
128
        pass
 
129
 
127
130
 
128
131
class ReportCommitToLog(NullCommitReporter):
129
132
 
 
133
    # this may be more useful if 'note' was replaced by an overridable
 
134
    # method on self, which would allow more trivial subclassing.
 
135
    # alternative, a callable could be passed in, allowing really trivial
 
136
    # reuse for some uis. RBC 20060511
 
137
 
130
138
    def snapshot_change(self, change, path):
131
139
        if change == 'unchanged':
132
140
            return
144
152
    def missing(self, path):
145
153
        note('missing %s', path)
146
154
 
 
155
    def renamed(self, change, old_path, new_path):
 
156
        note('%s %s => %s', change, old_path, new_path)
 
157
 
147
158
 
148
159
class Commit(object):
149
160
    """Task of committing a new revision.
509
520
                self.weave_store,
510
521
                self.branch.repository.get_transaction())
511
522
            if ie.revision is None:
512
 
                change = ie.snapshot(self.rev_id, path, previous_entries,
513
 
                                     self.work_tree, self.weave_store,
514
 
                                     self.branch.get_transaction())
515
 
            else:
516
 
                change = "unchanged"
517
 
            self.reporter.snapshot_change(change, path)
 
523
                # we are creating a new revision for ie in the history store
 
524
                # and inventory.
 
525
                ie.snapshot(self.rev_id, path, previous_entries,
 
526
                    self.work_tree, self.weave_store,
 
527
                    self.branch.repository.get_transaction())
 
528
            # describe the nature of the change that has occured relative to
 
529
            # the basis inventory.
 
530
            if (self.basis_inv.has_id(ie.file_id)):
 
531
                basis_ie = self.basis_inv[ie.file_id]
 
532
            else:
 
533
                basis_ie = None
 
534
            change = ie.describe_change(basis_ie, ie)
 
535
            if change in (InventoryEntry.RENAMED, 
 
536
                InventoryEntry.MODIFIED_AND_RENAMED):
 
537
                old_path = self.basis_inv.id2path(ie.file_id)
 
538
                self.reporter.renamed(change, old_path, path)
 
539
            else:
 
540
                self.reporter.snapshot_change(change, path)
518
541
 
519
542
    def _populate_new_inv(self):
520
543
        """Build revision inventory.
567
590
            self.new_inv.add(self.basis_inv[file_id].copy())
568
591
 
569
592
    def _report_deletes(self):
570
 
        for file_id in self.basis_inv:
571
 
            if file_id not in self.new_inv:
572
 
                self.reporter.deleted(self.basis_inv.id2path(file_id))
 
593
        for path, ie in self.basis_inv.iter_entries():
 
594
            if ie.file_id not in self.new_inv:
 
595
                self.reporter.deleted(path)
573
596
 
574
597
def _gen_revision_id(config, when):
575
598
    """Return new revision-id."""