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 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
691 if not self.GetIssue(): | 691 if not self.GetIssue(): |
692 return None | 692 return None |
693 return '%s/%s' % (self.GetRietveldServer(), self.GetIssue()) | 693 return '%s/%s' % (self.GetRietveldServer(), self.GetIssue()) |
694 | 694 |
695 def GetDescription(self, pretty=False): | 695 def GetDescription(self, pretty=False): |
696 if not self.has_description: | 696 if not self.has_description: |
697 if self.GetIssue(): | 697 if self.GetIssue(): |
698 issue = self.GetIssue() | 698 issue = self.GetIssue() |
699 try: | 699 try: |
700 self.description = self.RpcServer().get_description(issue).strip() | 700 self.description = self.RpcServer().get_description(issue).strip() |
701 except urllib2.HTTPError, e: | 701 except urllib2.HTTPError as e: |
702 if e.code == 404: | 702 if e.code == 404: |
703 DieWithError( | 703 DieWithError( |
704 ('\nWhile fetching the description for issue %d, received a ' | 704 ('\nWhile fetching the description for issue %d, received a ' |
705 '404 (not found)\n' | 705 '404 (not found)\n' |
706 'error. It is likely that you deleted this ' | 706 'error. It is likely that you deleted this ' |
707 'issue on the server. If this is the\n' | 707 'issue on the server. If this is the\n' |
708 'case, please run\n\n' | 708 'case, please run\n\n' |
709 ' git cl issue 0\n\n' | 709 ' git cl issue 0\n\n' |
710 'to clear the association with the deleted issue. Then run ' | 710 'to clear the association with the deleted issue. Then run ' |
711 'this command again.') % issue) | 711 'this command again.') % issue) |
712 else: | 712 else: |
713 DieWithError( | 713 DieWithError( |
714 '\nFailed to fetch issue description. HTTP error %d' % e.code) | 714 '\nFailed to fetch issue description. HTTP error %d' % e.code) |
715 except urllib2.URLError as e: | |
716 print >> sys.stderr, ( | |
717 'Warning: Failed to retrieve CL description due to network ' | |
718 'failure.') | |
719 self.description = '' | |
720 | |
715 self.has_description = True | 721 self.has_description = True |
716 if pretty: | 722 if pretty: |
717 wrapper = textwrap.TextWrapper() | 723 wrapper = textwrap.TextWrapper() |
718 wrapper.initial_indent = wrapper.subsequent_indent = ' ' | 724 wrapper.initial_indent = wrapper.subsequent_indent = ' ' |
719 return wrapper.fill(self.description) | 725 return wrapper.fill(self.description) |
720 return self.description | 726 return self.description |
721 | 727 |
722 def GetPatchset(self): | 728 def GetPatchset(self): |
723 """Returns the patchset number as a int or None if not set.""" | 729 """Returns the patchset number as a int or None if not set.""" |
724 if self.patchset is None and not self.lookedup_patchset: | 730 if self.patchset is None and not self.lookedup_patchset: |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1309 alignment, ShortBranchName(branch), color, issue, reset) | 1315 alignment, ShortBranchName(branch), color, issue, reset) |
1310 | 1316 |
1311 cl = Changelist() | 1317 cl = Changelist() |
1312 print | 1318 print |
1313 print 'Current branch:', | 1319 print 'Current branch:', |
1314 if not cl.GetIssue(): | 1320 if not cl.GetIssue(): |
1315 print 'no issue assigned.' | 1321 print 'no issue assigned.' |
1316 return 0 | 1322 return 0 |
1317 print cl.GetBranch() | 1323 print cl.GetBranch() |
1318 print 'Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL()) | 1324 print 'Issue number: %s (%s)' % (cl.GetIssue(), cl.GetIssueURL()) |
1319 print 'Issue description:' | 1325 if not options.fast: |
1320 print cl.GetDescription(pretty=True) | 1326 print 'Issue description:' |
iannucci
2014/07/27 18:05:09
it would be neat to cache this non-fast stuff. It
M-A Ruel
2014/07/28 15:35:41
The funny thing is that gcl does that. It should b
| |
1327 print cl.GetDescription(pretty=True) | |
1321 return 0 | 1328 return 0 |
1322 | 1329 |
1323 | 1330 |
1324 def colorize_CMDstatus_doc(): | 1331 def colorize_CMDstatus_doc(): |
1325 """To be called once in main() to add colors to git cl status help.""" | 1332 """To be called once in main() to add colors to git cl status help.""" |
1326 colors = [i for i in dir(Fore) if i[0].isupper()] | 1333 colors = [i for i in dir(Fore) if i[0].isupper()] |
1327 | 1334 |
1328 def colorize_line(line): | 1335 def colorize_line(line): |
1329 for color in colors: | 1336 for color in colors: |
1330 if color in line.upper(): | 1337 if color in line.upper(): |
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2649 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2656 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
2650 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2657 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
2651 | 2658 |
2652 | 2659 |
2653 if __name__ == '__main__': | 2660 if __name__ == '__main__': |
2654 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2661 # These affect sys.stdout so do it outside of main() to simplify mocks in |
2655 # unit testing. | 2662 # unit testing. |
2656 fix_encoding.fix_encoding() | 2663 fix_encoding.fix_encoding() |
2657 colorama.init() | 2664 colorama.init() |
2658 sys.exit(main(sys.argv[1:])) | 2665 sys.exit(main(sys.argv[1:])) |
OLD | NEW |