Mercurial > hg
changeset 27781:2af351bd289c
check-commit: support REVs as commandline arguments
usage:
* HG_NODE=REV check-commit
* hg export REV | check-commit
* check-commit REV ...
author | timeless <timeless@mozdev.org> |
---|---|
date | Thu, 07 Jan 2016 01:28:59 +0000 |
parents | f47185f09533 |
children | 7291c8165e33 |
files | contrib/check-commit |
diffstat | 1 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/check-commit Thu Jan 07 00:55:45 2016 +0000 +++ b/contrib/check-commit Thu Jan 07 01:28:59 2016 +0000 @@ -35,8 +35,9 @@ (r"^\+[ \t]+def [a-z]+_[a-z]", "adds a function with foo_bar naming"), ] -def checkcommit(commit): +def checkcommit(commit, node = None): exitcode = 0 + printed = node is None for exp, msg in errors: m = re.search(exp, commit, re.MULTILINE) if m: @@ -44,6 +45,9 @@ for n, l in enumerate(commit.splitlines(True)): pos += len(l) if pos >= m.end(): + if not printed: + printed = True + print "node: %s" % node print "%d: %s" % (n, msg) print " %s" % l[:-1] if "BYPASS" not in os.environ: @@ -55,12 +59,16 @@ return os.popen("hg export %s" % node).read() if __name__ == "__main__": + exitcode = 0 node = os.environ.get("HG_NODE") if node: commit = readcommit(node) + exitcode = checkcommit(commit) + elif sys.argv[1:]: + for node in sys.argv[1:]: + exitcode |= checkcommit(readcommit(node), node) else: commit = sys.stdin.read() - - exitcode = checkcommit(commit) + exitcode = checkcommit(commit) sys.exit(exitcode)