command that batches bzr and qbzr commands
Michael Gliwinski
Michael.Gliwinski at henderson-group.com
Thu Jul 29 14:29:44 BST 2010
On Tuesday 27 Jul 2010 15:55:21 John Arbash Meinel wrote:
...
> >>> Basically an example of what I'm trying to do is write a command which
> >>> downloads some files, imports them (like bzrtools' import) and then
> >>> launches a qcommit dialog pre-filled with certain message and author,
> >>> etc.
...
> >> Many plugins already do this. You may want to look at some of them,
> >> because sometimes the setup rules have been a bit unclear. (Some setup
> >> code expected run_argv_aliases() to be called, which usually doesn't
> >> happen when running from another command). However that might have been
> >> sorted out.
> >
> > OK, I'll look into that. Would you remember off top of your head an
> > example of one such plugin by any chance?
>
> IIRC bzrtools's cbranch command calls cmd classes directly.
Thanks.
...
> > So now I'm trying to figure out how to use QBzr's CommitWindow from my
> > command without inheriting from QBzrCommand (I still want the import to
> > run without GUI, but if GUI is available then offer the option of using
> > it). If anyone has any pointers on that BTW, I'd really appreciate them
> > (I had a look at the now disabled merge --qpreview which seemed to do
> > sth like that but it seems approach used there wouldn't work anymore).
BTW, in case it's useful to anyone I got this working with something like that
(the import stuff is based on colo plugin)::
qbzr = None
try:
import bzrlib.plugins.qbzr as qbzr
except ImportError:
pass
class NoQBzrError(errors.BzrCommandError):
_fmt = '%(name)s requires the qbzr plugin.'
class cmd_foo(Command):
def run(self, directory=None, commit=False):
# do stuff
if commit:
if qbzr is None:
raise NoQBzrError(name='commit option')
from bzrlib.plugins.qbzr.lib.commands import QBzrCommand
QBzrCommand.run.im_func(self, directory=directory)
def _qbzr_run(self, directory=None):
from bzrlib.plugins.qbzr.lib.commit import CommitWindow
if not directory:
directory = u'.'
tree = WorkingTree.open(directory)
selected_list = None
self.main_window = CommitWindow(tree, selected_list, dialog=False)
# set some properties, e.g.
self.main_window.message.setText('foo')
self.main_window.show()
self._application.exec_()
It works by invoking QBzrCommand.run function with regular bzr Command
instance as self. Possibly not the best way if QBzrCommand class was more
complex. I'm also toying with the idea of having different parent depending
if QBzr is available.
> Sure. You may also want to look for us on irc.freenode.net #bzr. People
> tend to hang out there, and you may get faster response times.
Thanks, will pop in sometime.
--
Michael Gliwinski
Henderson Group Information Services
9-11 Hightown Avenue, Newtownabby, BT36 4RT
Phone: 028 9034 3319
**********************************************************************************************
The information in this email is confidential and may be legally privileged. It is intended solely for the addressee and access to the email by anyone else is unauthorised.
If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.
When addressed to our clients, any opinions or advice contained in this e-mail are subject to the terms and conditions expressed in the governing client engagement leter or contract.
If you have received this email in error please notify support at henderson-group.com
John Henderson (Holdings) Ltd
Registered office: 9 Hightown Avenue, Mallusk, County Antrim, Northern Ireland, BT36 4RT.
Registered in Northern Ireland
Registration Number NI010588
Vat No.: 814 6399 12
*********************************************************************************
More information about the bazaar
mailing list