/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/commit.py

  • Committer: Ian Clatworthy
  • Date: 2007-06-19 07:26:24 UTC
  • mto: (2539.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2540.
  • Revision ID: ian.clatworthy@internode.on.net-20070619072624-73nm1uw3lu6jx4ko
Improved progress reporting for commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
273
273
                tree.find_ids_across_trees(specific_files,
274
274
                                           [self.basis_tree, self.work_tree])
275
275
 
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
283
 
            self.pb_count = 0
 
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
284
290
 
285
291
            self._gather_parents()
286
292
            if len(self.parents) > 1 and self.specific_files:
287
293
                raise errors.CannotCommitSelectedFileMerge(self.specific_files)
288
294
            
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()
297
303
 
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
309
315
 
310
316
            # Add revision data to the local branch
311
317
            self.rev_id = self.builder.commit(self.message)
312
 
            self._emit_progress_update()
313
318
            
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)
327
333
 
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)
332
339
 
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()
336
343
        finally:
337
344
            self._cleanup()
338
345
        return self.rev_id
605
612
                stacklevel=1)
606
613
            self.builder.new_inventory.add(self.basis_inv.root.copy())
607
614
            entries.next()
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
612
619
            try:
613
620
                kind = self.work_tree.kind(file_id)
684
691
            self.builder.record_entry_contents(ie, self.parent_invs, path,
685
692
                                               self.basis_tree)
686
693
 
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)
690
 
        self.pb_count += 1
 
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
 
699
        if show_entries:
 
700
            self.pb_entries_count = 0
 
701
            self.pb_entries_total = '?'
 
702
        self._emit_progress()
 
703
 
 
704
 
 
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()
 
709
 
 
710
 
 
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))
 
715
        else:
 
716
            text = "%s - Stage" % (self.pb_stage_name)
 
717
        self.pb.update(text, self.pb_stage_count, self.pb_stage_total)
 
718
 
691
719
 
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)
696
724
 
697