Johann's bzr request

Lalo Martins lalo at exoweb.net
Thu Sep 22 08:08:55 BST 2005


And so says James Blackwell on 22/09/05 14:07...
> command, or is there a way to use bzr as a library?

Well, bzr is *supposed* to be usable as a library.  But wrapping around
the cmd_* objects is not the best way.

The code in builtins is the command-line interface, and it's not worth
the trouble trying to force it to do what you want.

Rather, look at the source for the command you want to use, and do
something similar in your own code.

For example, this is (more or less) how you could get a diff:

from bzrlib.branch import Branch
from bzrlib.diff import show_diff, compare_trees
from cStringIO import StringIO
diff_data = StringIO()
show_diff(Branch.open(branchpath), None, None, output=diff_data)

And believe me, most operations are simpler than that.  The equivalent
to `bzr revno`:
from bzrlib.branch import Branch
revno = Branch.open(branchpath).revno()


(I suppose we need to start working on some API documentation...)

best,
                                               Lalo Martins
--
      So many of our dreams at first seem impossible,
       then they seem improbable, and then, when we
       summon the will, they soon become inevitable.
--
http://www.exoweb.net/                  mailto:lalo at exoweb.net
GNU: never give up freedom                 http://www.gnu.org/





More information about the bazaar mailing list