extensions: deprecate extsetup without a `ui` argument (API)
authorMatt Harbison <matt_harbison@yahoo.com>
Thu, 27 Dec 2018 21:46:03 -0500
changeset 41068 28a4fb793ba1
parent 41067 f2601cbce209
child 41069 70ca0e846d25
extensions: deprecate extsetup without a `ui` argument (API) 9.5 years should be enough time, but there were some tests for the old style still (which are now updated). Exthelper doesn't fallback to the old API, so this is for consistency. .. api:: The extension hook ``extsetup`` without a `ui` argument has been deprecated, and will be removed in the next version. Add a `ui` argument to avoid the deprecation warning.
hgext/highlight/__init__.py
mercurial/extensions.py
tests/notcapable
tests/test-dirstate-race.t
tests/test-extension.t
tests/test-http-bundle1.t
tests/test-http.t
tests/test-largefiles-wireproto.t
tests/test-lfs-serve-access.t
--- a/hgext/highlight/__init__.py	Thu Dec 27 21:27:43 2018 -0500
+++ b/hgext/highlight/__init__.py	Thu Dec 27 21:46:03 2018 -0500
@@ -87,7 +87,7 @@
     ]))
     return web.res.sendresponse()
 
-def extsetup():
+def extsetup(ui):
     # monkeypatch in the new version
     extensions.wrapfunction(webcommands, '_filerevision',
                             filerevision_highlight)
--- a/mercurial/extensions.py	Thu Dec 27 21:27:43 2018 -0500
+++ b/mercurial/extensions.py	Thu Dec 27 21:46:03 2018 -0500
@@ -226,6 +226,8 @@
             except TypeError:
                 if pycompat.getargspec(extsetup).args:
                     raise
+                ui.deprecwarn("extsetup for '%s' must take a ui argument"
+                              % name, "4.9")
                 extsetup() # old extsetup with no ui argument
         except Exception as inst:
             ui.traceback(force=True)
--- a/tests/notcapable	Thu Dec 27 21:27:43 2018 -0500
+++ b/tests/notcapable	Thu Dec 27 21:46:03 2018 -0500
@@ -7,7 +7,7 @@
 
 cat > notcapable-$CAP.py << EOF
 from mercurial import extensions, localrepo, repository
-def extsetup():
+def extsetup(ui):
     extensions.wrapfunction(repository.peer, 'capable', wrapcapable)
     extensions.wrapfunction(localrepo.localrepository, 'peer', wrappeer)
 def wrapcapable(orig, self, name, *args, **kwargs):
--- a/tests/test-dirstate-race.t	Thu Dec 27 21:27:43 2018 -0500
+++ b/tests/test-dirstate-race.t	Thu Dec 27 21:46:03 2018 -0500
@@ -53,7 +53,7 @@
   >     context,
   >     extensions,
   > )
-  > def extsetup():
+  > def extsetup(ui):
   >     extensions.wrapfunction(context.workingctx, '_checklookup', overridechecklookup)
   > def overridechecklookup(orig, self, files):
   >     # make an update that changes the dirstate from underneath
--- a/tests/test-extension.t	Thu Dec 27 21:27:43 2018 -0500
+++ b/tests/test-extension.t	Thu Dec 27 21:46:03 2018 -0500
@@ -279,7 +279,7 @@
   > NO_CHECK_EOF
   $ cat > loadabs.py <<NO_CHECK_EOF
   > import mod.ambigabs as ambigabs
-  > def extsetup():
+  > def extsetup(ui):
   >     print('ambigabs.s=%s' % ambigabs.s, flush=True)
   > NO_CHECK_EOF
   $ "$PYTHON" $TESTTMP/unflush.py loadabs.py
@@ -295,7 +295,7 @@
   > NO_CHECK_EOF
   $ cat > loadrel.py <<NO_CHECK_EOF
   > import mod.ambigrel as ambigrel
-  > def extsetup():
+  > def extsetup(ui):
   >     print('ambigrel.s=%s' % ambigrel.s, flush=True)
   > NO_CHECK_EOF
   $ "$PYTHON" $TESTTMP/unflush.py loadrel.py
--- a/tests/test-http-bundle1.t	Thu Dec 27 21:27:43 2018 -0500
+++ b/tests/test-http-bundle1.t	Thu Dec 27 21:46:03 2018 -0500
@@ -186,7 +186,7 @@
   >     if base64.b64decode(auth.split()[1]).split(b':', 1) != [b'user',
   >                                                             b'pass']:
   >         raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no')
-  > def extsetup():
+  > def extsetup(ui):
   >     common.permhooks.insert(0, perform_authentication)
   > EOT
   $ hg serve --config extensions.x=userpass.py -p $HGPORT2 -d --pid-file=pid \
--- a/tests/test-http.t	Thu Dec 27 21:27:43 2018 -0500
+++ b/tests/test-http.t	Thu Dec 27 21:46:03 2018 -0500
@@ -181,7 +181,7 @@
   >                 [(b'WWW-Authenticate', b'Basic Realm="mercurial"')])
   >     if base64.b64decode(auth.split()[1]).split(b':', 1) != [b'user', b'pass']:
   >         raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no')
-  > def extsetup():
+  > def extsetup(ui):
   >     common.permhooks.insert(0, perform_authentication)
   > EOT
   $ hg serve --config extensions.x=userpass.py -p $HGPORT2 -d --pid-file=pid \
@@ -526,7 +526,7 @@
   >     if not cookie:
   >         raise common.ErrorResponse(common.HTTP_SERVER_ERROR, b'no-cookie')
   >     raise common.ErrorResponse(common.HTTP_SERVER_ERROR, b'Cookie: %s' % cookie)
-  > def extsetup():
+  > def extsetup(ui):
   >     common.permhooks.insert(0, perform_authentication)
   > EOF
 
--- a/tests/test-largefiles-wireproto.t	Thu Dec 27 21:27:43 2018 -0500
+++ b/tests/test-largefiles-wireproto.t	Thu Dec 27 21:46:03 2018 -0500
@@ -430,7 +430,7 @@
   >                 [(b'WWW-Authenticate', b'Basic Realm="mercurial"')])
   >     if base64.b64decode(auth.split()[1]).split(b':', 1) != [b'user', b'pass']:
   >         raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no')
-  > def extsetup():
+  > def extsetup(ui):
   >     common.permhooks.insert(0, perform_authentication)
   > EOT
   $ hg serve --config extensions.x=userpass.py -R credentialmain \
--- a/tests/test-lfs-serve-access.t	Thu Dec 27 21:27:43 2018 -0500
+++ b/tests/test-lfs-serve-access.t	Thu Dec 27 21:46:03 2018 -0500
@@ -404,7 +404,7 @@
   >     if base64.b64decode(auth.split()[1]).split(b':', 1) != [b'user',
   >                                                             b'pass']:
   >         raise common.ErrorResponse(common.HTTP_FORBIDDEN, b'no')
-  > def extsetup():
+  > def extsetup(ui):
   >     common.permhooks.insert(0, perform_authentication)
   > EOF