Merge lp:~gz/hydrazine/setup_bzrlib_ui_597504 into lp:hydrazine

Proposed by Martin Packman
Status: Merged
Approved by: Martin Pool
Approved revision: 67
Merged at revision: 67
Proposed branch: lp:~gz/hydrazine/setup_bzrlib_ui_597504
Merge into: lp:hydrazine
Diff against target: 34 lines (+17/-0)
1 file modified
feed-pqm (+17/-0)
To merge this branch: bzr merge lp:~gz/hydrazine/setup_bzrlib_ui_597504
Reviewer Review Type Date Requested Status
Martin Pool Approve
Review via email: mp+28260@code.launchpad.net

Description of the change

Basically this just inits the bzrlib ui so that it can prompt for an email password (or anything else).

The change is a little messy as there have been several variations on how this should be done in recent times. For 2.1 you need to create the ui_factory object yourself, 2.2 added an initialize function, which has recently grown into a context-manager style interface.

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

thanks!

review: Approve
Revision history for this message
Martin Pool (mbp) wrote :

You're now in the team, please merge it to trunk yourself.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'feed-pqm'
2--- feed-pqm 2010-05-21 12:35:04 +0000
3+++ feed-pqm 2010-06-23 01:41:31 +0000
4@@ -21,6 +21,22 @@
5 import os
6 import sys
7
8+try:
9+ from bzrlib import initialize as bzrlib_initialize
10+except ImportError:
11+ import bzrlib.ui
12+ def bzrlib_setup():
13+ """Setup bzrlib ui for older bzr versions without bzrlib.initialize"""
14+ bzrlib.ui.ui_factory = bzrlib.ui.make_ui_for_terminal(
15+ sys.stdin, sys.stdout, sys.stderr)
16+else:
17+ import atexit
18+ def bzrlib_setup():
19+ """Call bzrlib.initialize and register cleanup to be run on exit"""
20+ context = bzrlib_initialize()
21+ if context is not None:
22+ atexit.register(context.__enter__().__exit__, None, None, None)
23+
24 from bzrlib.email_message import EmailMessage
25 from bzrlib.config import GlobalConfig
26 from bzrlib import gpg
27@@ -151,6 +167,7 @@
28 parser.add_option('--nomail', help="Do not send email commands", action="store_true", default=False)
29 parser.add_option('--queued', help="Examine already queued proposals", action="store_true", default=False)
30 opts, args = parser.parse_args()
31+ bzrlib_setup()
32 launchpad = hydrazine.create_session()
33 project = launchpad.projects[argv[1]]
34 i = 0

Subscribers

People subscribed via source and target branches

to all changes: