--- a/checker.py Thu Jul 07 13:58:38 2016 +0800
+++ b/checker.py Thu Jul 07 14:08:01 2016 +0800
+def hg_clone(url, dest):
+ return run(['hg', 'clone', url, dest])
+ return run(['hg', 'sum'])
+ template = (r'# C&O commit: {rev}:{node}\n'
+ r'# C&O commit branch: {branch}\n'
+ r'# C&O commit date: {date|isodatesec}\n'
+ r'# C&O commit author: {author|person}\n'
+ r'# C&O commit message: {desc|firstline}\n')
+ return run(['hg', 'log', '-r', '.', '-T', template], silent=True)
+def hg_files(include, exclude):
+ cmd.extend(('-I', pat))
+ cmd.extend(('-X', pat))
+ files = run(cmd, silent=True, get_output=True, ignore_codes=(1,))
+ files = files.splitlines()
def execute(tmp, config):
if not prevalidate(config):
print('# C&O task: clone')
print('# C&O project URL: {}'.format(config['url']))
- os.environ['HGPLAIN'] = '1'
+ if config['scm'] == 'hg':
+ os.environ['HGPLAIN'] = '1'
- if not run(['hg', 'clone', config['url'], source]):
+ if config['scm'] == 'hg':
+ if not hg_clone(config['url'], source):
print('$ cd {}'.format(source))
- if not run(['hg', 'sum']):
+ if config['scm'] == 'hg':
- template = (r'# C&O commit: {rev}:{node}\n'
- r'# C&O commit branch: {branch}\n'
- r'# C&O commit date: {date|isodatesec}\n'
- r'# C&O commit author: {author|person}\n'
- r'# C&O commit message: {desc|firstline}\n')
- if not run(['hg', 'log', '-r', '.', '-T', template], silent=True):
+ if config['scm'] == 'hg':
print('# C&O task: setup')
if linter['name'] not in linter_config:
- for pat in linter['include']:
- cmd.extend(('-I', pat))
- for pat in linter.get('exclude', []):
- cmd.extend(('-X', pat))
- files = run(cmd, silent=True, get_output=True, ignore_codes=(1,))
+ if config['scm'] == 'hg':
+ files = hg_files(linter['include'], linter.get('exclude', []))
lc = linter_config[linter['name']]
- for f in files.splitlines():
flags = lc.get('flags', []) + linter.get('flags', [])
pf = lc.get('post_flags', []) + linter.get('post_flags', [])