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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 return self.tree_status_url | 360 return self.tree_status_url |
361 | 361 |
362 def GetViewVCUrl(self): | 362 def GetViewVCUrl(self): |
363 if not self.viewvc_url: | 363 if not self.viewvc_url: |
364 self.viewvc_url = self._GetConfig('rietveld.viewvc-url', error_ok=True) | 364 self.viewvc_url = self._GetConfig('rietveld.viewvc-url', error_ok=True) |
365 return self.viewvc_url | 365 return self.viewvc_url |
366 | 366 |
367 def GetDefaultCCList(self): | 367 def GetDefaultCCList(self): |
368 return self._GetConfig('rietveld.cc', error_ok=True) | 368 return self._GetConfig('rietveld.cc', error_ok=True) |
369 | 369 |
| 370 def GetDefaultPrivateFlag(self): |
| 371 return self._GetConfig('rietveld.private', error_ok=True) |
| 372 |
370 def GetIsGerrit(self): | 373 def GetIsGerrit(self): |
371 """Return true if this repo is assosiated with gerrit code review system.""" | 374 """Return true if this repo is assosiated with gerrit code review system.""" |
372 if self.is_gerrit is None: | 375 if self.is_gerrit is None: |
373 self.is_gerrit = self._GetConfig('gerrit.host', error_ok=True) | 376 self.is_gerrit = self._GetConfig('gerrit.host', error_ok=True) |
374 return self.is_gerrit | 377 return self.is_gerrit |
375 | 378 |
376 def GetGitEditor(self): | 379 def GetGitEditor(self): |
377 """Return the editor specified in the git config, or None if none is.""" | 380 """Return the editor specified in the git config, or None if none is.""" |
378 if self.git_editor is None: | 381 if self.git_editor is None: |
379 self.git_editor = self._GetConfig('core.editor', error_ok=True) | 382 self.git_editor = self._GetConfig('core.editor', error_ok=True) |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 new_val = ask_for_data(prompt + ':') | 803 new_val = ask_for_data(prompt + ':') |
801 if new_val == 'x': | 804 if new_val == 'x': |
802 RunGit(['config', '--unset-all', 'rietveld.' + name], error_ok=True) | 805 RunGit(['config', '--unset-all', 'rietveld.' + name], error_ok=True) |
803 elif new_val: | 806 elif new_val: |
804 if is_url: | 807 if is_url: |
805 new_val = gclient_utils.UpgradeToHttps(new_val) | 808 new_val = gclient_utils.UpgradeToHttps(new_val) |
806 if new_val != initial: | 809 if new_val != initial: |
807 RunGit(['config', 'rietveld.' + name, new_val]) | 810 RunGit(['config', 'rietveld.' + name, new_val]) |
808 | 811 |
809 SetProperty(settings.GetDefaultCCList(), 'CC list', 'cc', False) | 812 SetProperty(settings.GetDefaultCCList(), 'CC list', 'cc', False) |
| 813 SetProperty(settings.GetDefaultPrivateFlag(), |
| 814 'Private flag (rietveld only)', 'private', False) |
810 SetProperty(settings.GetTreeStatusUrl(error_ok=True), 'Tree status URL', | 815 SetProperty(settings.GetTreeStatusUrl(error_ok=True), 'Tree status URL', |
811 'tree-status-url', False) | 816 'tree-status-url', False) |
812 SetProperty(settings.GetViewVCUrl(), 'ViewVC URL', 'viewvc-url', True) | 817 SetProperty(settings.GetViewVCUrl(), 'ViewVC URL', 'viewvc-url', True) |
813 | 818 |
814 # TODO: configure a default branch to diff against, rather than this | 819 # TODO: configure a default branch to diff against, rather than this |
815 # svn-based hackery. | 820 # svn-based hackery. |
816 | 821 |
817 | 822 |
818 class ChangeDescription(object): | 823 class ChangeDescription(object): |
819 """Contains a parsed form of the change description.""" | 824 """Contains a parsed form of the change description.""" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 fullname = 'rietveld.' + name | 942 fullname = 'rietveld.' + name |
938 if setting in keyvals: | 943 if setting in keyvals: |
939 RunGit(['config', fullname, keyvals[setting]]) | 944 RunGit(['config', fullname, keyvals[setting]]) |
940 else: | 945 else: |
941 RunGit(['config', '--unset-all', fullname], error_ok=unset_error_ok) | 946 RunGit(['config', '--unset-all', fullname], error_ok=unset_error_ok) |
942 | 947 |
943 SetProperty('server', 'CODE_REVIEW_SERVER') | 948 SetProperty('server', 'CODE_REVIEW_SERVER') |
944 # Only server setting is required. Other settings can be absent. | 949 # Only server setting is required. Other settings can be absent. |
945 # In that case, we ignore errors raised during option deletion attempt. | 950 # In that case, we ignore errors raised during option deletion attempt. |
946 SetProperty('cc', 'CC_LIST', unset_error_ok=True) | 951 SetProperty('cc', 'CC_LIST', unset_error_ok=True) |
| 952 SetProperty('private', 'PRIVATE', unset_error_ok=True) |
947 SetProperty('tree-status-url', 'STATUS', unset_error_ok=True) | 953 SetProperty('tree-status-url', 'STATUS', unset_error_ok=True) |
948 SetProperty('viewvc-url', 'VIEW_VC', unset_error_ok=True) | 954 SetProperty('viewvc-url', 'VIEW_VC', unset_error_ok=True) |
949 | 955 |
950 if 'GERRIT_HOST' in keyvals and 'GERRIT_PORT' in keyvals: | 956 if 'GERRIT_HOST' in keyvals and 'GERRIT_PORT' in keyvals: |
951 RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) | 957 RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) |
952 RunGit(['config', 'gerrit.port', keyvals['GERRIT_PORT']]) | 958 RunGit(['config', 'gerrit.port', keyvals['GERRIT_PORT']]) |
953 | 959 |
954 if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals: | 960 if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals: |
955 #should be of the form | 961 #should be of the form |
956 #PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof | 962 #PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1264 if change_desc.get_reviewers(): | 1270 if change_desc.get_reviewers(): |
1265 upload_args.append('--reviewers=' + ','.join(change_desc.get_reviewers())) | 1271 upload_args.append('--reviewers=' + ','.join(change_desc.get_reviewers())) |
1266 if options.send_mail: | 1272 if options.send_mail: |
1267 if not change_desc.get_reviewers(): | 1273 if not change_desc.get_reviewers(): |
1268 DieWithError("Must specify reviewers to send email.") | 1274 DieWithError("Must specify reviewers to send email.") |
1269 upload_args.append('--send_mail') | 1275 upload_args.append('--send_mail') |
1270 cc = ','.join(filter(None, (cl.GetCCList(), ','.join(options.cc)))) | 1276 cc = ','.join(filter(None, (cl.GetCCList(), ','.join(options.cc)))) |
1271 if cc: | 1277 if cc: |
1272 upload_args.extend(['--cc', cc]) | 1278 upload_args.extend(['--cc', cc]) |
1273 | 1279 |
| 1280 if options.private or settings.GetDefaultPrivateFlag() == "True": |
| 1281 upload_args.append('--private') |
| 1282 |
1274 upload_args.extend(['--git_similarity', str(options.similarity)]) | 1283 upload_args.extend(['--git_similarity', str(options.similarity)]) |
1275 if not options.find_copies: | 1284 if not options.find_copies: |
1276 upload_args.extend(['--git_no_find_copies']) | 1285 upload_args.extend(['--git_no_find_copies']) |
1277 | 1286 |
1278 # Include the upstream repo's URL in the change -- this is useful for | 1287 # Include the upstream repo's URL in the change -- this is useful for |
1279 # projects that have their source spread across multiple repos. | 1288 # projects that have their source spread across multiple repos. |
1280 remote_url = cl.GetGitBaseUrlFromConfig() | 1289 remote_url = cl.GetGitBaseUrlFromConfig() |
1281 if not remote_url: | 1290 if not remote_url: |
1282 if settings.GetIsGitSvn(): | 1291 if settings.GetIsGitSvn(): |
1283 # URL is dependent on the current directory. | 1292 # URL is dependent on the current directory. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 parser.add_option('--cc', | 1355 parser.add_option('--cc', |
1347 action='append', default=[], | 1356 action='append', default=[], |
1348 help='cc email addresses') | 1357 help='cc email addresses') |
1349 parser.add_option('-s', '--send-mail', action='store_true', | 1358 parser.add_option('-s', '--send-mail', action='store_true', |
1350 help='send email to reviewer immediately') | 1359 help='send email to reviewer immediately') |
1351 parser.add_option("--emulate_svn_auto_props", action="store_true", | 1360 parser.add_option("--emulate_svn_auto_props", action="store_true", |
1352 dest="emulate_svn_auto_props", | 1361 dest="emulate_svn_auto_props", |
1353 help="Emulate Subversion's auto properties feature.") | 1362 help="Emulate Subversion's auto properties feature.") |
1354 parser.add_option('-c', '--use-commit-queue', action='store_true', | 1363 parser.add_option('-c', '--use-commit-queue', action='store_true', |
1355 help='tell the commit queue to commit this patchset') | 1364 help='tell the commit queue to commit this patchset') |
| 1365 parser.add_option('--private', action='store_true', |
| 1366 help='set the review private (rietveld only)') |
1356 parser.add_option('--target_branch', | 1367 parser.add_option('--target_branch', |
1357 help='When uploading to gerrit, remote branch to ' | 1368 help='When uploading to gerrit, remote branch to ' |
1358 'use for CL. Default: master') | 1369 'use for CL. Default: master') |
1359 add_git_similarity(parser) | 1370 add_git_similarity(parser) |
1360 (options, args) = parser.parse_args(args) | 1371 (options, args) = parser.parse_args(args) |
1361 | 1372 |
1362 if options.target_branch and not settings.GetIsGerrit(): | 1373 if options.target_branch and not settings.GetIsGerrit(): |
1363 parser.error('Use --target_branch for non gerrit repository.') | 1374 parser.error('Use --target_branch for non gerrit repository.') |
1364 | 1375 |
1365 # Print warning if the user used the -m/--message argument. This will soon | 1376 # Print warning if the user used the -m/--message argument. This will soon |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2091 GenUsage(parser, 'help') | 2102 GenUsage(parser, 'help') |
2092 return CMDhelp(parser, argv) | 2103 return CMDhelp(parser, argv) |
2093 | 2104 |
2094 | 2105 |
2095 if __name__ == '__main__': | 2106 if __name__ == '__main__': |
2096 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2107 # These affect sys.stdout so do it outside of main() to simplify mocks in |
2097 # unit testing. | 2108 # unit testing. |
2098 fix_encoding.fix_encoding() | 2109 fix_encoding.fix_encoding() |
2099 colorama.init() | 2110 colorama.init() |
2100 sys.exit(main(sys.argv[1:])) | 2111 sys.exit(main(sys.argv[1:])) |
OLD | NEW |