changeset 49b7d40ee88a in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=49b7d40ee88a
description:
style: clean up style hook code a bit
I've renamed the check_whitespace operation to check_style. You're
going to
need to change your .hg/hgrc file. While you're at it, add a
pre-qrefresh
hook please.
diffstat:
SConstruct | 4 ++--
util/style.py | 27 +++++++++++++--------------
2 files changed, 15 insertions(+), 16 deletions(-)
diffs (115 lines):
diff -r c06505ff551e -r 49b7d40ee88a SConstruct
--- a/SConstruct Mon Jan 10 04:53:34 2011 -0800
+++ b/SConstruct Mon Jan 10 11:11:15 2011 -0800
@@ -177,8 +177,8 @@
style = %s/util/style.py
[hooks]
-pretxncommit.style = python:style.check_whitespace
-pre-qrefresh.style = python:style.check_whitespace
+pretxncommit.style = python:style.check_style
+pre-qrefresh.style = python:style.check_style
""" % (main.root)
mercurial_bin_not_found = """
diff -r c06505ff551e -r 49b7d40ee88a util/style.py
--- a/util/style.py Mon Jan 10 04:53:34 2011 -0800
+++ b/util/style.py Mon Jan 10 11:11:15 2011 -0800
@@ -36,6 +36,7 @@
from file_types import lang_type
+tabsize = 8
lead = re.compile(r'^([ \t]+)')
trail = re.compile(r'([ \t]+)$')
any_control = re.compile(r'\b(if|while|for)[ \t]*[(]')
@@ -69,7 +70,7 @@
if not checkwhite_line(line):
yield line,num + 1
-def fixwhite_line(line, tabsize):
+def fixwhite_line(line):
if lead.search(line):
newline = ''
for i,c in enumerate(line):
@@ -85,7 +86,7 @@
return line.rstrip() + '\n'
-def fixwhite(filename, tabsize, fixonly=None):
+def fixwhite(filename, fixonly=None):
if lang_type(filename) not in whitespace_types:
return
@@ -224,7 +225,7 @@
break
return modified
-def do_check_whitespace(ui, repo, *files, **args):
+def do_check_style(ui, repo, *files, **args):
"""check files for proper m5 style guidelines"""
from mercurial import mdiff, util
@@ -234,7 +235,7 @@
def skip(name):
return files and name in files
- def prompt(name, fixonly=None):
+ def prompt(name, func, fixonly=None):
if args.get('auto', False):
result = 'f'
else:
@@ -246,7 +247,7 @@
if result == 'a':
return True
elif result == 'f':
- fixwhite(repo.wjoin(name), args['tabsize'], fixonly)
+ func(repo.wjoin(name), fixonly)
return False
@@ -264,7 +265,7 @@
ok = False
if not ok:
- if prompt(fname):
+ if prompt(fname, fixwhite):
return True
try:
@@ -337,10 +338,10 @@
raise AttributeError, \
"This hook is not meant for %s" % hooktype
-def check_whitespace(ui, repo, hooktype, **kwargs):
+def check_style(ui, repo, hooktype, **kwargs):
check_hook(hooktype)
- args = { 'tabsize' : 8 }
- return do_check_whitespace(ui, repo, **args)
+ args = {}
+ return do_check_style(ui, repo, **args)
def check_format(ui, repo, hooktype, **kwargs):
check_hook(hooktype)
@@ -355,10 +356,9 @@
cmdtable = {
'^m5style' :
- ( do_check_whitespace,
- [ ('a', 'auto', False, _("automatically fix whitespace")),
- ('t', 'tabsize', 8, _("Number of spaces TAB indents")) ],
- _('hg m5style [-a] [-t <tabsize>] [FILE]...')),
+ ( do_check_style,
+ [ ('a', 'auto', False, _("automatically fix whitespace")) ],
+ _('hg m5style [-a] [FILE]...')),
'^m5format' :
( do_check_format,
[ ],
@@ -393,7 +393,6 @@
code = 1
verbose = 1
- tabsize = 8
for opt,arg in opts:
if opt == '-n':
code = None
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev