diff mbox

[U-Boot,v4] patman: Allow use outside of u-boot tree

Message ID 1357783210-2108-1-git-send-email-vbendeb@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Vadim Bendebury Jan. 10, 2013, 2 a.m. UTC
To make it usable in git trees not providing a patch checker
implementation, add a command line option, allowing to suppress patch
check. While we are at it, sort debug options alphabetically.

Also, do not raise an exception if checkpatch.pl is not found - just
print an error message suggesting to use the new option, and return
nonzero status.

   . unit test passes:
    $ ./patman  -t
    <unittest.result.TestResult run=7 errors=0 failures=0>
   . successfully used patman in the autotest tree to generate a patch
     email (with --no-check option)
   . successfully used patman in the u-boot tree to generate a patch
     email
   . `patman --help' now shows command line options ordered
     alphabetically

Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
---
Changes in v4:
  . now properly corrected typo in the error message

Changes in v3:
  . corrected typo in the error message

Changes in v2:
  . addressed comments WRT use of double negative
  . added code to gracefully handle absence of checkpatch.cl

 tools/patman/checkpatch.py |   10 +++++-----
 tools/patman/patman.py     |   14 ++++++++++----
 2 files changed, 15 insertions(+), 9 deletions(-)

Comments

Doug Anderson Jan. 10, 2013, 5:33 a.m. UTC | #1
On Wed, Jan 9, 2013 at 6:00 PM, Vadim Bendebury <vbendeb@chromium.org> wrote:
> To make it usable in git trees not providing a patch checker
> implementation, add a command line option, allowing to suppress patch
> check. While we are at it, sort debug options alphabetically.
>
> Also, do not raise an exception if checkpatch.pl is not found - just
> print an error message suggesting to use the new option, and return
> nonzero status.
>
>    . unit test passes:
>     $ ./patman  -t
>     <unittest.result.TestResult run=7 errors=0 failures=0>
>    . successfully used patman in the autotest tree to generate a patch
>      email (with --no-check option)
>    . successfully used patman in the u-boot tree to generate a patch
>      email
>    . `patman --help' now shows command line options ordered
>      alphabetically
>
> Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>

Acked-by: Doug Anderson <dianders@chromium.org>
Simon Glass Jan. 10, 2013, 5:05 p.m. UTC | #2
Hi Vadim,

On Wed, Jan 9, 2013 at 6:00 PM, Vadim Bendebury <vbendeb@chromium.org> wrote:
> To make it usable in git trees not providing a patch checker
> implementation, add a command line option, allowing to suppress patch
> check. While we are at it, sort debug options alphabetically.
>
> Also, do not raise an exception if checkpatch.pl is not found - just
> print an error message suggesting to use the new option, and return
> nonzero status.
>
>    . unit test passes:
>     $ ./patman  -t
>     <unittest.result.TestResult run=7 errors=0 failures=0>
>    . successfully used patman in the autotest tree to generate a patch
>      email (with --no-check option)
>    . successfully used patman in the u-boot tree to generate a patch
>      email
>    . `patman --help' now shows command line options ordered
>      alphabetically
>
> Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>

Acked-by: Simon Glass <sjg@chromium.org>

BTW what is this patch against - it doesn't seem to apply to mainline for me.

> ---
> Changes in v4:
>   . now properly corrected typo in the error message
>
> Changes in v3:
>   . corrected typo in the error message
>
> Changes in v2:
>   . addressed comments WRT use of double negative
>   . added code to gracefully handle absence of checkpatch.cl
>
>  tools/patman/checkpatch.py |   10 +++++-----
>  tools/patman/patman.py     |   14 ++++++++++----
>  2 files changed, 15 insertions(+), 9 deletions(-)
[snip]

Regards,
Simon
Vadim Bendebury Jan. 10, 2013, 5:29 p.m. UTC | #3
On Thu, Jan 10, 2013 at 9:05 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Vadim,
>
> On Wed, Jan 9, 2013 at 6:00 PM, Vadim Bendebury <vbendeb@chromium.org> wrote:
>> To make it usable in git trees not providing a patch checker
>> implementation, add a command line option, allowing to suppress patch
>> check. While we are at it, sort debug options alphabetically.
>>
>> Also, do not raise an exception if checkpatch.pl is not found - just
>> print an error message suggesting to use the new option, and return
>> nonzero status.
>>
>>    . unit test passes:
>>     $ ./patman  -t
>>     <unittest.result.TestResult run=7 errors=0 failures=0>
>>    . successfully used patman in the autotest tree to generate a patch
>>      email (with --no-check option)
>>    . successfully used patman in the u-boot tree to generate a patch
>>      email
>>    . `patman --help' now shows command line options ordered
>>      alphabetically
>>
>> Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
>
> Acked-by: Simon Glass <sjg@chromium.org>
>
> BTW what is this patch against - it doesn't seem to apply to mainline for me.
>

Right, it depends on the previous patches which still have not been
applied to the upstream ToT.

cheers,
/vb

>> ---
>> Changes in v4:
>>   . now properly corrected typo in the error message
>>
>> Changes in v3:
>>   . corrected typo in the error message
>>
>> Changes in v2:
>>   . addressed comments WRT use of double negative
>>   . added code to gracefully handle absence of checkpatch.cl
>>
>>  tools/patman/checkpatch.py |   10 +++++-----
>>  tools/patman/patman.py     |   14 ++++++++++----
>>  2 files changed, 15 insertions(+), 9 deletions(-)
> [snip]
>
> Regards,
> Simon
Simon Glass Jan. 31, 2013, 11:46 p.m. UTC | #4
On Fri, Jan 11, 2013 at 6:29 AM, Vadim Bendebury <vbendeb@chromium.org> wrote:
> On Thu, Jan 10, 2013 at 9:05 AM, Simon Glass <sjg@chromium.org> wrote:
>> Hi Vadim,
>>
>> On Wed, Jan 9, 2013 at 6:00 PM, Vadim Bendebury <vbendeb@chromium.org> wrote:
>>> To make it usable in git trees not providing a patch checker
>>> implementation, add a command line option, allowing to suppress patch
>>> check. While we are at it, sort debug options alphabetically.
>>>
>>> Also, do not raise an exception if checkpatch.pl is not found - just
>>> print an error message suggesting to use the new option, and return
>>> nonzero status.
>>>
>>>    . unit test passes:
>>>     $ ./patman  -t
>>>     <unittest.result.TestResult run=7 errors=0 failures=0>
>>>    . successfully used patman in the autotest tree to generate a patch
>>>      email (with --no-check option)
>>>    . successfully used patman in the u-boot tree to generate a patch
>>>      email
>>>    . `patman --help' now shows command line options ordered
>>>      alphabetically
>>>
>>> Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
>>
>> Acked-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-x86, thanks.

>>
>> BTW what is this patch against - it doesn't seem to apply to mainline for me.
>>
>
> Right, it depends on the previous patches which still have not been
> applied to the upstream ToT.
>
> cheers,
> /vb
>
>>> ---
>>> Changes in v4:
>>>   . now properly corrected typo in the error message
>>>
>>> Changes in v3:
>>>   . corrected typo in the error message
>>>
>>> Changes in v2:
>>>   . addressed comments WRT use of double negative
>>>   . added code to gracefully handle absence of checkpatch.cl
>>>
>>>  tools/patman/checkpatch.py |   10 +++++-----
>>>  tools/patman/patman.py     |   14 ++++++++++----
>>>  2 files changed, 15 insertions(+), 9 deletions(-)
>> [snip]
>>
>> Regards,
>> Simon
diff mbox

Patch

diff --git a/tools/patman/checkpatch.py b/tools/patman/checkpatch.py
index f72f8ee..d3a0477 100644
--- a/tools/patman/checkpatch.py
+++ b/tools/patman/checkpatch.py
@@ -23,6 +23,7 @@  import command
 import gitutil
 import os
 import re
+import sys
 import terminal
 
 def FindCheckPatch():
@@ -47,8 +48,10 @@  def FindCheckPatch():
         if os.path.isfile(fname):
             return fname
         path = os.path.dirname(path)
-    print 'Could not find checkpatch.pl'
-    return None
+
+    print >> sys.stderr, ('Cannot find checkpatch.pl - please put it in your ' +
+                '~/bin directory or use --no-check')
+    sys.exit(1)
 
 def CheckPatch(fname, verbose=False):
     """Run checkpatch.pl on a file.
@@ -67,9 +70,6 @@  def CheckPatch(fname, verbose=False):
     error_count, warning_count, lines = 0, 0, 0
     problems = []
     chk = FindCheckPatch()
-    if not chk:
-        raise OSError, ('Cannot find checkpatch.pl - please put it in your ' +
-                '~/bin directory')
     item = {}
     stdout = command.Output(chk, '--no-tree', fname)
     #pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE)
diff --git a/tools/patman/patman.py b/tools/patman/patman.py
index e56dd01..e049081 100755
--- a/tools/patman/patman.py
+++ b/tools/patman/patman.py
@@ -50,6 +50,9 @@  parser.add_option('-i', '--ignore-errors', action='store_true',
        help='Send patches email even if patch errors are found')
 parser.add_option('-n', '--dry-run', action='store_true', dest='dry_run',
        default=False, help="Do a try run (create but don't email patches)")
+parser.add_option('-p', '--project', default=project.DetectProject(),
+                  help="Project name; affects default option values and "
+                  "aliases [default: %default]")
 parser.add_option('-s', '--start', dest='start', type='int',
        default=0, help='Commit to start creating patches from (0 = HEAD)')
 parser.add_option('-t', '--test', action='store_true', dest='test',
@@ -58,11 +61,11 @@  parser.add_option('-v', '--verbose', action='store_true', dest='verbose',
        default=False, help='Verbose output of errors and warnings')
 parser.add_option('--cc-cmd', dest='cc_cmd', type='string', action='store',
        default=None, help='Output cc list for patch file (used by git)')
+parser.add_option('--no-check', action='store_false', dest='check_patch',
+                  default=True,
+                  help="Don't check for patch compliance")
 parser.add_option('--no-tags', action='store_false', dest='process_tags',
                   default=True, help="Don't process subject tags as aliaes")
-parser.add_option('-p', '--project', default=project.DetectProject(),
-                  help="Project name; affects default option values and "
-                  "aliases [default: %default]")
 
 parser.usage = """patman [options]
 
@@ -146,7 +149,10 @@  else:
     series.DoChecks()
 
     # Check the patches, and run them through 'git am' just to be sure
-    ok = checkpatch.CheckPatches(options.verbose, args)
+    if options.check_patch:
+        ok = checkpatch.CheckPatches(options.verbose, args)
+    else:
+        ok = True
     if not gitutil.ApplyPatches(options.verbose, args,
             options.count + options.start):
         ok = False