109
109
def _note(self, format, *args):
110
110
"""Output a message.
112
Messages are output by writing directly to stderr instead of
113
using bzrlib.trace.note(). The latter constantly updates the
114
log file as we go causing an unnecessary performance hit.
116
Subclasses may choose to override this method but need to be aware
117
of its potential impact on performance.
112
Subclasses may choose to override this method.
119
bzrlib.ui.ui_factory.clear_term()
120
sys.stderr.write((format + "\n") % args)
122
116
def snapshot_change(self, change, path):
123
117
if change == 'unchanged':
279
273
tree.find_ids_across_trees(specific_files,
280
274
[self.basis_tree, self.work_tree])
282
# Setup the progress bar ...
283
# one to finish, one for rev and inventory, and one for each
284
# inventory entry, and the same for the new inventory.
285
# note that this estimate is too long when we do a partial tree
286
# commit which excludes some new files from being considered.
287
# The estimate is corrected when we populate the new inv.
288
self.pb_total = len(self.work_inv) + 5
276
# Setup the progress bar. As the number of files that need to be
277
# committed in unknown, progress is reported as stages.
278
# We keep track of entries separately though and include that
279
# information in the progress bar during the relevant stages.
280
self.pb_stage_name = ""
281
self.pb_stage_count = 0
282
self.pb_stage_total = 4
283
if self.bound_branch:
284
self.pb_stage_total += 1
285
self.pb.show_pct = False
286
self.pb.show_spinner = False
287
self.pb.show_eta = False
288
self.pb.show_count = True
289
self.pb.show_bar = False
291
291
self._gather_parents()
292
292
if len(self.parents) > 1 and self.specific_files:
293
293
raise errors.CannotCommitSelectedFileMerge(self.specific_files)
295
295
# Build the new inventory
296
self._emit_progress_set_stage("Collecting changes", show_entries=True)
296
297
self.builder = self.branch.get_commit_builder(self.parents,
297
298
self.config, timestamp, timezone, committer, revprops, rev_id)
298
299
self._remove_deleted()
299
300
self._populate_new_inv()
300
301
self._report_deletes()
301
302
self._check_pointless()
302
self._emit_progress_update()
304
304
# TODO: Now the new inventory is known, check for conflicts and
305
305
# prompt the user for a commit message.
306
306
# ADHB 2006-08-08: If this is done, populate_new_inv should not add
307
307
# weave lines, because nothing should be recorded until it is known
308
308
# that commit will succeed.
309
self._emit_progress_set_stage("Saving data locally")
309
310
self.builder.finish_inventory()
310
self._emit_progress_update()
311
311
message = message_callback(self)
312
312
assert isinstance(message, unicode), type(message)
313
313
self.message = message
316
316
# Add revision data to the local branch
317
317
self.rev_id = self.builder.commit(self.message)
318
self._emit_progress_update()
320
# upload revision data to the master.
319
# Upload revision data to the master.
321
320
# this will propagate merged revisions too if needed.
322
321
if self.bound_branch:
322
self._emit_progress_set_stage("Uploading data to master branch")
323
323
self.master_branch.repository.fetch(self.branch.repository,
324
324
revision_id=self.rev_id)
325
325
# now the master has the revision data
332
332
self.branch.set_last_revision_info(new_revno, self.rev_id)
334
334
# Make the working tree up to date with the branch
335
self._emit_progress_set_stage("Updating the working tree")
335
336
rev_tree = self.builder.revision_tree()
336
337
self.work_tree.set_parent_trees([(self.rev_id, rev_tree)])
337
338
self.reporter.completed(new_revno, self.rev_id)
339
340
# Process the post commit hooks, if any
341
self._emit_progress_set_stage("Running post commit hooks")
340
342
self._process_hooks(old_revno, new_revno)
341
self._emit_progress_update()
344
345
return self.rev_id
612
613
self.builder.new_inventory.add(self.basis_inv.root.copy())
614
self._emit_progress_update()
615
self.pb_entries_total = len(self.work_inv)
615
616
for path, new_ie in entries:
616
self._emit_progress_update()
617
self._emit_progress_next_entry()
617
618
file_id = new_ie.file_id
619
620
kind = self.work_tree.kind(file_id)
690
691
self.builder.record_entry_contents(ie, self.parent_invs, path,
693
def _emit_progress_update(self):
694
"""Emit an update to the progress bar."""
695
self.pb.update("Committing", self.pb_count, self.pb_total)
694
def _emit_progress_set_stage(self, name, show_entries=False):
695
"""Set the progress stage and emit an update to the progress bar."""
696
self.pb_stage_name = name
697
self.pb_stage_count += 1
698
self.pb_entries_show = show_entries
700
self.pb_entries_count = 0
701
self.pb_entries_total = '?'
702
self._emit_progress()
704
def _emit_progress_next_entry(self):
705
"""Emit an update to the progress bar and increment the file count."""
706
self.pb_entries_count += 1
707
self._emit_progress()
709
def _emit_progress(self):
710
if self.pb_entries_show:
711
text = "%s [Entry %d/%s] - Stage" % (self.pb_stage_name,
712
self.pb_entries_count,str(self.pb_entries_total))
714
text = "%s - Stage" % (self.pb_stage_name)
715
self.pb.update(text, self.pb_stage_count, self.pb_stage_total)
698
717
def _report_deletes(self):
699
718
for path, ie in self.basis_inv.iter_entries():
700
719
if ie.file_id not in self.builder.new_inventory:
701
720
self.reporter.deleted(path)