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 """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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 # TODO(rogerta): Remove me, it's ugly. | 55 # TODO(rogerta): Remove me, it's ugly. |
56 if options.email == '=': | 56 if options.email == '=': |
57 options.email = '' | 57 options.email = '' |
58 | 58 |
59 obj = rietveld.Rietveld(options.server, options.email, None) | 59 obj = rietveld.Rietveld(options.server, options.email, None) |
60 | 60 |
61 if not options.patchset: | 61 if not options.patchset: |
62 options.patchset = obj.get_issue_properties( | 62 options.patchset = obj.get_issue_properties( |
63 options.issue, False)['patchsets'][-1] | 63 options.issue, False)['patchsets'][-1] |
64 logging.info('Using patchset %d' % options.patchset) | 64 print('No patchset specified. Using patchset %d' % options.patchset) |
65 # Download the patch. | 65 |
| 66 print('Downloading the patch.') |
66 patchset = obj.get_patch(options.issue, options.patchset) | 67 patchset = obj.get_patch(options.issue, options.patchset) |
67 for patch in patchset.patches: | 68 for patch in patchset.patches: |
68 logging.info(patch) | 69 print(patch) |
69 scm_type = scm.determine_scm(options.root_dir) | 70 scm_type = scm.determine_scm(options.root_dir) |
70 if scm_type == 'svn': | 71 if scm_type == 'svn': |
71 scm_obj = checkout.SvnCheckout(options.root_dir, None, None, None, None) | 72 scm_obj = checkout.SvnCheckout(options.root_dir, None, None, None, None) |
72 elif scm_type == 'git': | 73 elif scm_type == 'git': |
73 scm_obj = checkout.GitCheckoutBase(options.root_dir, None, None) | 74 scm_obj = checkout.GitCheckoutBase(options.root_dir, None, None) |
74 elif scm_type == None: | 75 elif scm_type == None: |
75 scm_obj = checkout.RawCheckout(options.root_dir, None) | 76 scm_obj = checkout.RawCheckout(options.root_dir, None) |
76 else: | 77 else: |
77 parser.error('Couldn\'t determine the scm') | 78 parser.error('Couldn\'t determine the scm') |
78 | 79 |
79 # Apply the patch. | 80 # Apply the patch. |
80 try: | 81 try: |
81 scm_obj.apply_patch(patchset) | 82 scm_obj.apply_patch(patchset) |
82 except checkout.PatchApplicationFailed, e: | 83 except checkout.PatchApplicationFailed, e: |
83 print >> sys.stderr, str(e) | 84 print >> sys.stderr, str(e) |
84 return 1 | 85 return 1 |
85 return 0 | 86 return 0 |
86 | 87 |
87 | 88 |
88 if __name__ == "__main__": | 89 if __name__ == "__main__": |
89 fix_encoding.fix_encoding() | 90 fix_encoding.fix_encoding() |
90 sys.exit(main()) | 91 sys.exit(main()) |
OLD | NEW |