##// END OF EJS Templates
check-commit: support REVs as commandline arguments...
timeless -
r27781:2af351bd default
parent child Browse files
Show More
@@ -35,8 +35,9 b' errors = ['
35 35 (r"^\+[ \t]+def [a-z]+_[a-z]", "adds a function with foo_bar naming"),
36 36 ]
37 37
38 def checkcommit(commit):
38 def checkcommit(commit, node = None):
39 39 exitcode = 0
40 printed = node is None
40 41 for exp, msg in errors:
41 42 m = re.search(exp, commit, re.MULTILINE)
42 43 if m:
@@ -44,6 +45,9 b' def checkcommit(commit):'
44 45 for n, l in enumerate(commit.splitlines(True)):
45 46 pos += len(l)
46 47 if pos >= m.end():
48 if not printed:
49 printed = True
50 print "node: %s" % node
47 51 print "%d: %s" % (n, msg)
48 52 print " %s" % l[:-1]
49 53 if "BYPASS" not in os.environ:
@@ -55,12 +59,16 b' def readcommit(node):'
55 59 return os.popen("hg export %s" % node).read()
56 60
57 61 if __name__ == "__main__":
62 exitcode = 0
58 63 node = os.environ.get("HG_NODE")
59 64
60 65 if node:
61 66 commit = readcommit(node)
67 exitcode = checkcommit(commit)
68 elif sys.argv[1:]:
69 for node in sys.argv[1:]:
70 exitcode |= checkcommit(readcommit(node), node)
62 71 else:
63 72 commit = sys.stdin.read()
64
65 exitcode = checkcommit(commit)
73 exitcode = checkcommit(commit)
66 74 sys.exit(exitcode)
General Comments 0
You need to be logged in to leave comments. Login now