drawdag: inline transaction() function
I suspect Jun wrote the method before he learnt that Python 2.7 allows
multiple context managers in a single with-clause.
--- a/tests/drawdag.py Sun Jun 25 12:41:34 2017 -0700
+++ b/tests/drawdag.py Fri Jun 30 23:15:09 2017 -0700
@@ -83,7 +83,6 @@
from __future__ import absolute_import, print_function
import collections
-import contextlib
import itertools
from mercurial.i18n import _
@@ -277,13 +276,6 @@
if leaf in v:
v.remove(leaf)
-@contextlib.contextmanager
-def transaction(repo):
- with repo.wlock():
- with repo.lock():
- with repo.transaction('drawdag'):
- yield
-
@command('debugdrawdag', [])
def debugdrawdag(ui, repo, **opts):
"""read an ASCII graph from stdin and create changesets
@@ -332,7 +324,7 @@
local=True)
# handle special comments
- with transaction(repo):
+ with repo.wlock(), repo.lock(), repo.transaction('drawdag'):
getctx = lambda x: repo.unfiltered()[committed[x.strip()]]
for line in text.splitlines():
if ' # ' not in line: