# HG changeset patch # User Martin von Zweigbergk # Date 2017-07-01 06:15:09 # Node ID 0830c841fc7f20bb7d82c1f6571be4a3afd3e0b2 # Parent 6d678ab1b10d0fddc73003d21aa3c7ec43194e2e 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. diff --git a/tests/drawdag.py b/tests/drawdag.py --- a/tests/drawdag.py +++ b/tests/drawdag.py @@ -83,7 +83,6 @@ Some special comments could have side ef from __future__ import absolute_import, print_function import collections -import contextlib import itertools from mercurial.i18n import _ @@ -277,13 +276,6 @@ def _walkgraph(edges): 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 @@ def debugdrawdag(ui, repo, **opts): 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: