Submitter | via Mercurial-devel |
---|---|
Date | July 1, 2017, 6:15 a.m. |
Message ID | <07d2ba135eae10b08603.1498889757@martinvonz.svl.corp.google.com> |
Download | mbox | patch |
Permalink | /patch/21860/ |
State | Accepted |
Headers | show |
Comments
Martin von Zweigbergk via Mercurial-devel <mercurial-devel@mercurial-scm.org> writes: > # HG changeset patch > # User Martin von Zweigbergk <martinvonz@google.com> > # Date 1498889709 25200 > # Fri Jun 30 23:15:09 2017 -0700 > # Node ID 07d2ba135eae10b08603230039c02feb0b1e5039 > # 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. Looks good to me, queued!
On Fri, 30 Jun 2017 23:15:57 -0700, Martin von Zweigbergk via Mercurial-devel wrote: > # HG changeset patch > # User Martin von Zweigbergk <martinvonz@google.com> > # Date 1498889709 25200 > # Fri Jun 30 23:15:09 2017 -0700 > # Node ID 07d2ba135eae10b08603230039c02feb0b1e5039 > # 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 > @@ -277,13 +277,6 @@ > if leaf in v: > v.remove(leaf) > > -@contextlib.contextmanager Removed unused import of contextlib.
Patch
diff --git a/tests/drawdag.py b/tests/drawdag.py --- a/tests/drawdag.py +++ b/tests/drawdag.py @@ -277,13 +277,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 +325,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: