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
--- 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):