~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Aaron Bentley
  • Date: 2005-10-04 13:22:51 UTC
  • mto: (1185.25.1)
  • mto: This revision was merged to the branch mainline in revision 1419.
  • Revision ID: abentley@panoramicfeedback.com-20051004132251-fe31406192419a29
Fixed commit so all output comes though CommitReporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
 
103
103
class NullCommitReporter(object):
104
104
    """I report on progress of a commit."""
105
 
    def added(self, path):
106
 
        pass
107
 
 
108
 
    def removed(self, path):
109
 
        pass
110
 
 
111
 
    def renamed(self, old_path, new_path):
112
 
        pass
113
 
 
 
105
 
 
106
    def snapshot_change(self, change, path):
 
107
        pass
 
108
 
 
109
    def completed(self, revno, rev_id):
 
110
        pass
 
111
 
 
112
    def deleted(self, file_id):
 
113
        pass
 
114
 
 
115
    def escaped(self, escape_count, message):
 
116
        pass
 
117
 
 
118
    def missing(self, path):
 
119
        pass
114
120
 
115
121
class ReportCommitToLog(NullCommitReporter):
116
 
    def added(self, path):
117
 
        note('added %s', path)
118
 
 
119
 
    def removed(self, path):
120
 
        note('removed %s', path)
121
 
 
122
 
    def renamed(self, old_path, new_path):
123
 
        note('renamed %s => %s', old_path, new_path)
124
 
 
 
122
 
 
123
    def snapshot_change(self, change, path):
 
124
        note("%s %s", change, path)
 
125
 
 
126
    def completed(self, revno, rev_id):
 
127
        note('committed r%d {%s}', revno, rev_id)
 
128
    
 
129
    def deleted(self, file_id):
 
130
        note('deleted %s', file_id)
 
131
 
 
132
    def escaped(self, escape_count, message):
 
133
        note("replaced %d control characters in message", escape_count)
 
134
 
 
135
    def missing(self, path):
 
136
        note('missing %s', path)
125
137
 
126
138
class Commit(object):
127
139
    """Task of committing a new revision.
226
238
            self._record_inventory()
227
239
            self._record_ancestry()
228
240
            self._make_revision()
229
 
            note('committed r%d {%s}', (self.branch.revno() + 1),
230
 
                 self.rev_id)
 
241
            self.reporter.completed(self.branch.revno()+1, self.rev_id)
231
242
            self.branch.append_revision(self.rev_id)
232
243
            self.branch.set_pending_merges([])
233
244
        finally:
258
269
            lambda match: match.group(0).encode('unicode_escape'),
259
270
            self.message)
260
271
        if escape_count:
261
 
            note("replaced %d control characters in message", escape_count)
 
272
            self.reporter.escaped(escape_count, self.message)
262
273
 
263
274
    def _record_ancestry(self):
264
275
        """Append merged revision ancestry to the ancestry file.
338
349
            if specific and not is_inside_any(specific, path):
339
350
                continue
340
351
            if not self.work_tree.has_filename(path):
341
 
                note('missing %s', path)
 
352
                self.reporter.missing(path)
342
353
                deleted_ids.append((path, ie.file_id))
343
354
        if deleted_ids:
344
355
            deleted_ids.sort(reverse=True)
393
404
                                     self.work_tree, self.weave_store)
394
405
            else:
395
406
                change = "unchanged"
396
 
            note("%s %s", change, path)
 
407
            self.reporter.snapshot_change(change, path)
397
408
 
398
409
    def _populate_new_inv(self):
399
410
        """Build revision inventory.
428
439
    def _report_deletes(self):
429
440
        for file_id in self.basis_inv:
430
441
            if file_id not in self.new_inv:
431
 
                note('deleted %s', self.basis_inv.id2path(file_id))
 
442
                self.reporter.deleted(self.basis_inv.id2path(file_id))
432
443
 
433
444
 
434
445