Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
| 7 | 7 |
| 8 """A git-command for integrating reviews on Rietveld.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
| 9 | 9 |
| 10 import json | 10 import json |
| (...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1231 parser.add_option('--bypass-hooks', action='store_true', dest='bypass_hooks', | 1231 parser.add_option('--bypass-hooks', action='store_true', dest='bypass_hooks', |
| 1232 help='bypass upload presubmit hook') | 1232 help='bypass upload presubmit hook') |
| 1233 parser.add_option('-f', action='store_true', dest='force', | 1233 parser.add_option('-f', action='store_true', dest='force', |
| 1234 help="force yes to questions (don't prompt)") | 1234 help="force yes to questions (don't prompt)") |
| 1235 parser.add_option('-m', dest='message', help='message for patchset') | 1235 parser.add_option('-m', dest='message', help='message for patchset') |
| 1236 parser.add_option('-t', dest='title', help='title for patchset') | 1236 parser.add_option('-t', dest='title', help='title for patchset') |
| 1237 parser.add_option('-r', '--reviewers', | 1237 parser.add_option('-r', '--reviewers', |
| 1238 help='reviewer email addresses') | 1238 help='reviewer email addresses') |
| 1239 parser.add_option('--cc', | 1239 parser.add_option('--cc', |
| 1240 help='cc email addresses') | 1240 help='cc email addresses') |
| 1241 parser.add_option('--allow-dirty', action='store_true', | |
| 1242 help='Allow upload even when there are uncommited changes') | |
|
Sam Clegg
2013/01/10 19:48:29
I would have preferred to use --force here for thi
| |
| 1241 parser.add_option('--send-mail', action='store_true', | 1243 parser.add_option('--send-mail', action='store_true', |
| 1242 help='send email to reviewer immediately') | 1244 help='send email to reviewer immediately') |
| 1243 parser.add_option("--emulate_svn_auto_props", action="store_true", | 1245 parser.add_option("--emulate_svn_auto_props", action="store_true", |
| 1244 dest="emulate_svn_auto_props", | 1246 dest="emulate_svn_auto_props", |
| 1245 help="Emulate Subversion's auto properties feature.") | 1247 help="Emulate Subversion's auto properties feature.") |
| 1246 parser.add_option('-c', '--use-commit-queue', action='store_true', | 1248 parser.add_option('-c', '--use-commit-queue', action='store_true', |
| 1247 help='tell the commit queue to commit this patchset') | 1249 help='tell the commit queue to commit this patchset') |
| 1248 parser.add_option('--target_branch', | 1250 parser.add_option('--target_branch', |
| 1249 help='When uploading to gerrit, remote branch to ' | 1251 help='When uploading to gerrit, remote branch to ' |
| 1250 'use for CL. Default: master') | 1252 'use for CL. Default: master') |
| 1251 add_git_similarity(parser) | 1253 add_git_similarity(parser) |
| 1252 (options, args) = parser.parse_args(args) | 1254 (options, args) = parser.parse_args(args) |
| 1253 | 1255 |
| 1254 if options.target_branch and not settings.GetIsGerrit(): | 1256 if options.target_branch and not settings.GetIsGerrit(): |
| 1255 parser.error('Use --target_branch for non gerrit repository.') | 1257 parser.error('Use --target_branch for non gerrit repository.') |
| 1256 | 1258 |
| 1257 # Print warning if the user used the -m/--message argument. This will soon | 1259 # Print warning if the user used the -m/--message argument. This will soon |
| 1258 # change to -t/--title. | 1260 # change to -t/--title. |
| 1259 if options.message: | 1261 if options.message: |
| 1260 print >> sys.stderr, ( | 1262 print >> sys.stderr, ( |
| 1261 '\nWARNING: Use -t or --title to set the title of the patchset.\n' | 1263 '\nWARNING: Use -t or --title to set the title of the patchset.\n' |
| 1262 'In the near future, -m or --message will send a message instead.\n' | 1264 'In the near future, -m or --message will send a message instead.\n' |
| 1263 'See http://goo.gl/JGg0Z for details.\n') | 1265 'See http://goo.gl/JGg0Z for details.\n') |
| 1264 | 1266 |
| 1265 if is_dirty_git_tree('upload'): | 1267 if not options.allow_dirty and is_dirty_git_tree('upload'): |
| 1266 return 1 | 1268 return 1 |
| 1267 | 1269 |
| 1268 cl = Changelist() | 1270 cl = Changelist() |
| 1269 if args: | 1271 if args: |
| 1270 # TODO(ukai): is it ok for gerrit case? | 1272 # TODO(ukai): is it ok for gerrit case? |
| 1271 base_branch = args[0] | 1273 base_branch = args[0] |
| 1272 else: | 1274 else: |
| 1273 # Default to diffing against common ancestor of upstream branch | 1275 # Default to diffing against common ancestor of upstream branch |
| 1274 base_branch = RunGit(['merge-base', cl.GetUpstreamBranch(), 'HEAD']).strip() | 1276 base_branch = RunGit(['merge-base', cl.GetUpstreamBranch(), 'HEAD']).strip() |
| 1275 args = [base_branch] | 1277 args = [base_branch] |
| 1278 if options.allow_dirty: | |
| 1279 args.append('HEAD') | |
|
Sam Clegg
2013/01/10 19:48:29
We most likely should just add 'HEAD' in all cases
| |
| 1276 | 1280 |
| 1277 if not options.bypass_hooks: | 1281 if not options.bypass_hooks: |
| 1278 hook_results = cl.RunHook(committing=False, upstream_branch=base_branch, | 1282 hook_results = cl.RunHook(committing=False, upstream_branch=base_branch, |
| 1279 may_prompt=not options.force, | 1283 may_prompt=not options.force, |
| 1280 verbose=options.verbose, | 1284 verbose=options.verbose, |
| 1281 author=None) | 1285 author=None) |
| 1282 if not hook_results.should_continue(): | 1286 if not hook_results.should_continue(): |
| 1283 return 1 | 1287 return 1 |
| 1284 if not options.reviewers and hook_results.reviewers: | 1288 if not options.reviewers and hook_results.reviewers: |
| 1285 options.reviewers = hook_results.reviewers | 1289 options.reviewers = hook_results.reviewers |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1866 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1870 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 1867 | 1871 |
| 1868 # Not a known command. Default to help. | 1872 # Not a known command. Default to help. |
| 1869 GenUsage(parser, 'help') | 1873 GenUsage(parser, 'help') |
| 1870 return CMDhelp(parser, argv) | 1874 return CMDhelp(parser, argv) |
| 1871 | 1875 |
| 1872 | 1876 |
| 1873 if __name__ == '__main__': | 1877 if __name__ == '__main__': |
| 1874 fix_encoding.fix_encoding() | 1878 fix_encoding.fix_encoding() |
| 1875 sys.exit(main(sys.argv[1:])) | 1879 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |