[MERGE] Deprecate compare_trees
John Arbash Meinel
john at arbash-meinel.com
Wed Jul 26 23:13:31 BST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robert Collins wrote:
> This patch deprecates compare_trees, moving its body to
> InterTree.changes_from. At the same time, to facilitate code reuse, I
> pulled up the lock_read, lock_write and unlock methods from
> InterRepository to InterObject and documented in the docstring what
> conditions they may be used under.
>
> Cheers,
> Rob
...
> === modified file 'bzrlib/inter.py'
> --- bzrlib/inter.py 2006-03-02 01:26:22 +0000
> +++ bzrlib/inter.py 2006-07-26 07:31:07 +0000
> @@ -29,6 +29,11 @@
> operations with another of similar type - they will always forward to
> a subclass of InterObject - i.e.
> InterVersionedFile.get(other).method_name(parameters).
> +
> + If the source and target objects implement the locking protocol -
> + lock_read, lock_write, unlock, then the InterObject's lock_read,
> + lock_write and unlock methods may be used (optionally in conjunction with
> + the needs_read_lock and needs_write_lock decorators.)
> """
>
> # _optimisers = set()
> @@ -47,6 +52,17 @@
> self.source = source
> self.target = target
>
> + def _double_lock(self, lock_source, lock_target):
> + """Take out too locks, rolling back the first if the second throws."""
> + lock_source()
> + try:
> + lock_target()
> + except Exception:
> + # we want to ensure that we don't leave source locked by mistake.
> + # and any error on target should not confuse source.
> + self.source.unlock()
> + raise
> +
By your description of python2.5 issues (KeyboardInterrupt not being
caught by Exception), it would seem that this should be a bare 'except:'
Otherwise it looks good to me.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEx+kKJdeBCYSNAAMRAoctAJ9OXCZYR1M6+6afT5iDL0pn6OC9igCgyLRE
p6OB8X1TLliWMfd2w4pp3ZA=
=Nbdy
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list