74
74
from bzrlib.branch import gen_file_id
75
75
from bzrlib.errors import (BzrError, PointlessCommit,
78
79
from bzrlib.revision import Revision
79
80
from bzrlib.trace import mutter, note, warning
98
99
class NullCommitReporter(object):
99
100
"""I report on progress of a commit."""
100
def added(self, path):
103
def removed(self, path):
106
def renamed(self, old_path, new_path):
102
def snapshot_change(self, change, path):
105
def completed(self, revno, rev_id):
108
def deleted(self, file_id):
111
def escaped(self, escape_count, message):
114
def missing(self, path):
110
117
class ReportCommitToLog(NullCommitReporter):
111
def added(self, path):
112
note('added %s', path)
114
def removed(self, path):
115
note('removed %s', path)
117
def renamed(self, old_path, new_path):
118
note('renamed %s => %s', old_path, new_path)
119
def snapshot_change(self, change, path):
120
note("%s %s", change, path)
122
def completed(self, revno, rev_id):
123
note('committed r%d {%s}', revno, rev_id)
125
def deleted(self, file_id):
126
note('deleted %s', file_id)
128
def escaped(self, escape_count, message):
129
note("replaced %d control characters in message", escape_count)
131
def missing(self, path):
132
note('missing %s', path)
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()
234
if len(list(self.work_tree.iter_conflicts()))>0:
235
raise ConflictsInTree
221
237
self._record_inventory()
222
238
self._make_revision()
223
note('committed r%d {%s}', (self.branch.revno() + 1),
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([])
252
267
lambda match: match.group(0).encode('unicode_escape'),
255
note("replaced %d control characters in message", escape_count)
270
self.reporter.escaped(escape_count, self.message)
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)
280
295
mutter("commit will ghost revision %r", parent_id)
311
326
if specific and not is_inside_any(specific, path):
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))
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)
322
337
def _store_snapshot(self):
338
353
self.work_tree, self.weave_store)
340
355
change = "unchanged"
341
note("%s %s", change, path)
356
self.reporter.snapshot_change(change, path)
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))
398
413
def _gen_revision_id(branch, when):
399
414
"""Return new revision-id."""