OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 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 """Wrapper for trychange.py for WebKit changes.""" | 5 """Wrapper for trychange.py for WebKit changes.""" |
6 | 6 |
7 import errno | 7 import errno |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import sys | 10 import sys |
11 import tempfile | 11 import tempfile |
12 | 12 |
13 import git_cl | 13 import git_cl |
14 from scm import GIT | 14 from scm import GIT |
15 import trychange | 15 import trychange |
16 | 16 |
17 | 17 |
18 class ScopedTemporaryFile(object): | 18 class ScopedTemporaryFile(object): |
19 def __init__(self, **kwargs): | 19 def __init__(self, **kwargs): |
20 file_handle, self._path = tempfile.mkstemp(**kwargs) | 20 file_handle, self._path = tempfile.mkstemp(**kwargs) |
21 os.close(file_handle) | 21 os.close(file_handle) |
22 | 22 |
23 def __enter__(self): | 23 def __enter__(self): |
24 return self._path | 24 return self._path |
25 | 25 |
26 def __exit__(self, type, value, traceback): | 26 def __exit__(self, _exc_type, _exc_value, _exc_traceback): |
27 try: | 27 try: |
28 os.remove(self._path) | 28 os.remove(self._path) |
29 except OSError, e: | 29 except OSError, e: |
30 if e.errno != errno.ENOENT: | 30 if e.errno != errno.ENOENT: |
31 raise e | 31 raise e |
32 | 32 |
33 | 33 |
34 def generateDiff(path_to_write, chromium_src_root): | 34 def generateDiff(path_to_write, chromium_src_root): |
35 """Create the diff file to send to the try server. We prepend the WebKit | 35 """Create the diff file to send to the try server. We prepend the WebKit |
36 revision to the beginning of the diff so we can patch against ToT or other | 36 revision to the beginning of the diff so we can patch against ToT or other |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 args.extend(argv) | 77 args.extend(argv) |
78 cl = git_cl.Changelist() | 78 cl = git_cl.Changelist() |
79 change = cl.GetChange(cl.GetUpstreamBranch(), None) | 79 change = cl.GetChange(cl.GetUpstreamBranch(), None) |
80 logging.getLogger().handlers = [] | 80 logging.getLogger().handlers = [] |
81 return trychange.TryChange(args, change, | 81 return trychange.TryChange(args, change, |
82 swallow_exception=False, prog='git wktry') | 82 swallow_exception=False, prog='git wktry') |
83 | 83 |
84 | 84 |
85 if __name__ == '__main__': | 85 if __name__ == '__main__': |
86 sys.exit(main(sys.argv)) | 86 sys.exit(main(sys.argv)) |
OLD | NEW |