##// 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 (r"^\+[ \t]+def [a-z]+_[a-z]", "adds a function with foo_bar naming"),
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 exitcode = 0
39 exitcode = 0
40 printed = node is None
40 for exp, msg in errors:
41 for exp, msg in errors:
41 m = re.search(exp, commit, re.MULTILINE)
42 m = re.search(exp, commit, re.MULTILINE)
42 if m:
43 if m:
@@ -44,6 +45,9 b' def checkcommit(commit):'
44 for n, l in enumerate(commit.splitlines(True)):
45 for n, l in enumerate(commit.splitlines(True)):
45 pos += len(l)
46 pos += len(l)
46 if pos >= m.end():
47 if pos >= m.end():
48 if not printed:
49 printed = True
50 print "node: %s" % node
47 print "%d: %s" % (n, msg)
51 print "%d: %s" % (n, msg)
48 print " %s" % l[:-1]
52 print " %s" % l[:-1]
49 if "BYPASS" not in os.environ:
53 if "BYPASS" not in os.environ:
@@ -55,12 +59,16 b' def readcommit(node):'
55 return os.popen("hg export %s" % node).read()
59 return os.popen("hg export %s" % node).read()
56
60
57 if __name__ == "__main__":
61 if __name__ == "__main__":
62 exitcode = 0
58 node = os.environ.get("HG_NODE")
63 node = os.environ.get("HG_NODE")
59
64
60 if node:
65 if node:
61 commit = readcommit(node)
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 else:
71 else:
63 commit = sys.stdin.read()
72 commit = sys.stdin.read()
64
73 exitcode = checkcommit(commit)
65 exitcode = checkcommit(commit)
66 sys.exit(exitcode)
74 sys.exit(exitcode)
General Comments 0
You need to be logged in to leave comments. Login now