Patchwork [3,of,4] check-commit: support nodes as arguments

login
register
mail settings
Submitter timeless@mozdev.org
Date Jan. 7, 2016, 10:13 p.m.
Message ID <666391b22d67439f2dee.1452204799@waste.org>
Download mbox | patch
Permalink /patch/12593/
State Rejected
Headers show

Comments

timeless@mozdev.org - Jan. 7, 2016, 10:13 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1452130139 0
#      Thu Jan 07 01:28:59 2016 +0000
# Node ID 666391b22d67439f2dee4761fa42775fc3c4e2ef
# Parent  409a03fdf519243fe530f52a68f7804977dcd0e9
check-commit: support nodes as arguments
Pierre-Yves David - Jan. 8, 2016, 12:58 p.m.
On 01/07/2016 10:13 PM, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1452130139 0
> #      Thu Jan 07 01:28:59 2016 +0000
> # Node ID 666391b22d67439f2dee4761fa42775fc3c4e2ef
> # Parent  409a03fdf519243fe530f52a68f7804977dcd0e9
> check-commit: support nodes as arguments

What is this node argument supposed to mean?
timeless - Jan. 8, 2016, 4:54 p.m.
Pierre-Yves David wrote:
> What is this node argument supposed to mean?

The same as HG_NODE which the script used previously. Anything that
resolves to a node works (e.g. I've used bookmarks, {rev}, {node}, `.`
should work...
Pierre-Yves David - Jan. 8, 2016, 5:33 p.m.
On 01/08/2016 04:54 PM, timeless wrote:
> Pierre-Yves David wrote:
>> What is this node argument supposed to mean?
>
> The same as HG_NODE which the script used previously. Anything that
> resolves to a node works (e.g. I've used bookmarks, {rev}, {node}, `.`
> should work...

Can you update your patch description and script documentation?

Patch

diff --git a/contrib/check-commit b/contrib/check-commit
--- a/contrib/check-commit
+++ b/contrib/check-commit
@@ -33,8 +33,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:
@@ -42,6 +43,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:
@@ -53,12 +57,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)