Mercurial > hg-stable
diff mercurial/streamclone.py @ 39773:97f2992c26f6
streamclone: reimplement nested context manager
It's gone in Python 3, and you can't *ctxs into a with statement. Sigh.
Differential Revision: https://phab.mercurial-scm.org/D4690
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 21 Sep 2018 11:43:46 -0400 |
parents | b10d145837bc |
children | d89d5bc06eaa |
line wrap: on
line diff
--- a/mercurial/streamclone.py Fri Sep 21 11:44:08 2018 -0400 +++ b/mercurial/streamclone.py Fri Sep 21 11:43:46 2018 -0400 @@ -10,7 +10,6 @@ import contextlib import os import struct -import warnings from .i18n import _ from . import ( @@ -568,12 +567,13 @@ @contextlib.contextmanager def nested(*ctxs): - with warnings.catch_warnings(): - # For some reason, Python decided 'nested' was deprecated without - # replacement. They officially advertised for filtering the deprecation - # warning for people who actually need the feature. - warnings.filterwarnings("ignore",category=DeprecationWarning) - with contextlib.nested(*ctxs): + this = ctxs[0] + rest = ctxs[1:] + with this: + if rest: + with nested(*rest): + yield + else: yield def consumev2(repo, fp, filecount, filesize):