# HG changeset patch # User Augie Fackler # Date 2018-09-21 15:43:46 # Node ID 97f2992c26f69b27af64e59c91a6fa0a706f9252 # Parent 4a8bfec90ae6067f4f1c237f4259ae61ed38b292 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 diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py --- a/mercurial/streamclone.py +++ b/mercurial/streamclone.py @@ -10,7 +10,6 @@ from __future__ import absolute_import import contextlib import os import struct -import warnings from .i18n import _ from . import ( @@ -568,12 +567,13 @@ def generatev2(repo): @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):