D4690: streamclone: reimplement nested context manager

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Fri Sep 21 15:49:41 UTC 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG97f2992c26f6: streamclone: reimplement nested context manager (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4690?vs=11261&id=11262

REVISION DETAIL
  https://phab.mercurial-scm.org/D4690

AFFECTED FILES
  mercurial/streamclone.py

CHANGE DETAILS

diff --git a/mercurial/streamclone.py b/mercurial/streamclone.py
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -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):



To: durin42, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list