Rev 2540: Better progress reporting in commit in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Jun 20 10:21:42 BST 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 2540
revision-id: pqm at pqm.ubuntu.com-20070620092141-cniojlk01bdec2a1
parent: pqm at pqm.ubuntu.com-20070620033726-baiap8oniaidhdf1
parent: ian.clatworthy at internode.on.net-20070620084028-ro8ibkz1xb2gynt9
committer: Canonical.com Patch Queue Manager<pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-06-20 10:21:41 +0100
message:
Better progress reporting in commit
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/commit.py commit.py-20050511101309-79ec1a0168e0e825
bzrlib/tests/workingtree_implementations/test_commit.py test_commit.py-20060421013633-1610ec2331c8190f
------------------------------------------------------------
revno: 2539.1.1
merged: ian.clatworthy at internode.on.net-20070620084028-ro8ibkz1xb2gynt9
parent: pqm at pqm.ubuntu.com-20070620033726-baiap8oniaidhdf1
parent: ian.clatworthy at internode.on.net-20070620033232-eod2sjmf2ath8ya3
committer: Ian Clatworthy <ian.clatworthy at internode.on.net>
branch nick: ianc-integration
timestamp: Wed 2007-06-20 18:40:28 +1000
message:
Better progress reporting in commit
------------------------------------------------------------
revno: 2531.1.3
merged: ian.clatworthy at internode.on.net-20070620033232-eod2sjmf2ath8ya3
parent: ian.clatworthy at internode.on.net-20070619072624-73nm1uw3lu6jx4ko
committer: Ian Clatworthy <ian.clatworthy at internode.on.net>
branch nick: bzr.commit-better-progress
timestamp: Wed 2007-06-20 13:32:32 +1000
message:
Fix whitespace and improve tests to cover actual progress messages
------------------------------------------------------------
revno: 2531.1.2
merged: ian.clatworthy at internode.on.net-20070619072624-73nm1uw3lu6jx4ko
parent: ian.clatworthy at internode.on.net-20070619002628-8zq42ikpr57youbw
committer: Ian Clatworthy <ian.clatworthy at internode.on.net>
branch nick: bzr.commit-better-progress
timestamp: Tue 2007-06-19 17:26:24 +1000
message:
Improved progress reporting for commit
=== modified file 'NEWS'
--- a/NEWS 2007-06-19 02:45:33 +0000
+++ b/NEWS 2007-06-20 08:40:28 +0000
@@ -22,6 +22,19 @@
* Automatic merge base selection uses a faster algorithm that chooses
better bases in criss-cross merge situations (Aaron Bentley)
+ * Progress reporting in ``commit`` has been improved. The various logical
+ stages are now reported on as follows, namely:
+
+ * Collecting changes [Entry x/y] - Stage n/m
+ * Saving data locally - Stage n/m
+ * Uploading data to master branch - Stage n/m
+ * Updating the working tree - Stage n/m
+ * Running post commit hooks - Stage n/m
+
+ If there is no master branch, the 3rd stage is omitted and the total
+ number of stages is adjusted accordingly.
+ (Ian Clatworthy)
+
TESTING:
* Removed the ``--keep-output`` option from selftest and clean up test
=== modified file 'bzrlib/commit.py'
--- a/bzrlib/commit.py 2007-06-18 02:25:13 +0000
+++ b/bzrlib/commit.py 2007-06-20 03:32:32 +0000
@@ -273,35 +273,41 @@
tree.find_ids_across_trees(specific_files,
[self.basis_tree, self.work_tree])
- # Setup the progress bar ...
- # one to finish, one for rev and inventory, and one for each
- # inventory entry, and the same for the new inventory.
- # note that this estimate is too long when we do a partial tree
- # commit which excludes some new files from being considered.
- # The estimate is corrected when we populate the new inv.
- self.pb_total = len(self.work_inv) + 5
- self.pb_count = 0
+ # Setup the progress bar. As the number of files that need to be
+ # committed in unknown, progress is reported as stages.
+ # We keep track of entries separately though and include that
+ # information in the progress bar during the relevant stages.
+ self.pb_stage_name = ""
+ self.pb_stage_count = 0
+ self.pb_stage_total = 4
+ if self.bound_branch:
+ self.pb_stage_total += 1
+ self.pb.show_pct = False
+ self.pb.show_spinner = False
+ self.pb.show_eta = False
+ self.pb.show_count = True
+ self.pb.show_bar = False
self._gather_parents()
if len(self.parents) > 1 and self.specific_files:
raise errors.CannotCommitSelectedFileMerge(self.specific_files)
# Build the new inventory
+ self._emit_progress_set_stage("Collecting changes", show_entries=True)
self.builder = self.branch.get_commit_builder(self.parents,
self.config, timestamp, timezone, committer, revprops, rev_id)
self._remove_deleted()
self._populate_new_inv()
self._report_deletes()
self._check_pointless()
- self._emit_progress_update()
# TODO: Now the new inventory is known, check for conflicts and
# prompt the user for a commit message.
# ADHB 2006-08-08: If this is done, populate_new_inv should not add
# weave lines, because nothing should be recorded until it is known
# that commit will succeed.
+ self._emit_progress_set_stage("Saving data locally")
self.builder.finish_inventory()
- self._emit_progress_update()
message = message_callback(self)
assert isinstance(message, unicode), type(message)
self.message = message
@@ -309,11 +315,11 @@
# Add revision data to the local branch
self.rev_id = self.builder.commit(self.message)
- self._emit_progress_update()
- # upload revision data to the master.
+ # Upload revision data to the master.
# this will propagate merged revisions too if needed.
if self.bound_branch:
+ self._emit_progress_set_stage("Uploading data to master branch")
self.master_branch.repository.fetch(self.branch.repository,
revision_id=self.rev_id)
# now the master has the revision data
@@ -326,13 +332,14 @@
self.branch.set_last_revision_info(new_revno, self.rev_id)
# Make the working tree up to date with the branch
+ self._emit_progress_set_stage("Updating the working tree")
rev_tree = self.builder.revision_tree()
self.work_tree.set_parent_trees([(self.rev_id, rev_tree)])
self.reporter.completed(new_revno, self.rev_id)
# Process the post commit hooks, if any
+ self._emit_progress_set_stage("Running post commit hooks")
self._process_hooks(old_revno, new_revno)
- self._emit_progress_update()
finally:
self._cleanup()
return self.rev_id
@@ -605,9 +612,9 @@
stacklevel=1)
self.builder.new_inventory.add(self.basis_inv.root.copy())
entries.next()
- self._emit_progress_update()
+ self.pb_entries_total = len(self.work_inv)
for path, new_ie in entries:
- self._emit_progress_update()
+ self._emit_progress_next_entry()
file_id = new_ie.file_id
try:
kind = self.work_tree.kind(file_id)
@@ -684,14 +691,31 @@
self.builder.record_entry_contents(ie, self.parent_invs, path,
self.basis_tree)
- def _emit_progress_update(self):
- """Emit an update to the progress bar."""
- self.pb.update("Committing", self.pb_count, self.pb_total)
- self.pb_count += 1
+ def _emit_progress_set_stage(self, name, show_entries=False):
+ """Set the progress stage and emit an update to the progress bar."""
+ self.pb_stage_name = name
+ self.pb_stage_count += 1
+ self.pb_entries_show = show_entries
+ if show_entries:
+ self.pb_entries_count = 0
+ self.pb_entries_total = '?'
+ self._emit_progress()
+
+ def _emit_progress_next_entry(self):
+ """Emit an update to the progress bar and increment the file count."""
+ self.pb_entries_count += 1
+ self._emit_progress()
+
+ def _emit_progress(self):
+ if self.pb_entries_show:
+ text = "%s [Entry %d/%s] - Stage" % (self.pb_stage_name,
+ self.pb_entries_count,str(self.pb_entries_total))
+ else:
+ text = "%s - Stage" % (self.pb_stage_name)
+ self.pb.update(text, self.pb_stage_count, self.pb_stage_total)
def _report_deletes(self):
for path, ie in self.basis_inv.iter_entries():
if ie.file_id not in self.builder.new_inventory:
self.reporter.deleted(path)
-
=== modified file 'bzrlib/tests/workingtree_implementations/test_commit.py'
--- a/bzrlib/tests/workingtree_implementations/test_commit.py 2007-03-23 20:19:01 +0000
+++ b/bzrlib/tests/workingtree_implementations/test_commit.py 2007-06-20 03:32:32 +0000
@@ -60,7 +60,7 @@
def update(self, message, count=None, total=None):
"""See progress.ProgressBar.update()."""
if self.depth == 1:
- self._calls.append(("update", count, total))
+ self._calls.append(("update", count, total, message))
class TestCapturingUI(TestCase):
@@ -75,7 +75,7 @@
pb2.update('foo', 0, 1)
pb2.finished()
pb1.finished()
- self.assertEqual([("update", 0, 1)], factory._calls)
+ self.assertEqual([("update", 0, 1, 'foo')], factory._calls)
class TestCommit(TestCaseWithWorkingTree):
@@ -345,18 +345,17 @@
# into the factory for this test - just make the test ui factory
# pun as a reporter. Then we can check the ordering is right.
tree.commit('second post', specific_files=['b'])
- # 9 steps: 1 for rev, 2 for inventory, 1 for finishing. 2 for root
- # and 6 for inventory files.
- # 2 steps don't trigger an update, as 'a' and 'c' are not
+ # 4 steps, the first of which is reported 5 times, once per file
+ # 2 files don't trigger an update, as 'a' and 'c' are not
# committed.
self.assertEqual(
- [("update", 0, 9),
- ("update", 1, 9),
- ("update", 2, 9),
- ("update", 3, 9),
- ("update", 4, 9),
- ("update", 5, 9),
- ("update", 6, 9),
- ("update", 7, 9)],
+ [('update', 1, 4, 'Collecting changes [Entry 0/?] - Stage'),
+ ('update', 1, 4, 'Collecting changes [Entry 1/4] - Stage'),
+ ('update', 1, 4, 'Collecting changes [Entry 2/4] - Stage'),
+ ('update', 1, 4, 'Collecting changes [Entry 3/4] - Stage'),
+ ('update', 1, 4, 'Collecting changes [Entry 4/4] - Stage'),
+ ('update', 2, 4, 'Saving data locally - Stage'),
+ ('update', 3, 4, 'Updating the working tree - Stage'),
+ ('update', 4, 4, 'Running post commit hooks - Stage')],
factory._calls
)
More information about the bazaar-commits
mailing list