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 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) | |
|
agable
2014/06/03 17:41:12
There is now nothing that actually sets this gitco
sheyang
2014/06/04 01:52:52
Done.
| |
| 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']]) |
| 1080 | 1087 |
|
agable
2014/06/03 17:41:12
Leave two newlines here.
sheyang
2014/06/04 01:52:52
Done.
| |
| 1081 | |
| 1082 def urlretrieve(source, destination): | 1088 def urlretrieve(source, destination): |
| 1083 """urllib is broken for SSL connections via a proxy therefore we | 1089 """urllib is broken for SSL connections via a proxy therefore we |
| 1084 can't use urllib.urlretrieve().""" | 1090 can't use urllib.urlretrieve().""" |
| 1085 with open(destination, 'w') as f: | 1091 with open(destination, 'w') as f: |
| 1086 f.write(urllib2.urlopen(source).read()) | 1092 f.write(urllib2.urlopen(source).read()) |
| 1087 | 1093 |
| 1088 | 1094 |
| 1089 def hasSheBang(fname): | 1095 def hasSheBang(fname): |
| 1090 """Checks fname is a #! script.""" | 1096 """Checks fname is a #! script.""" |
| 1091 with open(fname) as f: | 1097 with open(fname) as f: |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1612 keys = dict(line.split(': ', 1) for line in data.splitlines() | 1618 keys = dict(line.split(': ', 1) for line in data.splitlines() |
| 1613 if ': ' in line) | 1619 if ': ' in line) |
| 1614 remote_url = keys.get('URL', None) | 1620 remote_url = keys.get('URL', None) |
| 1615 else: | 1621 else: |
| 1616 if cl.GetRemoteUrl() and '/' in cl.GetUpstreamBranch(): | 1622 if cl.GetRemoteUrl() and '/' in cl.GetUpstreamBranch(): |
| 1617 remote_url = (cl.GetRemoteUrl() + '@' | 1623 remote_url = (cl.GetRemoteUrl() + '@' |
| 1618 + cl.GetUpstreamBranch().split('/')[-1]) | 1624 + cl.GetUpstreamBranch().split('/')[-1]) |
| 1619 if remote_url: | 1625 if remote_url: |
| 1620 upload_args.extend(['--base_url', remote_url]) | 1626 upload_args.extend(['--base_url', remote_url]) |
| 1621 | 1627 |
| 1628 project = settings.GetProject() | |
| 1629 if project: | |
| 1630 upload_args.extend(['--project', project]) | |
| 1631 | |
| 1622 try: | 1632 try: |
| 1623 upload_args = ['upload'] + upload_args + args | 1633 upload_args = ['upload'] + upload_args + args |
| 1624 logging.info('upload.RealMain(%s)', upload_args) | 1634 logging.info('upload.RealMain(%s)', upload_args) |
| 1625 issue, patchset = upload.RealMain(upload_args) | 1635 issue, patchset = upload.RealMain(upload_args) |
| 1626 issue = int(issue) | 1636 issue = int(issue) |
| 1627 patchset = int(patchset) | 1637 patchset = int(patchset) |
| 1628 except KeyboardInterrupt: | 1638 except KeyboardInterrupt: |
| 1629 sys.exit(1) | 1639 sys.exit(1) |
| 1630 except: | 1640 except: |
| 1631 # If we got an exception after the user typed a description for their | 1641 # 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 ' | 2617 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2608 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2618 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2609 | 2619 |
| 2610 | 2620 |
| 2611 if __name__ == '__main__': | 2621 if __name__ == '__main__': |
| 2612 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2622 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2613 # unit testing. | 2623 # unit testing. |
| 2614 fix_encoding.fix_encoding() | 2624 fix_encoding.fix_encoding() |
| 2615 colorama.init() | 2625 colorama.init() |
| 2616 sys.exit(main(sys.argv[1:])) | 2626 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |