summaryrefslogtreecommitdiff
path: root/util/hgstyle.py
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2016-03-30 15:32:17 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2016-03-30 15:32:17 +0100
commit74f62c784d1af5a6be53e3f49010e0e15a0f312e (patch)
tree1ba93f57c28b1fcadeddc09ec8d2e692a6a8eb8f /util/hgstyle.py
parenta05efc77be5f6df0418ccba5f7bf524773885448 (diff)
downloadgem5-74f62c784d1af5a6be53e3f49010e0e15a0f312e.tar.xz
style: Remove style validators
Style validators provide a subset of the style verifier functionality and are only exposed through the "hg m5format" command. This functionality seems to be both redundant and unused. Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> --HG-- extra : rebase_source : f4847ac3ddc86f6684565b65a942e04979972a7b
Diffstat (limited to 'util/hgstyle.py')
-rwxr-xr-xutil/hgstyle.py101
1 files changed, 3 insertions, 98 deletions
diff --git a/util/hgstyle.py b/util/hgstyle.py
index ccb04a94f..ecdec4b0f 100755
--- a/util/hgstyle.py
+++ b/util/hgstyle.py
@@ -50,8 +50,6 @@ current_dir = os.path.dirname(__file__)
sys.path.insert(0, current_dir)
from style.verifiers import all_verifiers
-from style.validators import all_validators
-from style.file_types import lang_type
from style.style import MercurialUI, check_ignores
from style.region import *
@@ -85,35 +83,6 @@ def modregions(wctx, fname):
return mod_regions
-def validate(filename, verbose, exit_code):
- lang = lang_type(filename)
- if lang not in ('C', 'C++'):
- return
-
- def bad():
- if exit_code is not None:
- sys.exit(exit_code)
-
- try:
- f = file(filename, 'r')
- except OSError:
- if verbose > 0:
- print 'could not open file %s' % filename
- bad()
- return None
-
- vals = [ v(filename, verbose=(verbose > 1), language=lang)
- for v in all_validators ]
-
- for i, line in enumerate(f):
- line = line.rstrip('\n')
- for v in vals:
- v.validate_line(i, line)
-
-
- return vals
-
-
def _modified_regions(repo, patterns, **kwargs):
opt_all = kwargs.get('all', False)
opt_no_ignore = kwargs.get('no_ignore', False)
@@ -198,37 +167,6 @@ def do_check_style(hgui, repo, *pats, **opts):
return False
-def do_check_format(hgui, repo, *pats, **opts):
- """check files for gem5 code formatting violations
-
- Without an argument, checks all modified and added files for gem5
- code formatting violations. A list of files can be specified to
- limit the checker to a subset of the repository. The style rules
- are normally applied on a diff of the repository state (i.e.,
- added files are checked in their entirety while only modifications
- of modified files are checked).
-
- The --all option can be specified to include clean files and check
- modified files in their entirety.
- """
- ui = MercurialUI(hgui, hgui.verbose)
-
- verbose = 0
- for fname, mod_regions in _modified_regions(repo, pats, **opts):
- vals = validate(joinpath(repo.root, fname), verbose, None)
- if vals is None:
- return True
- elif any([not v for v in vals]):
- print "%s:" % fname
- for v in vals:
- v.dump()
- result = ui.prompt("invalid formatting\n(i)gnore or (a)bort?",
- 'ai', 'a')
- if result == 'a':
- return True
-
- return False
-
def check_hook(hooktype):
if hooktype not in ('pretxncommit', 'pre-qrefresh'):
raise AttributeError, \
@@ -247,17 +185,6 @@ def check_style(ui, repo, hooktype, **kwargs):
traceback.print_exc()
return True
-def check_format(ui, repo, hooktype, **kwargs):
- check_hook(hooktype)
- args = {}
-
- try:
- return do_check_format(ui, repo, **args)
- except Exception, e:
- import traceback
- traceback.print_exc()
- return True
-
try:
from mercurial.i18n import _
except ImportError:
@@ -287,31 +214,9 @@ cmdtable = {
'^m5style' : (
do_check_style, all_opts + _common_region_options + commands.walkopts,
_('hg m5style [-a] [FILE]...')),
- '^m5format' :
- ( do_check_format, [
- ] + _common_region_options + commands.walkopts,
- _('hg m5format [FILE]...')),
}
if __name__ == '__main__':
- import argparse
-
- parser = argparse.ArgumentParser(
- description="Check a file for style violations")
-
- parser.add_argument("--verbose", "-v", action="count",
- help="Produce verbose output")
-
- parser.add_argument("file", metavar="FILE", nargs="+",
- type=str,
- help="Source file to inspect")
-
- args = parser.parse_args()
-
- for filename in args.file:
- vals = validate(filename, verbose=args.verbose,
- exit_code=1)
-
- if args.verbose > 0 and vals is not None:
- for v in vals:
- v.dump()
+ print >> sys.stderr, "This file cannot be used from the command line. Use"
+ print >> sys.stderr, "style.py instead."
+ sys.exit(1)