~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

Merge Aarons conflict plugin for 0.1rc1

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
from bzrlib.branch import gen_file_id
75
75
from bzrlib.errors import (BzrError, PointlessCommit,
76
76
                           HistoryMissing,
 
77
                           ConflictsInTree
77
78
                           )
78
79
from bzrlib.revision import Revision
79
80
from bzrlib.trace import mutter, note, warning
97
98
 
98
99
class NullCommitReporter(object):
99
100
    """I report on progress of a commit."""
100
 
    def added(self, path):
101
 
        pass
102
 
 
103
 
    def removed(self, path):
104
 
        pass
105
 
 
106
 
    def renamed(self, old_path, new_path):
107
 
        pass
108
 
 
 
101
 
 
102
    def snapshot_change(self, change, path):
 
103
        pass
 
104
 
 
105
    def completed(self, revno, rev_id):
 
106
        pass
 
107
 
 
108
    def deleted(self, file_id):
 
109
        pass
 
110
 
 
111
    def escaped(self, escape_count, message):
 
112
        pass
 
113
 
 
114
    def missing(self, path):
 
115
        pass
109
116
 
110
117
class ReportCommitToLog(NullCommitReporter):
111
 
    def added(self, path):
112
 
        note('added %s', path)
113
 
 
114
 
    def removed(self, path):
115
 
        note('removed %s', path)
116
 
 
117
 
    def renamed(self, old_path, new_path):
118
 
        note('renamed %s => %s', old_path, new_path)
119
 
 
 
118
 
 
119
    def snapshot_change(self, change, path):
 
120
        note("%s %s", change, path)
 
121
 
 
122
    def completed(self, revno, rev_id):
 
123
        note('committed r%d {%s}', revno, rev_id)
 
124
    
 
125
    def deleted(self, file_id):
 
126
        note('deleted %s', file_id)
 
127
 
 
128
    def escaped(self, escape_count, message):
 
129
        note("replaced %d control characters in message", escape_count)
 
130
 
 
131
    def missing(self, path):
 
132
        note('missing %s', path)
120
133
 
121
134
class Commit(object):
122
135
    """Task of committing a new revision.
218
231
                    or self.new_inv != self.basis_inv):
219
232
                raise PointlessCommit()
220
233
 
 
234
            if len(list(self.work_tree.iter_conflicts()))>0:
 
235
                raise ConflictsInTree
 
236
 
221
237
            self._record_inventory()
222
238
            self._make_revision()
223
 
            note('committed r%d {%s}', (self.branch.revno() + 1),
224
 
                 self.rev_id)
 
239
            self.reporter.completed(self.branch.revno()+1, self.rev_id)
225
240
            self.branch.append_revision(self.rev_id)
226
241
            self.branch.set_pending_merges([])
227
242
        finally:
252
267
            lambda match: match.group(0).encode('unicode_escape'),
253
268
            self.message)
254
269
        if escape_count:
255
 
            note("replaced %d control characters in message", escape_count)
 
270
            self.reporter.escaped(escape_count, self.message)
256
271
 
257
272
    def _gather_parents(self):
258
273
        """Record the parents of a merge for merge detection."""
274
289
            mutter('commit parent revision {%s}', parent_id)
275
290
            if not self.branch.has_revision(parent_id):
276
291
                if parent_id == self.branch.last_revision():
277
 
                    warning("parent is pissing %r", parent_id)
 
292
                    warning("parent is missing %r", parent_id)
278
293
                    raise HistoryMissing(self.branch, 'revision', parent_id)
279
294
                else:
280
295
                    mutter("commit will ghost revision %r", parent_id)
311
326
            if specific and not is_inside_any(specific, path):
312
327
                continue
313
328
            if not self.work_tree.has_filename(path):
314
 
                note('missing %s', path)
315
 
                deleted_ids.append(ie.file_id)
 
329
                self.reporter.missing(path)
 
330
                deleted_ids.append((path, ie.file_id))
316
331
        if deleted_ids:
317
 
            for file_id in deleted_ids:
318
 
                if file_id in self.work_inv:
319
 
                    del self.work_inv[file_id]
 
332
            deleted_ids.sort(reverse=True)
 
333
            for path, file_id in deleted_ids:
 
334
                del self.work_inv[file_id]
320
335
            self.branch._write_inventory(self.work_inv)
321
336
 
322
337
    def _store_snapshot(self):
338
353
                                     self.work_tree, self.weave_store)
339
354
            else:
340
355
                change = "unchanged"
341
 
            note("%s %s", change, path)
 
356
            self.reporter.snapshot_change(change, path)
342
357
 
343
358
    def _populate_new_inv(self):
344
359
        """Build revision inventory.
393
408
    def _report_deletes(self):
394
409
        for file_id in self.basis_inv:
395
410
            if file_id not in self.new_inv:
396
 
                note('deleted %s', self.basis_inv.id2path(file_id))
 
411
                self.reporter.deleted(self.basis_inv.id2path(file_id))
397
412
 
398
413
def _gen_revision_id(branch, when):
399
414
    """Return new revision-id."""