| 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 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 self.tree_status_url = self._GetConfig('rietveld.tree-status-url', | 388 self.tree_status_url = self._GetConfig('rietveld.tree-status-url', |
| 389 error_ok=error_ok, | 389 error_ok=error_ok, |
| 390 error_message=error_message) | 390 error_message=error_message) |
| 391 return self.tree_status_url | 391 return self.tree_status_url |
| 392 | 392 |
| 393 def GetViewVCUrl(self): | 393 def GetViewVCUrl(self): |
| 394 if not self.viewvc_url: | 394 if not self.viewvc_url: |
| 395 self.viewvc_url = self._GetConfig('rietveld.viewvc-url', error_ok=True) | 395 self.viewvc_url = self._GetConfig('rietveld.viewvc-url', error_ok=True) |
| 396 return self.viewvc_url | 396 return self.viewvc_url |
| 397 | 397 |
| 398 def GetBugPrefix(self): |
| 399 return self._GetConfig('rietveld.bug-prefix', error_ok=True) |
| 400 |
| 398 def GetDefaultCCList(self): | 401 def GetDefaultCCList(self): |
| 399 return self._GetConfig('rietveld.cc', error_ok=True) | 402 return self._GetConfig('rietveld.cc', error_ok=True) |
| 400 | 403 |
| 401 def GetDefaultPrivateFlag(self): | 404 def GetDefaultPrivateFlag(self): |
| 402 return self._GetConfig('rietveld.private', error_ok=True) | 405 return self._GetConfig('rietveld.private', error_ok=True) |
| 403 | 406 |
| 404 def GetIsGerrit(self): | 407 def GetIsGerrit(self): |
| 405 """Return true if this repo is assosiated with gerrit code review system.""" | 408 """Return true if this repo is assosiated with gerrit code review system.""" |
| 406 if self.is_gerrit is None: | 409 if self.is_gerrit is None: |
| 407 self.is_gerrit = self._GetConfig('gerrit.host', error_ok=True) | 410 self.is_gerrit = self._GetConfig('gerrit.host', error_ok=True) |
| (...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 new_val = gclient_utils.UpgradeToHttps(new_val) | 861 new_val = gclient_utils.UpgradeToHttps(new_val) |
| 859 if new_val != initial: | 862 if new_val != initial: |
| 860 RunGit(['config', 'rietveld.' + name, new_val]) | 863 RunGit(['config', 'rietveld.' + name, new_val]) |
| 861 | 864 |
| 862 SetProperty(settings.GetDefaultCCList(), 'CC list', 'cc', False) | 865 SetProperty(settings.GetDefaultCCList(), 'CC list', 'cc', False) |
| 863 SetProperty(settings.GetDefaultPrivateFlag(), | 866 SetProperty(settings.GetDefaultPrivateFlag(), |
| 864 'Private flag (rietveld only)', 'private', False) | 867 'Private flag (rietveld only)', 'private', False) |
| 865 SetProperty(settings.GetTreeStatusUrl(error_ok=True), 'Tree status URL', | 868 SetProperty(settings.GetTreeStatusUrl(error_ok=True), 'Tree status URL', |
| 866 'tree-status-url', False) | 869 'tree-status-url', False) |
| 867 SetProperty(settings.GetViewVCUrl(), 'ViewVC URL', 'viewvc-url', True) | 870 SetProperty(settings.GetViewVCUrl(), 'ViewVC URL', 'viewvc-url', True) |
| 871 SetProperty(settings.GetBugPrefix(), 'Bug Prefix', 'bug-prefix', False) |
| 868 | 872 |
| 869 # TODO: configure a default branch to diff against, rather than this | 873 # TODO: configure a default branch to diff against, rather than this |
| 870 # svn-based hackery. | 874 # svn-based hackery. |
| 871 | 875 |
| 872 | 876 |
| 873 class ChangeDescription(object): | 877 class ChangeDescription(object): |
| 874 """Contains a parsed form of the change description.""" | 878 """Contains a parsed form of the change description.""" |
| 875 R_LINE = r'^[ \t]*(TBR|R)[ \t]*=[ \t]*(.*?)[ \t]*$' | 879 R_LINE = r'^[ \t]*(TBR|R)[ \t]*=[ \t]*(.*?)[ \t]*$' |
| 876 BUG_LINE = r'^[ \t]*(BUG)[ \t]*=[ \t]*(.*?)[ \t]*$' | 880 BUG_LINE = r'^[ \t]*(BUG)[ \t]*=[ \t]*(.*?)[ \t]*$' |
| 877 | 881 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 self.set_description([ | 946 self.set_description([ |
| 943 '# Enter a description of the change.', | 947 '# Enter a description of the change.', |
| 944 '# This will be displayed on the codereview site.', | 948 '# This will be displayed on the codereview site.', |
| 945 '# The first line will also be used as the subject of the review.', | 949 '# The first line will also be used as the subject of the review.', |
| 946 '#--------------------This line is 72 characters long' | 950 '#--------------------This line is 72 characters long' |
| 947 '--------------------', | 951 '--------------------', |
| 948 ] + self._description_lines) | 952 ] + self._description_lines) |
| 949 | 953 |
| 950 regexp = re.compile(self.BUG_LINE) | 954 regexp = re.compile(self.BUG_LINE) |
| 951 if not any((regexp.match(line) for line in self._description_lines)): | 955 if not any((regexp.match(line) for line in self._description_lines)): |
| 952 self.append_footer('BUG=') | 956 self.append_footer('BUG=%s' % settings.GetBugPrefix()) |
| 953 content = gclient_utils.RunEditor(self.description, True, | 957 content = gclient_utils.RunEditor(self.description, True, |
| 954 git_editor=settings.GetGitEditor()) | 958 git_editor=settings.GetGitEditor()) |
| 955 if not content: | 959 if not content: |
| 956 DieWithError('Running editor failed') | 960 DieWithError('Running editor failed') |
| 957 lines = content.splitlines() | 961 lines = content.splitlines() |
| 958 | 962 |
| 959 # Strip off comments. | 963 # Strip off comments. |
| 960 clean_lines = [line.rstrip() for line in lines if not line.startswith('#')] | 964 clean_lines = [line.rstrip() for line in lines if not line.startswith('#')] |
| 961 if not clean_lines: | 965 if not clean_lines: |
| 962 DieWithError('No CL description, aborting') | 966 DieWithError('No CL description, aborting') |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 else: | 1029 else: |
| 1026 RunGit(['config', '--unset-all', fullname], error_ok=unset_error_ok) | 1030 RunGit(['config', '--unset-all', fullname], error_ok=unset_error_ok) |
| 1027 | 1031 |
| 1028 SetProperty('server', 'CODE_REVIEW_SERVER') | 1032 SetProperty('server', 'CODE_REVIEW_SERVER') |
| 1029 # Only server setting is required. Other settings can be absent. | 1033 # Only server setting is required. Other settings can be absent. |
| 1030 # In that case, we ignore errors raised during option deletion attempt. | 1034 # In that case, we ignore errors raised during option deletion attempt. |
| 1031 SetProperty('cc', 'CC_LIST', unset_error_ok=True) | 1035 SetProperty('cc', 'CC_LIST', unset_error_ok=True) |
| 1032 SetProperty('private', 'PRIVATE', unset_error_ok=True) | 1036 SetProperty('private', 'PRIVATE', unset_error_ok=True) |
| 1033 SetProperty('tree-status-url', 'STATUS', unset_error_ok=True) | 1037 SetProperty('tree-status-url', 'STATUS', unset_error_ok=True) |
| 1034 SetProperty('viewvc-url', 'VIEW_VC', unset_error_ok=True) | 1038 SetProperty('viewvc-url', 'VIEW_VC', unset_error_ok=True) |
| 1039 SetProperty('bug-prefix', 'BUG_PREFIX', unset_error_ok=True) |
| 1035 | 1040 |
| 1036 if 'GERRIT_HOST' in keyvals: | 1041 if 'GERRIT_HOST' in keyvals: |
| 1037 RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) | 1042 RunGit(['config', 'gerrit.host', keyvals['GERRIT_HOST']]) |
| 1038 | 1043 |
| 1039 if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals: | 1044 if 'PUSH_URL_CONFIG' in keyvals and 'ORIGIN_URL_CONFIG' in keyvals: |
| 1040 #should be of the form | 1045 #should be of the form |
| 1041 #PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof | 1046 #PUSH_URL_CONFIG: url.ssh://gitrw.chromium.org.pushinsteadof |
| 1042 #ORIGIN_URL_CONFIG: http://src.chromium.org/git | 1047 #ORIGIN_URL_CONFIG: http://src.chromium.org/git |
| 1043 RunGit(['config', keyvals['PUSH_URL_CONFIG'], | 1048 RunGit(['config', keyvals['PUSH_URL_CONFIG'], |
| 1044 keyvals['ORIGIN_URL_CONFIG']]) | 1049 keyvals['ORIGIN_URL_CONFIG']]) |
| (...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2402 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2407 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
| 2403 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2408 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 2404 | 2409 |
| 2405 | 2410 |
| 2406 if __name__ == '__main__': | 2411 if __name__ == '__main__': |
| 2407 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2412 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 2408 # unit testing. | 2413 # unit testing. |
| 2409 fix_encoding.fix_encoding() | 2414 fix_encoding.fix_encoding() |
| 2410 colorama.init() | 2415 colorama.init() |
| 2411 sys.exit(main(sys.argv[1:])) | 2416 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |