Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 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 logging | 10 import logging |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 439 self.GetIssue() | 439 self.GetIssue() |
| 440 return self.rietveld_server | 440 return self.rietveld_server |
| 441 | 441 |
| 442 def GetIssueURL(self): | 442 def GetIssueURL(self): |
| 443 """Get the URL for a particular issue.""" | 443 """Get the URL for a particular issue.""" |
| 444 return '%s/%s' % (self.GetRietveldServer(), self.GetIssue()) | 444 return '%s/%s' % (self.GetRietveldServer(), self.GetIssue()) |
| 445 | 445 |
| 446 def GetDescription(self, pretty=False): | 446 def GetDescription(self, pretty=False): |
| 447 if not self.has_description: | 447 if not self.has_description: |
| 448 if self.GetIssue(): | 448 if self.GetIssue(): |
| 449 self.description = self.RpcServer().get_description( | 449 issue = int(self.GetIssue()) |
| 450 int(self.GetIssue())).strip() | 450 try: |
| 451 self.description = self.RpcServer().get_description(issue).strip() | |
| 452 except urllib2.HTTPError, e: | |
| 453 if e.code == 404: | |
| 454 DieWithError( | |
| 455 ('\nWhile fetching the description for issue %d, received a ' | |
| 456 '404 (not found)\nerror. It is likely that you deleted this ' | |
|
M-A Ruel
2012/01/04 19:16:35
I prefer to have each \n to end the string even if
| |
| 457 'issue on the server. If this is the\ncase, please run\n\n' | |
| 458 ' git cl issue 0\n\n' | |
| 459 'to clear the association with the deleted issue. Then ' | |
| 460 'run this command again.') % issue) | |
| 461 else: | |
| 462 DieWithError('\nFailed to fetch issue description. HTTP error ' + | |
|
M-A Ruel
2012/01/04 19:16:35
I prefer this alignment:
DieWithError(
'\nFai
| |
| 463 e.code) | |
| 451 self.has_description = True | 464 self.has_description = True |
| 452 if pretty: | 465 if pretty: |
| 453 wrapper = textwrap.TextWrapper() | 466 wrapper = textwrap.TextWrapper() |
| 454 wrapper.initial_indent = wrapper.subsequent_indent = ' ' | 467 wrapper.initial_indent = wrapper.subsequent_indent = ' ' |
| 455 return wrapper.fill(self.description) | 468 return wrapper.fill(self.description) |
| 456 return self.description | 469 return self.description |
| 457 | 470 |
| 458 def GetPatchset(self): | 471 def GetPatchset(self): |
| 459 if not self.has_patchset: | 472 if not self.has_patchset: |
| 460 patchset = RunGit(['config', self._PatchsetSetting()], | 473 patchset = RunGit(['config', self._PatchsetSetting()], |
| (...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1416 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 1429 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
| 1417 | 1430 |
| 1418 # Not a known command. Default to help. | 1431 # Not a known command. Default to help. |
| 1419 GenUsage(parser, 'help') | 1432 GenUsage(parser, 'help') |
| 1420 return CMDhelp(parser, argv) | 1433 return CMDhelp(parser, argv) |
| 1421 | 1434 |
| 1422 | 1435 |
| 1423 if __name__ == '__main__': | 1436 if __name__ == '__main__': |
| 1424 fix_encoding.fix_encoding() | 1437 fix_encoding.fix_encoding() |
| 1425 sys.exit(main(sys.argv[1:])) | 1438 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |