[PATCH 3 of 8 RFC] vfs: add check pattern for using file APIs of os module
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Fri Jun 15 14:45:14 UTC 2012
# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1339768793 -32400
# Node ID 649cab17ed60acdffc1d50a0f6cb2c19ac391f98
# Parent 02d1b3da58fbff7d2bb8d1e21d3cc352bdad211e
vfs: add check pattern for using file APIs of os module
vfs provides only functions below, but check pattern also matches
other file APIs of os module.
- chdir
- chmod
- getcwd
- listdir
- lstat
- makedirs
- mkdir
- open
- readlink
- remove
- removedirs
- rename
- rmdir
- stat
- symlink
- unlink
- utime
- walk
this patch also omit checking against:
- mercurial/posix.py
- mercurial/windows.py
- mercurial/win32.py
these should invoke file API in "os" directly
- contrib/casesmash
- contrib/setup3k
- contrib/tmplrewrite
- contrib/check-code
these must not import util module
diff -r 02d1b3da58fb -r 649cab17ed60 contrib/check-code.py
--- a/contrib/check-code.py Fri Jun 15 22:59:53 2012 +0900
+++ b/contrib/check-code.py Fri Jun 15 22:59:53 2012 +0900
@@ -265,6 +265,19 @@
[]
]
+vfspats = [
+ [
+ ],
+ # warnings
+ [
+ (r'os\.(access|chdir|chmod|chown|chroot|getcwd|getcwdu|lchown|link|'
+ 'listdir|lstat|makedirs|mkdir|mkfifo|mknod|open|pathconf|readlink|'
+ 'remove|removedirs|rename|renames|rmdir|stat|statvfs|symlink|tempnam|'
+ 'tmpfile|tmpnam|unlink|utime|walk)',
+ "don't use file API of os module directly. use via util.vfs()"),
+ ]
+]
+
checks = [
('python', r'.*\.(py|cgi)$', None, pyfilters, pypats),
('test script', r'(.*/)?test-[^.~]*$', None, testfilters, testpats),
@@ -274,6 +287,11 @@
pyfilters, inrevlogpats),
('layering violation ui in util', r'mercurial/util\.py', None,
pyfilters, inutilpats),
+ ('file API via vfs',
+ r'(hgext|mercurial|contrib)/.*\.py$',
+ r'(mercurial/(posix|windows|win32)|'
+ 'contrib/(casesmash|check-code|setup3k|tmplrewrite))\.py$',
+ pyfilters, vfspats),
]
class norepeatlogger(object):
More information about the Mercurial-devel
mailing list