[PATCH] check-commit: allow underbars in cffi_-prefix function names

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Aug 5 20:20:04 EDT 2016



On 08/06/2016 01:58 AM, Augie Fackler wrote:
>
>> On Aug 5, 2016, at 7:40 PM, Pierre-Yves David <pierre-yves.david at ens-lyon.org> wrote:
>>
>>
>>
>> On 08/05/2016 11:28 PM, Augie Fackler wrote:
>>> # HG changeset patch
>>> # User Augie Fackler <augie at google.com>
>>> # Date 1470432471 14400
>>> #      Fri Aug 05 17:27:51 2016 -0400
>>> # Node ID 91bc284fa60d068f88b988b149a05c0d14aee0b5
>>> # Parent  834b8ac4a7587562dccb527b28606ecf5532e883
>>> check-commit: allow underbars in cffi_-prefix function names
>>>
>>> It seems reasonable to give cffi functions slightly more verbose names
>>> in some circumstances, given the way they interface with C.
>>
>> That seems reasonable because, cffi maps C function with "_" in their name
>>
>>>
>>> diff --git a/contrib/check-commit b/contrib/check-commit
>>> --- a/contrib/check-commit
>>> +++ b/contrib/check-commit
>>> @@ -41,7 +41,8 @@ errors = [
>>>     (afterheader + r".{79,}", "summary line too long (limit is 78)"),
>>>     (r"\n\+\n( |\+)\n", "adds double empty line"),
>>>     (r"\n \n\+\n", "adds double empty line"),
>>> -    (r"\n\+[ \t]+def [a-z]+_[a-z]", "adds a function with foo_bar naming"),
>>> +    (r"\n\+[ \t]+def (?!cffi)[a-z]+_[a-z]",
>>> +     "adds a function with foo_bar naming"),
>>> ]
>>
>> Can we have an inline comment about this cffi thing, this code is already quite scary to new comer.
>
> Can you just add that in flight?

Yep, pushed with

diff -r 4de25e275c00 contrib/check-commit
--- a/contrib/check-commit	Fri Aug 05 17:27:51 2016 -0400
+++ b/contrib/check-commit	Sat Aug 06 02:16:06 2016 +0200
@@ -41,6 +41,10 @@ errors = [
      (afterheader + r".{79,}", "summary line too long (limit is 78)"),
      (r"\n\+\n( |\+)\n", "adds double empty line"),
      (r"\n \n\+\n", "adds double empty line"),
+    # Forbid "_" in function name.
+    #
+    # We skip the check for cffi related functions. They use names 
mapping the
+    # name of the C function. C function names may contain "_".
      (r"\n\+[ \t]+def (?!cffi)[a-z]+_[a-z]",
       "adds a function with foo_bar naming"),
  ]

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list