Usage question about bzrlib.builtins.cmd_diff
Andrew Bennetts
andrew.bennetts at canonical.com
Thu Mar 10 00:27:07 UTC 2011
Martin (gzlist) wrote:
> On 09/03/2011, Matt Drew <matt.drew at steeprockinc.com> wrote:
> > I can run this command from the command line:
> > bzr diff filename -r1..2
> > to generate a diff between file filename as it existed at revision 1 and
> > revision 2.
> >
> > I want to do the same thing from python. I tried this:
> > import bzrlib.builtins
> > bzrlib.builtins.cmd_diff().run(file_list=['filename'])
>
> It doesn't appear Command objects are designed to be reused like this,
> though people seem to want to. The arguments to `run` are not just
> strings but have been preprocessed, as can be seen from the class
> attributes.
Actually, I think it's acceptable to use the run_argv_aliases method,
which among other things will turn things like “-r1..2” into the
appropriate revision spec objects:
bzrlib.builtins.cmd_diff().run_argv_aliases([filename, '-r1..2'])
It's not especially obvious that this is the method you need for this
situation. Perhaps we can document that more clearly.
The rest of Martin's advice is very good though.
-Andrew.
More information about the bazaar
mailing list