Controlling bazaar from python

Aaron Bentley aaron.bentley at utoronto.ca
Wed Aug 8 19:11:13 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jeremy Wilkins wrote:
> I've tried the following simple program
> 
> #!/usr/bin/env python
> 
> from bzrlib import builtins
> 
> sta = builtins.cmd_status()
> sta.run(False, '/tmp/bzrtest/')
> 
> but get the following error

> bzrlib.errors.NotBranchError: Not a branch: /

You are passing '/tmp/bzrtest/' for the file list parameter.  That is
equivalent file_list=['/', 't', 'm', 'p', '/', 'b', 'z', 'r', 't', 'e',
's', 't', '/']

If you pass in ['/tmp/bzrtest/'], you will get the results you want.

> At the moment I'm not really
> understanding how I'm meant to be performing functions on the working
> tree programmatically.

Pretty much the same as cmd_status does it, if you're trying to imitate
status closely.

> eg
> 
> bzr_wt = bzr('/tmp/bzrtest')

bzr_wt = workingtree.WorkingTree.open('/tmp/bzrtest')

> for moddedfile in bzr_wt.getModfiied():

for path, k, t, m in bzr_wt.changes_from(bzr_wt.basis_tree()).modified:

>     print (moddedfile.filename)

    print path

Note that 'delta.TreeDelta.modified' contains files that have only been
modified, not ones that have been renamed and modified.  For details,
see bzrlib/delta.py

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGugdB0F+nu1YWqI0RAtLtAJ4mcgUZCB5WdcQkbxrPussjZN3eoACeI7+4
Xe3qotiHtKBfNueHDg3v7Lk=
=ksMS
-----END PGP SIGNATURE-----



More information about the bazaar mailing list