The code below creates a button, bzr, which when clicked shows bzr stat output in the log. When right-clicked, it allows you to execute any bzr q* command in the path context of the current node. You need to run the script with if 0: at the top once to create all the submenu items, then change it back to if 1:.

bzrbut.png
# to generate right-click button commands for all the bzr q* commands
# (Qt interface for bzr) as children of this @button node, change the
# `if 1` to `if 0` and run this script

if 1:

    import subprocess

    path = g.getAbsPathFromNode(c,p) or c.getNodePath(p)
    cmd = subprocess.Popen(['bzr', 'stat', path], stdin=subprocess.PIPE,
      stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    stdout,stderr = cmd.communicate()

    g.es("\n\n".join([stdout,stderr]))

else:

    # bzr help commands | grep ^q | sed 's/ .*//' | tr \\n ' '

    qcoms = """qadd qannotate qbind qbranch qbrowse qcat qcommit qconfig
        qconflicts qdiff qexport qgetnew qgetupdates qinfo qinit qlog
        qmerge qplugins qpull qpush qrevert qrun qsend qswitch qtag
        qunbind quncommit qupdate qversion qviewer""".split()
    for q in qcoms:
        nd = p.insertAsLastChild()
        nd.h = '@rclick '+q
        nd.b = """import subprocess

path = g.getAbsPathFromNode(c,p) or c.getNodePath(p)
cmd = subprocess.Popen(['bzr', '%s', path], stdin=subprocess.PIPE,
  stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout,stderr = cmd.communicate()""" % q
    c.redraw()

    g.es('Added qbzr right-click menu items')