<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    <br>
    Hi, I've never tried to write a plugin before, and my python skills
    are at the barely-literate level, so I'm wondering if someone who
    knows the bzr api inside and out can tell me if I'm doing this
    right.<br>
    <br>
    I'm trying to write a post_commit hook that will put the new revno
    in a file at the root of the branch, if that file already exists. 
    Here's what I have so far, does this look right?  It seems to work.<br>
    <br>
    This is to update a version resource in an executable.  Visual
    Studio is totally broken in the way it handles build events and
    custom build steps, so I can't use bzr revno or version-info because
    I need a file that changes on every commit, sadly.<br>
    <br>
    Thanks,<br>
    Chris<br>
    <br>
    <br>
    revno_commit_file.py:<br>
    <br>
    <small><tt>import bzrlib.branch<br>
        <br>
        def post_commit_hook(local, master, old_revno, old_revid,
        new_revno, new_revid):<br>
            import bzrlib.urlutils<br>
            import os.path<br>
            p = bzrlib.urlutils.local_path_from_url(master.base) +
        'revno'<br>
            if os.path.isfile(p):<br>
                f = open(p,'w')<br>
                f.write(str(new_revno))<br>
                f.close()<br>
        <br>
        # my version of bzr doesn't have install_lazy_named_hook, sadly<br>
        bzrlib.branch.Branch.hooks.install_named_hook('post_commit', <br>
                                                      post_commit_hook,
        <br>
                                                      'Update revno file
        on commit, if it exists.')<br>
      </tt></small><br>
  </body>
</html>