plugin not working on lightweight checkouts

Chris Hecker checker at d6.com
Sat Nov 28 08:35:59 UTC 2015


I've got this simple plugin that updates a file named 'revno' with the 
revno and revid at the root of a branch when a checkin or pull happens 
so I can use it in my build system. It works great, and it's below. But, 
I was on another machine that has a lightweight checkout of this project 
and it does not appear to update 'revno' when I push to the repo for 
this branch remotely, and then update the working copy. Is there 
anything I can do to fix this easily?

I didn't immediately see another hook at 
http://doc.bazaar.canonical.com/bzr.dev/en/user-reference/hooks-help.html that 
would help, but I admit I skimmed it...

Thanks,
Chris




"""Update the "revno" file when the branch changes.

This post_change_branch_tip hook puts the current revno in a file called
"revno" in the base directory of the current branch, if it exists. If 
"revno"
doesn't exist, then it is not created."""

from bzrlib import branch
version_info = (1, 0, 0, 'final', 0)

def update_revno_file(params):
     from bzrlib import errors
     try:
         trans = params.branch.bzrdir.root_transport
         path = trans.local_abspath('revno')
     except errors.NotLocalUrl:
         return # Nothing to do for a remote URL
     import os.path
     if os.path.isfile(path):
         f = open(path,'w')
         f.write('%s\n%s' % (params.new_revno,params.new_revid))
         f.close()

branch.Branch.hooks.install_named_hook('post_change_branch_tip',
                                        update_revno_file,
                                        'Update "revno" file on branch 
change, if it exists.')





More information about the bazaar mailing list