ObjectNotLocked. What I should do?

John Arbash Meinel john at arbash-meinel.com
Wed Mar 28 19:46:48 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

James Westby wrote:
> On (28/03/07 11:31), Olexandr Byelchenko wrote:
>> I have plugin x-bit that help me to control executable bit
>> in working tree on win32. This plugin operate with inventory.
>>
>> Today (after upgrade one of my branch to WT4) I've got error:
>>
>> E:\work\ping-test>bzr x-bit dtr_sync.py
>> bzr: ERROR: bzrlib.errors.ObjectNotLocked: <WorkingTree4 of E:/work/ping-test> is not locked
>>
>> The code in question:
>>
>>     def run(self, files_list, set=False, clear=False):
>>         from bzrlib.workingtree import WorkingTree
>>
>>         tree = WorkingTree.open_containing(files_list[0])[0]
>           
>           tree.lock_read()
>           try:
> 
>>         inv = tree.read_working_inventory()
> 
>           finally:
>             tree.unlock()
> 
>> Error raised on last line.
>> What I do wrong? And what I need to change to make my plugin works
>> with both WT3 and WT4?
>>
> 
> That is completely untested, and I'm not sure that it keeps
> compatibility with old releases of bzr.
> 
> Thanks,
> 
> James


It is compatible, but since he is modifying the inventory, he should
really be taking out a full 'lock_tree_write()' for the duration of the
command, otherwise he will race with someone else.

But see my other email for a more complete fix. Which should also be
compatibile across bzr versions, and will work on Windows and Linux.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGCrgYJdeBCYSNAAMRApeBAJ9giWiTJVQQ2dWFe3w6EP3mN6EQ2QCg0DjP
W1KZ9zM1nIkpi0UqJ9qG6HM=
=YOl0
-----END PGP SIGNATURE-----



More information about the bazaar mailing list