| 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 |
| 11 import optparse | 11 import optparse |
| 12 import os | 12 import os |
| 13 import subprocess | 13 import subprocess |
| 14 import sys | 14 import sys |
| 15 import urllib2 | 15 import urllib2 |
| 16 | 16 |
| 17 import breakpad # pylint: disable=W0611 | 17 import breakpad # pylint: disable=W0611 |
| 18 | 18 |
| 19 import checkout | 19 import checkout |
| 20 import fix_encoding | 20 import fix_encoding |
| 21 import gclient_utils | 21 import gclient_utils |
| 22 import rietveld | 22 import rietveld |
| 23 import scm | 23 import scm |
| 24 | 24 |
| 25 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | 25 BASE_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 26 | 26 |
| 27 | 27 |
| 28 class Unbuffered(object): |
| 29 """Disable buffering on a file object.""" |
| 30 def __init__(self, stream): |
| 31 self.stream = stream |
| 32 |
| 33 def write(self, data): |
| 34 self.stream.write(data) |
| 35 self.stream.flush() |
| 36 |
| 37 def __getattr__(self, attr): |
| 38 return getattr(self.stream, attr) |
| 39 |
| 40 |
| 28 def main(): | 41 def main(): |
| 42 sys.stdout = Unbuffered(sys.stdout) |
| 29 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) | 43 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) |
| 30 parser.add_option( | 44 parser.add_option( |
| 31 '-v', '--verbose', action='count', default=0, | 45 '-v', '--verbose', action='count', default=0, |
| 32 help='Prints debugging infos') | 46 help='Prints debugging infos') |
| 33 parser.add_option( | 47 parser.add_option( |
| 34 '-e', '--email', | 48 '-e', '--email', |
| 35 help='Email address to access rietveld. If not specified, anonymous ' | 49 help='Email address to access rietveld. If not specified, anonymous ' |
| 36 'access will be used.') | 50 'access will be used.') |
| 37 parser.add_option( | 51 parser.add_option( |
| 38 '-w', '--password', default=None, | 52 '-w', '--password', default=None, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 if sys.platform == 'win32': | 175 if sys.platform == 'win32': |
| 162 gclient_path += '.bat' | 176 gclient_path += '.bat' |
| 163 return subprocess.call( | 177 return subprocess.call( |
| 164 [gclient_path, 'sync', '--revision', base_rev], cwd=gclient_root) | 178 [gclient_path, 'sync', '--revision', base_rev], cwd=gclient_root) |
| 165 return 0 | 179 return 0 |
| 166 | 180 |
| 167 | 181 |
| 168 if __name__ == "__main__": | 182 if __name__ == "__main__": |
| 169 fix_encoding.fix_encoding() | 183 fix_encoding.fix_encoding() |
| 170 sys.exit(main()) | 184 sys.exit(main()) |
| OLD | NEW |