changeset 47635:752109dc2fb7

check-code: add a rules to catch os.path.abspath All previous usages have been migrated. So let us add a check-code rules to catch future usages. We restrict it to mercurial/ and hgext/ because multiple other script never depends on Mercurial modules. Differential Revision: https://phab.mercurial-scm.org/D11072
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 10 Jul 2021 13:46:35 +0200
parents 352ada3aab70
children b2ed9480b34a
files contrib/check-code.py
diffstat 1 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/check-code.py	Sat Jul 10 14:07:33 2021 +0200
+++ b/contrib/check-code.py	Sat Jul 10 13:46:35 2021 +0200
@@ -545,6 +545,22 @@
     ),
 ]
 
+# pattern only for mercurial and extensions
+core_py_pats = [
+    [
+        # Windows tend to get confused about capitalization of the drive letter
+        #
+        # see mercurial.windows.abspath for details
+        (
+            r'os\.path\.abspath',
+            "use util.abspath instead (windows)",
+            r'#.*re-exports',
+        ),
+    ],
+    # warnings
+    [],
+]
+
 # filters to convert normal *.py files
 pyfilters = [] + commonpyfilters
 
@@ -700,6 +716,13 @@
         pyfilters,
         py3pats,
     ),
+    (
+        'core files',
+        r'.*(hgext|mercurial)/(?!demandimport|policy|pycompat).*\.py',
+        '',
+        pyfilters,
+        core_py_pats,
+    ),
     ('test script', r'(.*/)?test-[^.~]*$', '', testfilters, testpats),
     ('c', r'.*\.[ch]$', '', cfilters, cpats),
     ('unified test', r'.*\.t$', '', utestfilters, utestpats),