| 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 datetime | 10 import datetime |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 self.default_server = None | 274 self.default_server = None |
| 275 self.cc = None | 275 self.cc = None |
| 276 self.root = None | 276 self.root = None |
| 277 self.is_git_svn = None | 277 self.is_git_svn = None |
| 278 self.svn_branch = None | 278 self.svn_branch = None |
| 279 self.tree_status_url = None | 279 self.tree_status_url = None |
| 280 self.viewvc_url = None | 280 self.viewvc_url = None |
| 281 self.updated = False | 281 self.updated = False |
| 282 self.is_gerrit = None | 282 self.is_gerrit = None |
| 283 self.git_editor = None | 283 self.git_editor = None |
| 284 self.project = None |
| 284 | 285 |
| 285 def LazyUpdateIfNeeded(self): | 286 def LazyUpdateIfNeeded(self): |
| 286 """Updates the settings from a codereview.settings file, if available.""" | 287 """Updates the settings from a codereview.settings file, if available.""" |
| 287 if not self.updated: | 288 if not self.updated: |
| 288 # The only value that actually changes the behavior is | 289 # The only value that actually changes the behavior is |
| 289 # autoupdate = "false". Everything else means "true". | 290 # autoupdate = "false". Everything else means "true". |
| 290 autoupdate = RunGit(['config', 'rietveld.autoupdate'], | 291 autoupdate = RunGit(['config', 'rietveld.autoupdate'], |
| 291 error_ok=True | 292 error_ok=True |
| 292 ).strip().lower() | 293 ).strip().lower() |
| 293 | 294 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 return self.git_editor or None | 436 return self.git_editor or None |
| 436 | 437 |
| 437 def GetLintRegex(self): | 438 def GetLintRegex(self): |
| 438 return (self._GetRietveldConfig('cpplint-regex', error_ok=True) or | 439 return (self._GetRietveldConfig('cpplint-regex', error_ok=True) or |
| 439 DEFAULT_LINT_REGEX) | 440 DEFAULT_LINT_REGEX) |
| 440 | 441 |
| 441 def GetLintIgnoreRegex(self): | 442 def GetLintIgnoreRegex(self): |
| 442 return (self._GetRietveldConfig('cpplint-ignore-regex', error_ok=True) or | 443 return (self._GetRietveldConfig('cpplint-ignore-regex', error_ok=True) or |
| 443 DEFAULT_LINT_IGNORE_REGEX) | 444 DEFAULT_LINT_IGNORE_REGEX) |
| 444 | 445 |
| 446 def GetProject(self): |
| 447 if not self.project: |
| 448 self.project = self._GetRietveldConfig('project', error_ok=True) |
| 449 return self.project |
| 450 |
| 445 def _GetRietveldConfig(self, param, **kwargs): | 451 def _GetRietveldConfig(self, param, **kwargs): |
| 446 return self._GetConfig('rietveld.' + param, **kwargs) | 452 return self._GetConfig('rietveld.' + param, **kwargs) |
| 447 | 453 |
| 448 def _GetConfig(self, param, **kwargs): | 454 def _GetConfig(self, param, **kwargs): |
| 449 self.LazyUpdateIfNeeded() | 455 self.LazyUpdateIfNeeded() |
| 450 return RunGit(['config', param], **kwargs).strip() | 456 return RunGit(['config', param], **kwargs).strip() |
| 451 | 457 |
| 452 | 458 |
| 453 def ShortBranchName(branch): | 459 def ShortBranchName(branch): |
| 454 """Convert a name like 'refs/heads/foo' to just 'foo'.""" | 460 """Convert a name like 'refs/heads/foo' to just 'foo'.""" |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 SetProperty('server', 'CODE_REVIEW_SERVER') | 1066 SetProperty('server', 'CODE_REVIEW_SERVER') |
| 1061 # Only server setting is required. Other settings can be absent. | 1067 # Only server setting is required. Other settings can be absent. |
| 1062 # In that case, we ignore errors raised during option deletion attempt. | 1068 # In that case, we ignore errors raised during option deletion attempt. |
| 1063 SetProperty('cc', 'CC_LIST', unset_error_ok=True) | 1069 SetProperty('cc', 'CC_LIST', unset_error_ok=True) |
| 1064 SetProperty('private', 'PRIVATE', unset_error_ok=True) | 1070 SetProperty('private', 'PRIVATE', unset_error_ok=True) |
| 1065 SetProperty('tree-status-url', 'STATUS', unset_error_ok=True) | 1071 SetProperty('tree-status-url', 'STATUS', unset_error_ok=True) |
| 1066 SetProperty('viewvc-url', 'VIEW_VC', unset_error_ok=True) | 1072 SetProperty('viewvc-url', 'VIEW_VC', unset_error_ok=True) |
| 1067 SetProperty('bug-prefix', 'BUG_PREFIX', unset_error_ok=True) | 1073 SetProperty('bug-prefix', 'BUG_PREFIX', unset_error_ok=True) |
| 1068 SetProperty('cpplint-regex', 'LINT_REGEX', unset_error_ok=True) | 1074 SetProperty('cpplint-regex', 'LINT_REGEX', unset_error_ok=True) |
| 1069 SetProperty('cpplint-ignore-regex', 'LINT_IGNORE_REGEX', unset_error_ok=True) | 1075 SetProperty('cpplint-ignore-regex', 'LINT_IGNORE_REGEX', unset_error_ok=True) |
| 1076 SetProperty('project', 'PROJECT', unset_error_ok=True) |
| 1070 | 1077 |
| 1071 if 'GERRIT_HOST' in keyvals: | 1078 if 'GERRIT_HOST' in keyvals: |
| 1072 RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) | 1079 RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) |
| 1073 | 1080 |
| 1074 if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals: | 1081 if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals: |
| 1075 #should be of the form | 1082 #should be of the form |
| 1076 #PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof | 1083 #PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof |
| 1077 #ORIGIN_URL_CONFIG: http://src.chromium.org/git | 1084 #ORIGIN_URL_CONFIG: http://src.chromium.org/git |
| 1078 RunGit(['config', keyvals['PUSH_URL_CONFIG'], | 1085 RunGit(['config', keyvals['PUSH_URL_CONFIG'], |
| 1079 keyvals['ORIGIN_URL_CONFIG']]) | 1086 keyvals['ORIGIN_URL_CONFIG']]) |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 keys = dict(line.split(': ', 1) for line in data.splitlines() | 1619 keys = dict(line.split(': ', 1) for line in data.splitlines() |
| 1613 if ': ' in line) | 1620 if ': ' in line) |
| 1614 remote_url = keys.get('URL', None) | 1621 remote_url = keys.get('URL', None) |
| 1615 else: | 1622 else: |
| 1616 if cl.GetRemoteUrl() and '/' in cl.GetUpstreamBranch(): | 1623 if cl.GetRemoteUrl() and '/' in cl.GetUpstreamBranch(): |
| 1617 remote_url = (cl.GetRemoteUrl() + '@' | 1624 remote_url = (cl.GetRemoteUrl() + '@' |
| 1618 + cl.GetUpstreamBranch().split('/')[-1]) | 1625 + cl.GetUpstreamBranch().split('/')[-1]) |
| 1619 if remote_url: | 1626 if remote_url: |
| 1620 upload_args.extend(['--base_url', remote_url]) | 1627 upload_args.extend(['--base_url', remote_url]) |
| 1621 | 1628 |
| 1629 project = settings.GetProject() |
| 1630 if project: |
| 1631 upload_args.extend(['--project', project]) |
| 1632 |
| 1622 try: | 1633 try: |
| 1623 upload_args = ['upload'] + upload_args + args | 1634 upload_args = ['upload'] + upload_args + args |
| 1624 logging.info('upload.RealMain(%s)', upload_args) | 1635 logging.info('upload.RealMain(%s)', upload_args) |
| 1625 issue, patchset = upload.RealMain(upload_args) | 1636 issue, patchset = upload.RealMain(upload_args) |
| 1626 issue = int(issue) | 1637 issue = int(issue) |
| 1627 patchset = int(patchset) | 1638 patchset = int(patchset) |
| 1628 except KeyboardInterrupt: | 1639 except KeyboardInterrupt: |
| 1629 sys.exit(1) | 1640 sys.exit(1) |
| 1630 except: | 1641 except: |
| 1631 # If we got an exception after the user typed a description for their | 1642 # If we got an exception after the user typed a description for their |
| (...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2607 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2618 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2608 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2619 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2609 | 2620 |
| 2610 | 2621 |
| 2611 if __name__ == '__main__': | 2622 if __name__ == '__main__': |
| 2612 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2623 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2613 # unit testing. | 2624 # unit testing. |
| 2614 fix_encoding.fix_encoding() | 2625 fix_encoding.fix_encoding() |
| 2615 colorama.init() | 2626 colorama.init() |
| 2616 sys.exit(main(sys.argv[1:])) | 2627 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |