Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: apply_issue.py

Issue 10908063: Fix apply_issue.py to work on python 2.6. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | rietveld.py » ('j') | rietveld.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 """Applies an issue from Rietveld. 6 """Applies an issue from Rietveld.
7 """ 7 """
8 8
9 import logging 9 import logging
10 import optparse 10 import optparse
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) 52 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args))
53 if not options.issue: 53 if not options.issue:
54 parser.error('Require --issue') 54 parser.error('Require --issue')
55 options.server = options.server.rstrip('/') 55 options.server = options.server.rstrip('/')
56 if not options.server: 56 if not options.server:
57 parser.error('Require a valid server') 57 parser.error('Require a valid server')
58 58
59 obj = rietveld.Rietveld(options.server, '', None) 59 obj = rietveld.Rietveld(options.server, '', None)
60 try: 60 try:
61 properties = obj.get_issue_properties(options.issue, False) 61 properties = obj.get_issue_properties(options.issue, False)
62 except rietveld.upload.ClientLoginError: 62 except rietveld.upload.ClientLoginError, e:
63 # Requires login. 63 if sys.stdout.closed:
64 print >> sys.stderr, 'Accessing the issue requires login.'
M-A Ruel 2012/09/03 17:34:25 Hopefully, this should refrain from causing times
65 return 1
66 print('Accessing the issue requires login.')
64 obj = rietveld.Rietveld(options.server, None, None) 67 obj = rietveld.Rietveld(options.server, None, None)
65 properties = obj.get_issue_properties(options.issue, False) 68 properties = obj.get_issue_properties(options.issue, False)
66 69
67 if not options.patchset: 70 if not options.patchset:
68 options.patchset = properties['patchsets'][-1] 71 options.patchset = properties['patchsets'][-1]
69 print('No patchset specified. Using patchset %d' % options.patchset) 72 print('No patchset specified. Using patchset %d' % options.patchset)
70 73
71 print('Downloading the patch.') 74 print('Downloading the patch.')
72 try: 75 try:
73 patchset = obj.get_patch(options.issue, options.patchset) 76 patchset = obj.get_patch(options.issue, options.patchset)
74 except urllib2.HTTPError, e: 77 except urllib2.HTTPError, e:
75 print >> sys.stderr, ( 78 print >> sys.stderr, (
76 'Failed to fetch the patch for issue %d, patchset %d.\n' 79 'Failed to fetch the patch for issue %d, patchset %d.\n'
77 'Try visiting %s/%d') % ( 80 'Try visiting %s/%d') % (
78 options.issue, options.patchset, 81 options.issue, options.patchset,
79 options.server, options.issue) 82 options.server, options.issue)
80 return 1 83 return 1
81 for patch in patchset.patches: 84 for patch in patchset.patches:
82 print(patch) 85 print(patch)
83 scm_type = scm.determine_scm(options.root_dir) 86 scm_type = scm.determine_scm(options.root_dir)
84 if scm_type == 'svn': 87 if scm_type == 'svn':
85 scm_obj = checkout.SvnCheckout(options.root_dir, None, None, None, None) 88 scm_obj = checkout.SvnCheckout(options.root_dir, None, None, None, None)
86 elif scm_type == 'git': 89 elif scm_type == 'git':
87 scm_obj = checkout.GitCheckoutBase(options.root_dir, None, None) 90 scm_obj = checkout.GitCheckoutBase(options.root_dir, None, None)
88 elif scm_type == None: 91 elif scm_type == None:
89 scm_obj = checkout.RawCheckout(options.root_dir, None) 92 scm_obj = checkout.RawCheckout(options.root_dir, None, None)
90 else: 93 else:
91 parser.error('Couldn\'t determine the scm') 94 parser.error('Couldn\'t determine the scm')
92 95
93 # Apply the patch. 96 # Apply the patch.
94 try: 97 try:
95 scm_obj.apply_patch(patchset) 98 scm_obj.apply_patch(patchset)
96 except checkout.PatchApplicationFailed, e: 99 except checkout.PatchApplicationFailed, e:
97 print >> sys.stderr, str(e) 100 print >> sys.stderr, str(e)
98 return 1 101 return 1
99 return 0 102 return 0
100 103
101 104
102 if __name__ == "__main__": 105 if __name__ == "__main__":
103 fix_encoding.fix_encoding() 106 fix_encoding.fix_encoding()
104 sys.exit(main()) 107 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | rietveld.py » ('j') | rietveld.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698