Merge lp:~jelmer/brz/pb-context into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 6866
Merge reported by: Vincent Ladeuil
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/pb-context
Merge into: lp:brz
Diff against target: 63 lines (+13/-4)
4 files modified
breezy/bundle/apply_bundle.py (+1/-1)
breezy/plugins/weave_fmt/bzrdir.py (+0/-1)
breezy/reconcile.py (+5/-2)
breezy/tests/testui.py (+7/-0)
To merge this branch: bzr merge lp:~jelmer/brz/pb-context
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+339449@code.launchpad.net

Commit message

Make progress bars context managers.

Description of the change

Make progress bars context managers.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Looks like a good improvement overall, see couple of inline notes.

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) :
Revision history for this message
Vincent Ladeuil (vila) wrote :

Running landing tests failed

lp:~jelmer/brz/pb-context updated
6865. By Jelmer Vernooij

Merge trunk.

6866. By Jelmer Vernooij

Fix context manager for RecordingUIFactory.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/bundle/apply_bundle.py'
2--- breezy/bundle/apply_bundle.py 2018-02-24 15:50:23 +0000
3+++ breezy/bundle/apply_bundle.py 2018-03-01 23:45:46 +0000
4@@ -32,7 +32,7 @@
5 custom_install = getattr(bundle_reader, 'install', None)
6 if custom_install is not None:
7 return custom_install(repository)
8- with ui.ui_factory.nested_progress_bar() as pb, repository.lock_write():
9+ with repository.lock_write(), ui.ui_factory.nested_progress_bar() as pb:
10 real_revisions = bundle_reader.real_revisions
11 for i, revision in enumerate(reversed(real_revisions)):
12 pb.update(gettext("Install revisions"), i, len(real_revisions))
13
14=== modified file 'breezy/plugins/weave_fmt/bzrdir.py'
15--- breezy/plugins/weave_fmt/bzrdir.py 2018-02-24 15:50:23 +0000
16+++ breezy/plugins/weave_fmt/bzrdir.py 2018-03-01 23:45:46 +0000
17@@ -242,7 +242,6 @@
18 if pb is not None:
19 warnings.warn(gettext("pb parameter to convert() is deprecated"))
20 with ui.ui_factory.nested_progress_bar() as self.pb:
21- try:
22 ui.ui_factory.note(gettext('starting upgrade from format 4 to 5'))
23 if isinstance(self.controldir.transport, local.LocalTransport):
24 self.controldir.get_workingtree_transport(None).delete('stat-cache')
25
26=== modified file 'breezy/reconcile.py'
27--- breezy/reconcile.py 2018-02-24 15:50:23 +0000
28+++ breezy/reconcile.py 2018-03-01 23:45:46 +0000
29@@ -76,11 +76,14 @@
30 branch history was correct, True if the branch history needed to be
31 re-normalized.
32 """
33- with ui.ui_factory.nested_progress_bar() as self.pb:
34- self._reconcile()
35+ operation = cleanup.OperationWithCleanups(self._reconcile)
36+ self.add_cleanup = operation.add_cleanup
37+ operation.run_simple()
38
39 def _reconcile(self):
40 """Helper function for performing reconciliation."""
41+ self.pb = ui.ui_factory.nested_progress_bar()
42+ self.add_cleanup(self.pb.finished)
43 self._reconcile_branch()
44 self._reconcile_repository()
45
46
47=== modified file 'breezy/tests/testui.py'
48--- breezy/tests/testui.py 2017-05-22 00:56:52 +0000
49+++ breezy/tests/testui.py 2018-03-01 23:45:46 +0000
50@@ -41,6 +41,13 @@
51 def finished(self):
52 self.depth -= 1
53
54+ def __enter__(self):
55+ return self
56+
57+ def __exit__(self, exc_type, exc_val, exc_tb):
58+ self.finished()
59+ return False
60+
61 def update(self, message, count=None, total=None):
62 if self.depth == 1:
63 self._calls.append(("update", count, total, message))

Subscribers

People subscribed via source and target branches