# HG changeset patch # User timeless # Date 2016-01-07 01:28:59 # Node ID 2af351bd289c9b2fdf2d852715ab4ed4213e900b # Parent f47185f09533e156f4121279c19acb140bcceabd check-commit: support REVs as commandline arguments usage: * HG_NODE=REV check-commit * hg export REV | check-commit * check-commit REV ... diff --git a/contrib/check-commit b/contrib/check-commit --- a/contrib/check-commit +++ b/contrib/check-commit @@ -35,8 +35,9 @@ errors = [ (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 @@ def checkcommit(commit): 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 @@ def readcommit(node): 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)