Commits

Waldemar Kornewald  committed d2ff544

Removed skip_text feature. Use .hgignorechecks instead. Currently it skips all checks. We might want to support skipping only specific checks at some point.

  • Participants
  • Parent commits 7f49602

Comments (0)

Files changed (2)

File hghooks/code.py

 def pep8hook(ui, repo, hooktype, node, pending, **kwargs):
     pep8_ignores = ui.config('pep8', 'ignore', '')
     pep8_params = ui.config('pep8', 'parameters', '')
-    checker_manager = CheckerManager(ui, repo, node, 'no-pep8')
+    checker_manager = CheckerManager(ui, repo, node)
     return checker_manager.check(pep8_checker(pep8_ignores, pep8_params))
 
 def pdbhook(ui, repo, hooktype, node, pending, **kwargs):
-    checker_manager = CheckerManager(ui, repo, node, 'no-pdb')
+    checker_manager = CheckerManager(ui, repo, node)
     return checker_manager.check(pdb_checker)
 
 def pyflakeshook(ui, repo, hooktype, node, pending, **kwargs):
-    checker_manager = CheckerManager(ui, repo, node, 'no-pyflakes')
+    checker_manager = CheckerManager(ui, repo, node)
     return checker_manager.check(pyflakes_checker)
 
 def allhook(*args, **kwargs):

File hghooks/manager.py

 # You should have received a copy of the GNU Lesser General Public License
 # along with hghooks.  If not, see <http://www.gnu.org/licenses/>.
 
+from hghooks.checkers import re_options
 from mercurial import match, ignore, util
 import os
 import re
 import shutil
 import tempfile
-from hghooks.checkers import re_options
-
-skip_pattern = re.compile('# hghooks: (.*)', re_options)
 
 class CheckerManager(object):
 
-    def __init__(self, ui, repo, node, skip_text=None):
+    def __init__(self, ui, repo, node):
         self.ui = ui
         self.repo = repo
         self.node = node
-        self.skip_text = skip_text
-
-    def skip_file(self, filename, filedata):
-        if not filename.endswith('.py'):
-            return True
-
-        for match in skip_pattern.findall(filedata):
-            if self.skip_text in match:
-                return True
-
-        return False
 
     def check(self, checker):
         # TODO: Test latest revision on all new/modified heads
             revctx = self.repo[revision]
 
             for filename in revctx.files():
-                if filename not in existing_files or ignorefunc(filename):
+                if filename not in existing_files or ignorefunc(filename) or \
+                        not filename.endswith('.py'):
                     continue
 
                 full_path = os.path.join(directory, filename)
                 filectx = ctx.filectx(filename)
                 filedata = filectx.data()
 
-                if self.skip_text and self.skip_file(filename, filedata):
-                    continue
-
                 modified_files[full_path] = filedata
 
         if modified_files: