plugin not working on lightweight checkouts

Chris Hecker checker at d6.com
Mon Nov 30 06:57:14 UTC 2015


It looks like that's the one Sebastien tested that didn't work, it 
hooked too early?

Chris

On 2015-11-29 22:55, Joshua Judson Rosen wrote:
> On 11/29/2015 05:24 AM, Chris Hecker wrote:
>>
>>> I was expecting it to react on "bzr update" and "bzr commit".
>>> However, it only seems to react on "bzr commit".
>>
>> Yeah, exactly, this is why I started the thread.  :)
>>
>> Thanks for looking into it...hopefully there's a hook we can use?
>
> I think in order to catch updates to the _working tree_
> that don't changes to the _branch_ (as is the case for "bzr update"),
> you need to also establish a MutableTree hook--something like this:
>
> 	mutabletree.MutableTree.hooks.install_named_hook('post_transform',
> 	                                                 update_revno_file,
> 	                                                 'Update "revno" file on working-tree update')
>
>
> Note that you'll need to change your update_revno_file() function
> for that to work, because it'll be called with different
> parameters than its currently expecting, but that's a starting point.
>
> Actually, you probably want to just use the various MutableTree hooks
> (MutableTree 'post_commit' + MutableTree 'post_transform'),
> and _not_ use the Branch hook. It looks like you're only interested
> in catching changes to working trees--not to branches per se;
> i.e.: you do not want to catch new revisions being pushed/pulled
> into a branch that _doesn't_ have a working tree
> (which the branch 'post_change_branch_tip' hook _will_ catch).
>
>
>> On 2015-11-29 00:53, Sebastien Alaiwan wrote:
>>> I tested your plugin with a single standalone tree.
>>>
>>> I was expecting it to react on "bzr update" and "bzr commit".
>>> However, it only seems to react on "bzr commit".
>>>
>>> Test of "bzr update":
>>>
>>> *$ bzr up*
>>> Tree is up to date at revision 77 of branch /tmp/deeep
>>> *$ head revno -n 1*
>>> 77
>>> *$ bzr up -r 75*
>>>    M  README
>>> All changes applied successfully.
>>> Updated to revision 75 of branch /tmp/deeep
>>> *$ head revno -n 1*
>>> 77
>>> *$ *
>>>
>>>
>>>
>>> Test of "bzr commit":
>>>
>>> *$ **bzr up*
>>>    M  README
>>> All changes applied successfully.
>>> Updated to revision 77 of branch /tmp/deeep
>>> *$**echo "Hello" >> README *
>>> *$**bzr commit -m "Test"*
>>> Committing to: /tmp/deeep/
>>> modified README
>>> /update_revno_file//(this is my debug trace).
>>> /Committed revision 78.
>>> *$ head revno -n 1*
>>> 78
>>>
>>> This might be related to the problem you're having.
>>> Is this the expected behaviour? Not updating the "revno" file on "bzr
>>> update -r XXX" commands seems error-prone, as you might want to build
>>> older revisions of your project.
>>>
>>> I was about to suggest to directly use, from your build system, the
>>> ".bzr/branch/last-revision" file.
>>> However, this will couple your build system to bazaar ; which you
>>> probably want to avoid.
>>>
>>> Cheers,
>>> Sebastien
>>>
>>>
>>> On 2015-11-28 09:35, Chris Hecker wrote:
>>>>
>>>> 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