Deleted Added
sdiff udiff text old ( 10294:b58f6afe14c5 ) new ( 10674:e2f9644a7738 )
full compact
1#! /usr/bin/env python
2# Copyright (c) 2014 ARM Limited
3# All rights reserved
4#
5# The license below extends only to copyright in the software and shall
6# not be construed as granting a license to any other intellectual
7# property including but not limited to intellectual property relating
8# to a hardware implementation of the functionality of the software

--- 144 unchanged lines hidden (view full) ---

153class StdioUI(UserInterface):
154 def do_prompt(self, prompt, results, default):
155 return raw_input(prompt) or default
156
157 def write(self, string):
158 sys.stdout.write(string)
159
160class Verifier(object):
161 def __init__(self, ui, repo=None):
162 self.ui = ui
163 self.repo = repo
164 if repo is None:
165 self.wctx = None
166
167 def __getattr__(self, attr):
168 if attr in ('prompt', 'write'):
169 return getattr(self.ui, attr)
170
171 if attr == 'wctx':
172 try:
173 wctx = repo.workingctx()
174 except:
175 from mercurial import context
176 wctx = context.workingctx(repo)
177 self.wctx = wctx
178 return wctx
179
180 raise AttributeError
181
182 def open(self, filename, mode):
183 if self.repo:
184 filename = self.repo.wjoin(filename)
185
186 try:
187 f = file(filename, mode)
188 except OSError, msg:
189 print 'could not open file %s: %s' % (filename, msg)
190 return None
191
192 return f
193
194 def skip(self, filename):
195 # We never want to handle symlinks, so always skip them: If the location
196 # pointed to is a directory, skip it. If the location is a file inside
197 # the gem5 directory, it will be checked as a file, so symlink can be
198 # skipped. If the location is a file outside gem5, we don't want to
199 # check it anyway.
200 if os.path.islink(filename):
201 return True
202 return lang_type(filename) not in self.languages

--- 239 unchanged lines hidden (view full) ---

442 opt_no_ignore = opts.get('no_ignore', False)
443 ui = MercurialUI(hgui, hgui.verbose, opt_fix_white)
444
445 def prompt(name, func, regions=all_regions):
446 result = ui.prompt("(a)bort, (i)gnore, or (f)ix?", 'aif', 'a')
447 if result == 'a':
448 return True
449 elif result == 'f':
450 func(repo.wjoin(name), regions)
451
452 return False
453
454
455 # Import the match (repository file name matching helper)
456 # function. Different versions of Mercurial keep it in different
457 # modules and implement them differently.
458 try:

--- 12 unchanged lines hidden (view full) ---

471 from mercurial import context
472 wctx = context.workingctx(repo)
473
474 files = [ (fn, all_regions) for fn in added ] + \
475 [ (fn, modregions(wctx, fn)) for fn in modified ]
476 else:
477 files = [ (fn, all_regions) for fn in added + modified + clean ]
478
479 whitespace = Whitespace(ui)
480 sorted_includes = SortedIncludes(ui)
481 for fname, mod_regions in files:
482 if not opt_no_ignore and check_ignores(fname):
483 continue
484
485 fpath = joinpath(repo.root, fname)
486
487 if whitespace.apply(fpath, prompt, mod_regions):
488 return True
489
490 if sorted_includes.apply(fpath, prompt, mod_regions):
491 return True
492
493 return False
494
495def do_check_format(hgui, repo, **args):
496 ui = MercurialUI(hgui, hgui.verbose, auto)
497
498 modified, added, removed, deleted, unknown, ignore, clean = repo.status()

--- 117 unchanged lines hidden ---