33
31
__version__ = version_string
36
class cmd_pqm_submit(Command):
37
"""Submit the parent tree to the pqm.
40
$ echo "star-merge $PARENT $TARGET"
42
| mail pqm@somewhere -s "merge text"
44
But it pays attention to who the local committer is
45
(using their e-mail address), and uses the local
46
gpg signing configuration. (As well as target pqm
49
The reason we use 'parent' instead of the local branch
50
is that most likely the local branch is not a public
51
branch. And the branch must be available to the pqm.
53
This can be configured at the branch level using ~/.bazaar/locations.conf.
56
pqm_email = PQM <pqm@example.com>
57
pqm_user_email = User Name <user@example.com>
58
submit_branch = http://code.example.com/code/project/devel
59
# Set public_branch appropriately for all branches in repository:
60
public_branch = http://code.example.com/code/emurphy/project
61
public_branch:policy = appendpath
62
[/home/emurphy/repo/branch]
63
# Override public_branch for this repository:
64
public_branch = http://alternate.host.example.com/other/public/branch
66
smtp_server = host:port
70
If you don't specify the smtp server, the message will be sent via localhost.
73
takes_args = ['location?']
76
help='Message to use on merge to pqm. '
77
'Currently must be a single line because of pqm limits.',
80
Option('dry-run', help='Print request instead of sending.'),
81
Option('public-location', type=str,
82
help='Use this url as the public location to the pqm.'),
83
Option('submit-branch', type=str,
84
help='Use this url as the target submission branch.'),
85
Option('ignore-local', help='Do not check the local branch or tree.'),
88
def run(self, location=None, message=None, public_location=None,
89
dry_run=False, submit_branch=None, ignore_local=False):
90
from bzrlib import trace, bzrdir
91
if __name__ != 'bzrlib.plugins.pqm':
92
trace.warning('The bzr-pqm plugin needs to be called'
93
' "bzrlib.plugins.pqm" not "%s"\n'
94
'Please rename the plugin.',
97
from bzrlib.plugins.pqm.pqm_submit import submit
100
tree, b, relpath = None, None, None
104
tree, b, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
108
self.add_cleanup(b.unlock)
109
if relpath and not tree and location != '.':
110
raise BzrCommandError(
111
'No working tree was found, but we were not given the '
112
'exact path to the branch.\n'
113
'We found a branch at: %s' % (b.base,))
115
raise BzrCommandError(
116
'You must supply a commit message for the pqm to use.')
117
submit(b, message=message, dry_run=dry_run,
118
public_location=public_location,
119
submit_location=submit_branch,
120
tree=tree, ignore_local=ignore_local)
122
class cmd_lp_land(Command):
123
"""Land the merge proposal for this branch via PQM.
125
The branch will be submitted to PQM according to the merge proposal. If
126
there is more than one one outstanding proposal for the branch, its
127
location must be specified.
130
takes_args = ['location?']
133
Option('dry-run', help='Display the PQM message instead of sending.'),
136
help="This is a testfix (tags commit with [testfix])."),
139
help="Does not require QA (tags commit with [no-qa])."),
142
help="Incremental to other bug fix (tags commit with [incr])."),
144
'rollback', type=int,
146
"Rollback given revision number. (tags commit with "
147
"[rollback=revno]).")),
150
def run(self, location=None, dry_run=False, testfix=False,
151
no_qa=False, incremental=False, rollback=None):
152
from bzrlib.plugins.pqm.lpland import Submitter
153
from bzrlib.plugins.pqm.lpland import (
154
MissingReviewError, MissingBugsError, MissingBugsIncrementalError)
160
if rollback and (no_qa or incremental):
161
print "--rollback option used. Ignoring --no-qa and --incremental."
163
submitter = Submitter.from_cmdline(
164
location, testfix, no_qa, incremental,
165
rollback=rollback).run(outf)
166
except MissingReviewError:
167
raise BzrCommandError(
168
"Cannot land branches that haven't got approved code "
169
"reviews. Get an 'Approved' vote so we can fill in the "
170
"[r=REVIEWER] section.")
171
except MissingBugsError:
172
raise BzrCommandError(
173
"Branch doesn't have linked bugs and doesn't have no-qa "
174
"option set. Use --no-qa, or link the related bugs to the "
176
except MissingBugsIncrementalError:
177
raise BzrCommandError(
178
"--incremental option requires bugs linked to the branch. "
179
"Link the bugs or remove the --incremental option.")
182
register_command(cmd_pqm_submit)
183
register_command(cmd_lp_land)
34
plugin_cmds.register_lazy("cmd_pqm_submit", [], 'bzrlib.plugins.pqm.cmds')
35
plugin_cmds.register_lazy("cmd_lp_land", [], 'bzrlib.plugins.pqm.cmds')
186
37
if bzrlib_version >= (2, 5):
187
38
from bzrlib import config as _mod_config