[PATCH] {RFC} commands: switch to ctxmanager in phase
Gregory Szorc
gregory.szorc at gmail.com
Mon Jan 11 18:11:04 CST 2016
On Mon, Jan 11, 2016 at 3:40 PM, Bryan O'Sullivan <bos at serpentine.com>
wrote:
>
> On Mon, Jan 11, 2016 at 3:34 PM, Bryan O'Sullivan <bos at serpentine.com>
> wrote:
>
>> + with util.ctxmanager(repo.lock, repo.translambda('phase')) as c:
>>
>
> I forgot the patch that introduces translambda; it simply defers
> repo.transaction with a lambda because that pattern is used so heavily.
>
> This patch series is several dozen long, all very simple transformations
> of this sort. I think the introductory patch should be enough to get
> conversation started :-)
>
+1 to moving locks and transactions to context managers.
As much as we use the pattern of obtaining a lock *and* a transaction, I
think it might be worthwhile to introduce a utility context manager. e.g.
with repo.lockandtransaction('phase') as c:
lock, tr = c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20160111/c7394628/attachment.html>
More information about the Mercurial-devel
mailing list