[RFC/MERGE][#243391] _run_and_cleanup helper (alternative to try/finally)
John Arbash Meinel
john at arbash-meinel.com
Wed Oct 8 20:49:32 BST 2008
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Andrew Bennetts wrote:
> Andrew Bennetts wrote:
>> Hi all,
>>
>> This patch is an extension of my fix for bug 230902 at
> [...]
>
> Ahem. Attached this time.
>
> -Andrew.
>
>
+def _run_and_cleanup(cleanup, callable, *args, **kwargs):
+ """Like ``callable(*args, **kwargs); cleanup()``, but errors from
callable.
+
^- I think the docstring is a bit confusing. The first three times I
read it, I thought it was wrong, though I now understand it. I don't
have much better to say, though perhaps split the "but errors from" out
into another sentence, where you have room to really describe it.
Also, 'callable' is a builtin, so it is nice to not use it for variable
names.
=== modified file 'bzrlib/tests/test_branch.py'
- --- bzrlib/tests/test_branch.py 2008-07-22 19:48:40 +0000
+++ bzrlib/tests/test_branch.py 2008-10-07 11:54:11 +0000
@@ -41,6 +41,7 @@
BzrBranchFormat5,
BzrBranchFormat6,
PullResult,
+ _run_with_write_locked_target,
)
from bzrlib.bzrdir import (BzrDirMetaFormat1, BzrDirMeta1,
BzrDir, BzrDirFormat)
@@ -438,3 +439,70 @@
# it's still supported
a = "%d revisions pulled" % r
self.assertEqual(a, "10 revisions pulled")
+
+
+
+class _StubLockable(object):
+ """Helper for TestRunWithWriteLockedTarget."""
^- too many spaces here
Otherwise I think I like it. Though you should consider Aaron's
suggestion about using a class rather than a simple function.
BB:tweak
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkjtDswACgkQJdeBCYSNAAMksgCeLe3tz2kC0GgBbnaifngDhg1N
yqQAn1iDmdLda+6vbrXqEsEJdah+oSQl
=mhxt
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list