changeset 65da28dee7cf in /z/repo/gem5 details: http://repo.gem5.org/gem5?cmd=changeset;node=65da28dee7cf description: style: Fix incorrect style checker option name
The style used to support the option -w to automatically fix white space issues. However, this option was actually wired up to fix all styles issues the checker encountered. This changeset cleans up the code that handles automatic fixing and adds an option to fix all issues, and separate options for white spaces and include ordering. diffstat: util/style.py | 33 ++++++++++++++++++++++----------- 1 files changed, 22 insertions(+), 11 deletions(-) diffs (83 lines): diff -r 4972ada74310 -r 65da28dee7cf util/style.py --- a/util/style.py Wed Feb 11 10:23:31 2015 -0500 +++ b/util/style.py Wed Feb 11 10:23:33 2015 -0500 @@ -126,14 +126,10 @@ return mod_regions class UserInterface(object): - def __init__(self, verbose=False, auto=False): - self.auto = auto + def __init__(self, verbose=False): self.verbose = verbose def prompt(self, prompt, results, default): - if self.auto: - return self.auto - while True: result = self.do_prompt(prompt, results, default) if result in results: @@ -436,10 +432,17 @@ """ from mercurial import mdiff, util - opt_fix_white = opts.get('fix_white', False) + opt_fix_all = opts.get('fix_all', False) + if not opt_fix_all: + opt_fix_white = opts.get('fix_white', False) + opt_fix_include = opts.get('fix_include', False) + else: + opt_fix_white = True + opt_fix_include = True + opt_all = opts.get('all', False) opt_no_ignore = opts.get('no_ignore', False) - ui = MercurialUI(hgui, hgui.verbose, opt_fix_white) + ui = MercurialUI(hgui, verbose=hgui.verbose) def prompt(name, func, regions=all_regions): result = ui.prompt("(a)bort, (i)gnore, or (f)ix?", 'aif', 'a') @@ -450,6 +453,12 @@ return False + def no_prompt(name, func, regions=all_regions): + func(name, regions) + return False + + prompt_white = prompt if not opt_fix_white else no_prompt + prompt_include = prompt if not opt_fix_include else no_prompt # Import the match (repository file name matching helper) # function. Different versions of Mercurial keep it in different @@ -481,16 +490,16 @@ if not opt_no_ignore and check_ignores(fname): continue - if whitespace.apply(fname, prompt, mod_regions): + if whitespace.apply(fname, prompt_white, mod_regions): return True - if sorted_includes.apply(fname, prompt, mod_regions): + if sorted_includes.apply(fname, prompt_include, mod_regions): return True return False def do_check_format(hgui, repo, **args): - ui = MercurialUI(hgui, hgui.verbose, auto) + ui = MercurialUI(hgui, hgui.verbose) modified, added, removed, deleted, unknown, ignore, clean = repo.status() @@ -544,7 +553,9 @@ cmdtable = { '^m5style' : ( do_check_style, [ - ('w', 'fix-white', False, _("automatically fix whitespace")), + ('f', 'fix-all', False, _("automatically fix style issues")), + ('', 'fix-white', False, _("automatically fix white space issues")), + ('', 'fix-include', False, _("automatically fix include ordering")), ('a', 'all', False, _("include clean files and unmodified parts of modified files")), ('', 'no-ignore', False, _("ignore the style ignore list")), _______________________________________________ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev