Patchwork exchange: use context manager for bundle1 unbundling

login
register
mail settings
Submitter via Mercurial-devel
Date June 16, 2017, 6:02 a.m.
Message ID <31b11625ed4218a1ab33.1497592931@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/21426/
State Accepted
Headers show

Comments

via Mercurial-devel - June 16, 2017, 6:02 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1497592640 25200
#      Thu Jun 15 22:57:20 2017 -0700
# Node ID 31b11625ed4218a1ab33ffacd1b6d0fe11996f55
# Parent  2d327b17f319e8e3305c33734d0202978d57f0f9
exchange: use context manager for bundle1 unbundling

The lazy locking is not used for bundle1, so using a regular context
manager is clearer.
Sean Farley - June 16, 2017, 6:04 a.m.
Martin von Zweigbergk via Mercurial-devel
<mercurial-devel@mercurial-scm.org> writes:

> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1497592640 25200
> #      Thu Jun 15 22:57:20 2017 -0700
> # Node ID 31b11625ed4218a1ab33ffacd1b6d0fe11996f55
> # Parent  2d327b17f319e8e3305c33734d0202978d57f0f9
> exchange: use context manager for bundle1 unbundling
>
> The lazy locking is not used for bundle1, so using a regular context
> manager is clearer.

Nice, queued. Thanks!

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1733,8 +1733,8 @@ 
         # push can proceed
         if not util.safehasattr(cg, 'params'):
             # legacy case: bundle1 (changegroup 01)
-            lockandtr[1] = repo.lock()
-            r = cg.apply(repo, source, url)
+            with repo.lock():
+                r = cg.apply(repo, source, url)
         else:
             r = None
             try: