273
273
tree.find_ids_across_trees(specific_files,
274
274
[self.basis_tree, self.work_tree])
276
# Setup the progress bar ...
277
# one to finish, one for rev and inventory, and one for each
278
# inventory entry, and the same for the new inventory.
279
# note that this estimate is too long when we do a partial tree
280
# commit which excludes some new files from being considered.
281
# The estimate is corrected when we populate the new inv.
282
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
285
291
self._gather_parents()
286
292
if len(self.parents) > 1 and self.specific_files:
287
293
raise errors.CannotCommitSelectedFileMerge(self.specific_files)
289
295
# Build the new inventory
296
self._emit_progress_set_stage("Collecting changes", show_entries=True)
290
297
self.builder = self.branch.get_commit_builder(self.parents,
291
298
self.config, timestamp, timezone, committer, revprops, rev_id)
292
299
self._remove_deleted()
293
300
self._populate_new_inv()
294
301
self._report_deletes()
295
302
self._check_pointless()
296
self._emit_progress_update()
298
304
# TODO: Now the new inventory is known, check for conflicts and
299
305
# prompt the user for a commit message.
300
306
# ADHB 2006-08-08: If this is done, populate_new_inv should not add
301
307
# weave lines, because nothing should be recorded until it is known
302
308
# that commit will succeed.
309
self._emit_progress_set_stage("Saving data locally")
303
310
self.builder.finish_inventory()
304
self._emit_progress_update()
305
311
message = message_callback(self)
306
312
assert isinstance(message, unicode), type(message)
307
313
self.message = message
310
316
# Add revision data to the local branch
311
317
self.rev_id = self.builder.commit(self.message)
312
self._emit_progress_update()
314
# upload revision data to the master.
319
# Upload revision data to the master.
315
320
# this will propagate merged revisions too if needed.
316
321
if self.bound_branch:
322
self._emit_progress_set_stage("Uploading data to master branch")
317
323
self.master_branch.repository.fetch(self.branch.repository,
318
324
revision_id=self.rev_id)
319
325
# now the master has the revision data
326
332
self.branch.set_last_revision_info(new_revno, self.rev_id)
328
334
# Make the working tree up to date with the branch
335
self._emit_progress_set_stage("Updating the working tree")
329
336
rev_tree = self.builder.revision_tree()
330
337
self.work_tree.set_parent_trees([(self.rev_id, rev_tree)])
331
338
self.reporter.completed(new_revno, self.rev_id)
333
340
# Process the post commit hooks, if any
341
self._emit_progress_set_stage("Running post commit hooks")
334
342
self._process_hooks(old_revno, new_revno)
335
self._emit_progress_update()
338
345
return self.rev_id
606
613
self.builder.new_inventory.add(self.basis_inv.root.copy())
608
self._emit_progress_update()
615
self.pb_entries_total = len(self.work_inv)
609
616
for path, new_ie in entries:
610
self._emit_progress_update()
617
self._emit_progress_next_entry()
611
618
file_id = new_ie.file_id
613
620
kind = self.work_tree.kind(file_id)
684
691
self.builder.record_entry_contents(ie, self.parent_invs, path,
687
def _emit_progress_update(self):
688
"""Emit an update to the progress bar."""
689
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()
705
def _emit_progress_next_entry(self):
706
"""Emit an update to the progress bar and increment the file count."""
707
self.pb_entries_count += 1
708
self._emit_progress()
711
def _emit_progress(self):
712
if self.pb_entries_show:
713
text = "%s [Entry %d/%s] - Stage" % (self.pb_stage_name,
714
self.pb_entries_count,str(self.pb_entries_total))
716
text = "%s - Stage" % (self.pb_stage_name)
717
self.pb.update(text, self.pb_stage_count, self.pb_stage_total)
692
720
def _report_deletes(self):
693
721
for path, ie in self.basis_inv.iter_entries():
694
722
if ie.file_id not in self.builder.new_inventory:
695
723
self.reporter.deleted(path)