| 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 and Gerrit.""" | 8 """A git-command for integrating reviews on Rietveld and Gerrit.""" |
| 9 | 9 |
| 10 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
| (...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 def UpdateDescription(self, description): | 1308 def UpdateDescription(self, description): |
| 1309 self.description = description | 1309 self.description = description |
| 1310 return self._codereview_impl.UpdateDescriptionRemote(description) | 1310 return self._codereview_impl.UpdateDescriptionRemote(description) |
| 1311 | 1311 |
| 1312 def RunHook(self, committing, may_prompt, verbose, change): | 1312 def RunHook(self, committing, may_prompt, verbose, change): |
| 1313 """Calls sys.exit() if the hook fails; returns a HookResults otherwise.""" | 1313 """Calls sys.exit() if the hook fails; returns a HookResults otherwise.""" |
| 1314 try: | 1314 try: |
| 1315 return presubmit_support.DoPresubmitChecks(change, committing, | 1315 return presubmit_support.DoPresubmitChecks(change, committing, |
| 1316 verbose=verbose, output_stream=sys.stdout, input_stream=sys.stdin, | 1316 verbose=verbose, output_stream=sys.stdout, input_stream=sys.stdin, |
| 1317 default_presubmit=None, may_prompt=may_prompt, | 1317 default_presubmit=None, may_prompt=may_prompt, |
| 1318 rietveld_obj=self._codereview_impl.GetRieveldObjForPresubmit()) | 1318 rietveld_obj=self._codereview_impl.GetRieveldObjForPresubmit(), |
| 1319 gerrit_obj=self._codereview_impl.GetGerritObjForPresubmit()) |
| 1319 except presubmit_support.PresubmitFailure, e: | 1320 except presubmit_support.PresubmitFailure, e: |
| 1320 DieWithError( | 1321 DieWithError( |
| 1321 ('%s\nMaybe your depot_tools is out of date?\n' | 1322 ('%s\nMaybe your depot_tools is out of date?\n' |
| 1322 'If all fails, contact maruel@') % e) | 1323 'If all fails, contact maruel@') % e) |
| 1323 | 1324 |
| 1324 def CMDPatchIssue(self, issue_arg, reject, nocommit, directory): | 1325 def CMDPatchIssue(self, issue_arg, reject, nocommit, directory): |
| 1325 """Fetches and applies the issue patch from codereview to local branch.""" | 1326 """Fetches and applies the issue patch from codereview to local branch.""" |
| 1326 if isinstance(issue_arg, (int, long)) or issue_arg.isdigit(): | 1327 if isinstance(issue_arg, (int, long)) or issue_arg.isdigit(): |
| 1327 parsed_issue_arg = _ParsedIssueNumberArgument(int(issue_arg)) | 1328 parsed_issue_arg = _ParsedIssueNumberArgument(int(issue_arg)) |
| 1328 else: | 1329 else: |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1492 | 1493 |
| 1493 def PatchsetSetting(self): | 1494 def PatchsetSetting(self): |
| 1494 """Returns name of git config setting which stores issue number.""" | 1495 """Returns name of git config setting which stores issue number.""" |
| 1495 raise NotImplementedError() | 1496 raise NotImplementedError() |
| 1496 | 1497 |
| 1497 def GetRieveldObjForPresubmit(self): | 1498 def GetRieveldObjForPresubmit(self): |
| 1498 # This is an unfortunate Rietveld-embeddedness in presubmit. | 1499 # This is an unfortunate Rietveld-embeddedness in presubmit. |
| 1499 # For non-Rietveld codereviews, this probably should return a dummy object. | 1500 # For non-Rietveld codereviews, this probably should return a dummy object. |
| 1500 raise NotImplementedError() | 1501 raise NotImplementedError() |
| 1501 | 1502 |
| 1503 def GetGerritObjForPresubmit(self): |
| 1504 # None is valid return value, otherwise presubmit_support.GerritAccessor. |
| 1505 return None |
| 1506 |
| 1502 def UpdateDescriptionRemote(self, description): | 1507 def UpdateDescriptionRemote(self, description): |
| 1503 """Update the description on codereview site.""" | 1508 """Update the description on codereview site.""" |
| 1504 raise NotImplementedError() | 1509 raise NotImplementedError() |
| 1505 | 1510 |
| 1506 def CloseIssue(self): | 1511 def CloseIssue(self): |
| 1507 """Closes the issue.""" | 1512 """Closes the issue.""" |
| 1508 raise NotImplementedError() | 1513 raise NotImplementedError() |
| 1509 | 1514 |
| 1510 def GetApprovingReviewers(self): | 1515 def GetApprovingReviewers(self): |
| 1511 """Returns a list of reviewers approving the change. | 1516 """Returns a list of reviewers approving the change. |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2098 def __getattr__(self, attr): | 2103 def __getattr__(self, attr): |
| 2099 print( | 2104 print( |
| 2100 'You aren\'t using Rietveld at the moment, but Gerrit.\n' | 2105 'You aren\'t using Rietveld at the moment, but Gerrit.\n' |
| 2101 'Using Rietveld in your PRESUBMIT scripts won\'t work.\n' | 2106 'Using Rietveld in your PRESUBMIT scripts won\'t work.\n' |
| 2102 'Please, either change your PRESUBIT to not use rietveld_obj.%s,\n' | 2107 'Please, either change your PRESUBIT to not use rietveld_obj.%s,\n' |
| 2103 'or use Rietveld for codereview.\n' | 2108 'or use Rietveld for codereview.\n' |
| 2104 'See also http://crbug.com/579160.' % attr) | 2109 'See also http://crbug.com/579160.' % attr) |
| 2105 raise NotImplementedError() | 2110 raise NotImplementedError() |
| 2106 return ThisIsNotRietveldIssue() | 2111 return ThisIsNotRietveldIssue() |
| 2107 | 2112 |
| 2113 def GetGerritObjForPresubmit(self): |
| 2114 return presubmit_support.GerritAccessor(self._GetGerritHost()) |
| 2115 |
| 2108 def GetStatus(self): | 2116 def GetStatus(self): |
| 2109 """Apply a rough heuristic to give a simple summary of an issue's review | 2117 """Apply a rough heuristic to give a simple summary of an issue's review |
| 2110 or CQ status, assuming adherence to a common workflow. | 2118 or CQ status, assuming adherence to a common workflow. |
| 2111 | 2119 |
| 2112 Returns None if no issue for this branch, or one of the following keywords: | 2120 Returns None if no issue for this branch, or one of the following keywords: |
| 2113 * 'error' - error from review tool (including deleted issues) | 2121 * 'error' - error from review tool (including deleted issues) |
| 2114 * 'unsent' - no reviewers added | 2122 * 'unsent' - no reviewers added |
| 2115 * 'waiting' - waiting for review | 2123 * 'waiting' - waiting for review |
| 2116 * 'reply' - waiting for owner to reply to review | 2124 * 'reply' - waiting for owner to reply to review |
| 2117 * 'not lgtm' - Code-Review -2 from at least one approved reviewer | 2125 * 'not lgtm' - Code-Review -2 from at least one approved reviewer |
| (...skipping 2736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4854 if __name__ == '__main__': | 4862 if __name__ == '__main__': |
| 4855 # These affect sys.stdout so do it outside of main() to simplify mocks in | 4863 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 4856 # unit testing. | 4864 # unit testing. |
| 4857 fix_encoding.fix_encoding() | 4865 fix_encoding.fix_encoding() |
| 4858 setup_color.init() | 4866 setup_color.init() |
| 4859 try: | 4867 try: |
| 4860 sys.exit(main(sys.argv[1:])) | 4868 sys.exit(main(sys.argv[1:])) |
| 4861 except KeyboardInterrupt: | 4869 except KeyboardInterrupt: |
| 4862 sys.stderr.write('interrupted\n') | 4870 sys.stderr.write('interrupted\n') |
| 4863 sys.exit(1) | 4871 sys.exit(1) |
| OLD | NEW |