/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Ian Clatworthy
  • Date: 2007-09-13 05:36:27 UTC
  • mto: (2819.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2820.
  • Revision ID: ian.clatworthy@internode.on.net-20070913053627-7pyodcq5oe2qdhhn
remove more reporting stuff

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
class NullCommitReporter(object):
88
88
    """I report on progress of a commit."""
89
89
 
90
 
    def __init__(self, show_change_total=False):
91
 
        self.show_change_total = show_change_total
92
 
        self.changes = 0
93
 
 
94
90
    def started(self, revno, revid, location=None):
95
91
        pass
96
92
 
112
108
    def renamed(self, change, old_path, new_path):
113
109
        pass
114
110
 
 
111
    def is_verbose(self):
 
112
        return False
 
113
 
 
114
 
 
115
class ReportCommitToLog(NullCommitReporter):
 
116
 
115
117
    def _note(self, format, *args):
116
118
        """Output a message.
117
119
 
119
121
        """
120
122
        note(format, *args)
121
123
 
122
 
    def _note_change(self, format, *args):
123
 
        self._note(format, *args)
124
 
        self.changes += 1
125
 
 
126
 
    def is_verbose(self):
127
 
        return False
128
 
 
129
 
 
130
 
class ReportCommitToLog(NullCommitReporter):
131
 
 
132
124
    def snapshot_change(self, change, path):
133
125
        if change == 'unchanged':
134
126
            return
135
127
        if change == 'added' and path == '':
136
128
            return
137
 
        self._note_change("%s %s", change, path)
 
129
        self._note("%s %s", change, path)
138
130
 
139
131
    def started(self, revno, rev_id, location=None):
140
132
        if location is not None:
144
136
        self._note('Committing revision %d%s.', revno, location)
145
137
 
146
138
    def completed(self, revno, rev_id):
147
 
        if not self.show_change_total:
148
 
            details = ''
149
 
        elif self.changes == 1:
150
 
            details = ' (%d change made)' % self.changes
151
 
        else:
152
 
            details = ' (%d changes made)' % self.changes
153
 
        self._note('Committed revision %d%s.', revno, details)
 
139
        self._note('Committed revision %d.', revno)
154
140
 
155
141
    def deleted(self, file_id):
156
 
        self._note_change('deleted %s', file_id)
 
142
        self._note('deleted %s', file_id)
157
143
 
158
144
    def escaped(self, escape_count, message):
159
145
        self._note("replaced %d control characters in message", escape_count)
160
146
 
161
147
    def missing(self, path):
162
 
        self._note_change('missing %s', path)
 
148
        self._note('missing %s', path)
163
149
 
164
150
    def renamed(self, change, old_path, new_path):
165
 
        self._note_change('%s %s => %s', change, old_path, new_path)
 
151
        self._note('%s %s => %s', change, old_path, new_path)
166
152
 
167
153
    def is_verbose(self):
168
154
        return True
396
382
        """Select the CommitReporter to use."""
397
383
        if is_quiet():
398
384
            return NullCommitReporter()
399
 
        # TODO: In verbose mode, show the total number of changes
400
385
        return ReportCommitToLog()
401
386
 
402
387
    def _any_real_changes(self):
710
695
            for unknown in self.work_tree.unknowns():
711
696
                raise StrictCommitFailed()
712
697
               
 
698
        report_changes = self.reporter.is_verbose()
713
699
        deleted_ids = []
714
700
        deleted_paths = set()
715
701
        work_inv = self.work_tree.inventory
717
703
        entries = work_inv.iter_entries()
718
704
        if not self.builder.record_root_entry:
719
705
            entries.next()
720
 
        report_changes = self.reporter.is_verbose()
721
706
        for path, existing_ie in entries:
722
707
            file_id = existing_ie.file_id
723
708
            name = existing_ie.name
752
737
            # parameter but the test suite currently (28-Jun-07) breaks
753
738
            # without it thanks to a unicode normalisation issue. :-(
754
739
            definitely_changed = kind != existing_ie.kind 
755
 
            self._record_entry(path, file_id, specific_files, kind, name,
756
 
                parent_id, definitely_changed, existing_ie, report_changes)
 
740
            ie = self._record_entry(path, file_id, specific_files, kind, name,
 
741
                parent_id, definitely_changed, existing_ie)
 
742
            if report_changes and ie is not None:
 
743
                self._report_change(ie, path)
757
744
 
758
745
        # Unversion IDs that were found to be deleted
759
746
        self.work_tree.unversion(deleted_ids)
784
771
            pass
785
772
 
786
773
    def _record_entry(self, path, file_id, specific_files, kind, name,
787
 
                      parent_id, definitely_changed, existing_ie=None,
788
 
                      report_changes=False):
 
774
            parent_id, definitely_changed, existing_ie=None):
789
775
        "Record the new inventory entry for a path if any."
790
776
        # mutter('check %s {%s}', path, file_id)
791
777
        if (not specific_files or 
806
792
        if ie is not None:
807
793
            self.builder.record_entry_contents(ie, self.parent_invs, 
808
794
                path, self.work_tree)
809
 
            if report_changes:
810
 
                # Special case initial commit for performance
811
 
                if self.initial_commit:
812
 
                    self.reporter.snapshot_change('added', path)
813
 
                else:
814
 
                    self._report_change(ie, path)
815
795
        return ie
816
796
 
817
797
    def _report_change(self, ie, path):
820
800
        The change that has occurred is described relative to the basis
821
801
        inventory.
822
802
        """
 
803
        # Special case initial commit for performance
 
804
        if self.initial_commit:
 
805
            self.reporter.snapshot_change('added', path)
 
806
            return
823
807
        if (self.basis_inv.has_id(ie.file_id)):
824
808
            basis_ie = self.basis_inv[ie.file_id]
825
809
        else: