Controlling bazaar from python

Jeremy Wilkins jeb at
Wed Aug 8 18:57:52 BST 2007


I've had a look through and the blackbox tests and have
set off trying to get status information. I've tried the following
simple program

#!/usr/bin/env python

from bzrlib import builtins

sta = builtins.cmd_status(), '/tmp/bzrtest/')

but get the following error

Traceback (most recent call last):
  File "", line 6, in ?, '/tmp/bzrtest/')
  File "/opt/local/lib/python2.4/site-packages/bzrlib/",
line 622, in ignore_pipe
    result = func(*args, **kwargs)
  File "/opt/local/lib/python2.4/site-packages/bzrlib/",
line 197, in run
    tree, file_list = tree_files(file_list)
  File "/opt/local/lib/python2.4/site-packages/bzrlib/",
line 69, in tree_files
    return internal_tree_files(file_list, default_branch)
  File "/opt/local/lib/python2.4/site-packages/bzrlib/",
line 94, in internal_tree_files
    tree = WorkingTree.open_containing(osutils.realpath(file_list[0]))[0]
  File "/opt/local/lib/python2.4/site-packages/bzrlib/",
line 356, in open_containing
    control, relpath = bzrdir.BzrDir.open_containing(path)
  File "/opt/local/lib/python2.4/site-packages/bzrlib/", line
604, in open_containing
    return BzrDir.open_containing_from_transport(get_transport(url))
  File "/opt/local/lib/python2.4/site-packages/bzrlib/", line
632, in open_containing_from_transport
    raise errors.NotBranchError(path=url)
bzrlib.errors.NotBranchError: Not a branch: /

Presumably I need to somehow tell the bzr what the working tree root
is? it seems to be looking in /. This is when running the program from
within the test bzr working tree.

Ideally what I'd like to be able to do is instantiate a bzr object
that represents a working tree and call methods to give me a list of
modified files, or added files, etc. At the moment I'm not really
understanding how I'm meant to be performing functions on the working
tree programmatically.


bzr_wt = bzr('/tmp/bzrtest')
for moddedfile in bzr_wt.getModfiied():
    print (moddedfile.filename)



On 8/7/07, Martin Pool <mbp at> wrote:
> On 8/7/07, Jeremy Wilkins <jeb at> wrote:
> > I am thanks. I'd assumed the recommended method of integration was
> > treating bazaar like a  library but if os.system is the recommended
> > way, thats probably easiest for me.
> >
> > I'd had a look through the General HACKING HOWTO but that was more
> > focused on hacking on bazaar as opposed to integration issues.
> Using it as a library is the recommended way.
> --
> Martin

More information about the bazaar mailing list