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 getpass | 9 import getpass |
10 import logging | 10 import logging |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 parser.add_option( | 58 parser.add_option( |
59 '-r', | 59 '-r', |
60 '--root_dir', | 60 '--root_dir', |
61 default=os.getcwd(), | 61 default=os.getcwd(), |
62 help='Root directory to apply the patch') | 62 help='Root directory to apply the patch') |
63 parser.add_option( | 63 parser.add_option( |
64 '-s', | 64 '-s', |
65 '--server', | 65 '--server', |
66 default='http://codereview.chromium.org', | 66 default='http://codereview.chromium.org', |
67 help='Rietveld server') | 67 help='Rietveld server') |
| 68 parser.add_option('--no-commit', action='store_true', |
| 69 help='Do not try to commit patch to SCM (git only)') |
68 options, args = parser.parse_args() | 70 options, args = parser.parse_args() |
69 logging.basicConfig( | 71 logging.basicConfig( |
70 format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s', | 72 format='%(levelname)5s %(module)11s(%(lineno)4d): %(message)s', |
71 level=[logging.WARNING, logging.INFO, logging.DEBUG][ | 73 level=[logging.WARNING, logging.INFO, logging.DEBUG][ |
72 min(2, options.verbose)]) | 74 min(2, options.verbose)]) |
73 if args: | 75 if args: |
74 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) | 76 parser.error('Extra argument(s) "%s" not understood' % ' '.join(args)) |
75 if not options.issue: | 77 if not options.issue: |
76 parser.error('Require --issue') | 78 parser.error('Require --issue') |
77 options.server = options.server.rstrip('/') | 79 options.server = options.server.rstrip('/') |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 print( | 132 print( |
131 'Failed to fetch the patch for issue %d, patchset %d.\n' | 133 'Failed to fetch the patch for issue %d, patchset %d.\n' |
132 'Try visiting %s/%d') % ( | 134 'Try visiting %s/%d') % ( |
133 options.issue, options.patchset, | 135 options.issue, options.patchset, |
134 options.server, options.issue) | 136 options.server, options.issue) |
135 return 1 | 137 return 1 |
136 for patch in patchset.patches: | 138 for patch in patchset.patches: |
137 print(patch) | 139 print(patch) |
138 full_dir = os.path.abspath(options.root_dir) | 140 full_dir = os.path.abspath(options.root_dir) |
139 scm_type = scm.determine_scm(full_dir) | 141 scm_type = scm.determine_scm(full_dir) |
140 if scm_type == 'svn': | 142 if options.no_commit or scm_type is None: |
| 143 scm_obj = checkout.RawCheckout(full_dir, None, None) |
| 144 elif scm_type == 'svn': |
141 scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None) | 145 scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None) |
142 elif scm_type == 'git': | 146 elif scm_type == 'git': |
143 scm_obj = checkout.GitCheckoutBase(full_dir, None, None) | 147 scm_obj = checkout.GitCheckoutBase(full_dir, None, None) |
144 elif scm_type == None: | |
145 scm_obj = checkout.RawCheckout(full_dir, None, None) | |
146 else: | 148 else: |
147 parser.error('Couldn\'t determine the scm') | 149 parser.error('Couldn\'t determine the scm') |
148 | 150 |
149 # TODO(maruel): HACK, remove me. | 151 # TODO(maruel): HACK, remove me. |
150 # When run a build slave, make sure buildbot knows that the checkout was | 152 # When run a build slave, make sure buildbot knows that the checkout was |
151 # modified. | 153 # modified. |
152 if options.root_dir == 'src' and getpass.getuser() == 'chrome-bot': | 154 if options.root_dir == 'src' and getpass.getuser() == 'chrome-bot': |
153 # See sourcedirIsPatched() in: | 155 # See sourcedirIsPatched() in: |
154 # http://src.chromium.org/viewvc/chrome/trunk/tools/build/scripts/slave/ | 156 # http://src.chromium.org/viewvc/chrome/trunk/tools/build/scripts/slave/ |
155 # chromium_commands.py?view=markup | 157 # chromium_commands.py?view=markup |
(...skipping 25 matching lines...) Expand all Loading... |
181 '--nohooks', | 183 '--nohooks', |
182 '--delete_unversioned_trees', | 184 '--delete_unversioned_trees', |
183 ], | 185 ], |
184 cwd=gclient_root) | 186 cwd=gclient_root) |
185 return 0 | 187 return 0 |
186 | 188 |
187 | 189 |
188 if __name__ == "__main__": | 190 if __name__ == "__main__": |
189 fix_encoding.fix_encoding() | 191 fix_encoding.fix_encoding() |
190 sys.exit(main()) | 192 sys.exit(main()) |
OLD | NEW |