[MERGE] More explicit use of Tree.get_root_id()

John Arbash Meinel john at arbash-meinel.com
Fri Oct 26 22:25:06 BST 2007


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

James Westby wrote:
> On (26/10/07 14:23), John Arbash Meinel wrote:
>> +    def test_get_root_id_default(self):
>> +        tree = self.get_tree_with_default_root_id()
>> +        tree.lock_read()
>> +        self.addCleanup(tree.unlock)
> 
> Can I ask what the difference is between this and using try/finally?
> 
> Thanks,
> 
> James
> 

Nothing. It just means I don't have to indent. It also means the tests are 2
lines shorter (you don't have the 'try' and 'finally' lines).
Also, you can't lock and unlock multiple times this way. Well you can, but you
need to leave the tree in a locked state. And it isn't logically very nice to
lock and unlock multiple times with a pending unlock at the end.

John
=:->

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

iD8DBQFHIlsyJdeBCYSNAAMRAre/AKDEYR/HxDQHgpigSmRfXqXq7D0mBQCfXgyl
k+1ojEamsscBT3nPymy9GfM=
=921C
-----END PGP SIGNATURE-----



More information about the bazaar mailing list