diff options
Diffstat (limited to 'tools/patman/patman.py')
-rwxr-xr-x | tools/patman/patman.py | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/tools/patman/patman.py b/tools/patman/patman.py index cfe06d08236..e049081eae7 100755 --- a/tools/patman/patman.py +++ b/tools/patman/patman.py @@ -34,6 +34,8 @@ import checkpatch import command import gitutil import patchstream +import project +import settings import terminal import test @@ -48,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', @@ -56,6 +61,9 @@ 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") @@ -64,6 +72,11 @@ parser.usage = """patman [options] Create patches from commits in a branch, check them and email them as specified by tags you place in the commits. Use -n to """ + +# Parse options twice: first to get the project and second to handle +# defaults properly (which depends on project). +(options, args) = parser.parse_args() +settings.Setup(parser, options.project, '') (options, args) = parser.parse_args() # Run our meagre tests @@ -75,8 +88,9 @@ if options.test: result = unittest.TestResult() suite.run(result) - suite = doctest.DocTestSuite('gitutil') - suite.run(result) + for module in ['gitutil', 'settings']: + suite = doctest.DocTestSuite(module) + suite.run(result) # TODO: Surely we can just 'print' result? print result @@ -135,19 +149,24 @@ 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 + cc_file = series.MakeCcFile(options.process_tags, cover_fname) + # Email the patches out (giving the user time to check / cancel) cmd = '' if ok or options.ignore_errors: - cc_file = series.MakeCcFile(options.process_tags) cmd = gitutil.EmailPatches(series, cover_fname, args, options.dry_run, cc_file) - os.remove(cc_file) # For a dry run, just show our actions as a sanity check if options.dry_run: series.ShowActions(args, cmd, options.process_tags) + + os.remove(cc_file) |