[PATCH 1 of 2] util: rename ctxmanager's __call__ method to enter

Bryan O'Sullivan bos at serpentine.com
Thu Jan 14 17:31:07 UTC 2016


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1452792661 28800
#      Thu Jan 14 09:31:01 2016 -0800
# Node ID e0d9c51605b76a3aaf5e694cd251d9af17032780
# Parent  443848eece189002c542339dc1cf84f49a94c824
util: rename ctxmanager's __call__ method to enter

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2659,7 +2659,7 @@ class ctxmanager(object):
     def __enter__(self):
         return self
 
-    def __call__(self):
+    def enter(self):
         '''Create and enter context managers in the order in which they were
         passed to the constructor.'''
         values = []
diff --git a/tests/test-ctxmanager.py b/tests/test-ctxmanager.py
--- a/tests/test-ctxmanager.py
+++ b/tests/test-ctxmanager.py
@@ -45,7 +45,7 @@ class test_ctxmanager(unittest.TestCase)
         trace = []
         addtrace = trace.append
         with ctxmanager(ctxmgr('a', addtrace), ctxmgr('b', addtrace)) as c:
-            a, b = c()
+            a, b = c.enter()
             c.atexit(addtrace, ('atexit', 'x'))
             c.atexit(addtrace, ('atexit', 'y'))
         self.assertEqual(trace, [('enter', 'a'), ('enter', 'b'),
@@ -58,7 +58,7 @@ class test_ctxmanager(unittest.TestCase)
         with self.assertRaises(ctxerror):
             with ctxmanager(ctxmgr('a', addtrace),
                            lambda: raise_on_enter('b', addtrace)) as c:
-                c()
+                c.enter()
                 addtrace('unreachable')
         self.assertEqual(trace, [('enter', 'a'), ('raise', 'b'), ('exit', 'a')])
 
@@ -68,7 +68,7 @@ class test_ctxmanager(unittest.TestCase)
         with self.assertRaises(ctxerror):
             with ctxmanager(ctxmgr('a', addtrace),
                            lambda: raise_on_exit('b', addtrace)) as c:
-                c()
+                c.enter()
                 addtrace('running')
         self.assertEqual(trace, [('enter', 'a'), ('enter', 'b'), 'running',
                                  ('raise', 'b'), ('exit', 'a')])


More information about the Mercurial-devel mailing list