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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkit-patch

Issue 2110893003: Merge webkit_patch and multi_command_tool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sort imports; remove out-of-date comment. Created 4 years, 5 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
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/tool/multi_command_tool.py » ('j') | no next file with comments »
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) 2011 Code Aurora Forum. All rights reserved. 2 # Copyright (c) 2011 Code Aurora Forum. All rights reserved.
3 # Copyright (c) 2010 Google Inc. All rights reserved. 3 # Copyright (c) 2010 Google Inc. All rights reserved.
4 # Copyright (c) 2009 Apple Inc. All rights reserved. 4 # Copyright (c) 2009 Apple Inc. All rights reserved.
5 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org) 5 # Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org)
6 # 6 #
7 # Redistribution and use in source and binary forms, with or without 7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are 8 # modification, are permitted provided that the following conditions are
9 # met: 9 # met:
10 # 10 #
(...skipping 11 matching lines...) Expand all
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #
33 # A tool for automating dealing with bugzilla, posting patches, committing patch es, etc.
34 32
35 import logging 33 import logging
36 import os
37 import signal 34 import signal
38 import sys 35 import sys
39 import codecs 36 import codecs
40 37
41 import webkitpy.common.version_check 38 import webkitpy.common.version_check
42 39
43 from webkitpy.common.system.logutils import configure_logging 40 from webkitpy.common.system.logutils import configure_logging
44 from webkitpy.tool.webkit_patch import WebKitPatch 41 from webkitpy.tool.webkit_patch import WebKitPatch
45 42
46 # A StreamWriter will by default try to encode all objects passed 43 # A StreamWriter will by default try to encode all objects passed
47 # to write(), so when passed a raw string already encoded as utf8, 44 # to write(), so when passed a raw string already encoded as utf8,
48 # it will blow up with an UnicodeDecodeError. This does not match 45 # it will blow up with an UnicodeDecodeError. This does not match
49 # the default behaviour of writing to sys.stdout, so we intercept 46 # the default behaviour of writing to sys.stdout, so we intercept
50 # the case of writing raw strings and make sure StreamWriter gets 47 # the case of writing raw strings and make sure StreamWriter gets
51 # input that it can handle. 48 # input that it can handle.
52 49
53 50
54 class ForgivingUTF8Writer(codecs.lookup('utf-8')[-1]): 51 class ForgivingUTF8Writer(codecs.lookup('utf-8')[-1]):
55 52
56 def write(self, object): 53 def write(self, obj):
57 if isinstance(object, str): 54 if isinstance(obj, str):
58 # Assume raw strings are utf-8 encoded. If this line 55 # Assume raw strings are utf-8 encoded. If this line
59 # fails with an UnicodeDecodeError, our assumption was 56 # fails with an UnicodeDecodeError, our assumption was
60 # wrong, and the stacktrace should show you where we 57 # wrong, and the stacktrace should show you where we
61 # write non-Unicode/UTF-8 data (which we shouldn't). 58 # write non-Unicode/UTF-8 data (which we shouldn't).
62 object = object.decode('utf-8') 59 obj = obj.decode('utf-8')
63 return codecs.StreamWriter.write(self, object) 60 return codecs.StreamWriter.write(self, obj)
64 61
65 # By default, sys.stdout assumes ascii encoding. Since our messages can 62 # By default, sys.stdout assumes ascii encoding. Since our messages can
66 # contain unicode strings (as with some peoples' names) we need to apply 63 # contain unicode strings (as with some peoples' names) we need to apply
67 # the utf-8 codec to prevent throwing and exception. 64 # the utf-8 codec to prevent throwing and exception.
68 # Not having this was the cause of https://bugs.webkit.org/show_bug.cgi?id=63452 . 65 # Not having this was the cause of https://bugs.webkit.org/show_bug.cgi?id=63452 .
69 sys.stdout = ForgivingUTF8Writer(sys.stdout) 66 sys.stdout = ForgivingUTF8Writer(sys.stdout)
70 67
71 _log = logging.getLogger("webkit-patch") 68 _log = logging.getLogger("webkit-patch")
72 69
73 70
74 def main(): 71 def main():
75 # This is a hack to let us enable DEBUG logging as early as possible. 72 # This is a hack to let us enable DEBUG logging as early as possible.
76 # Note this can't be ternary as versioning.check_version() 73 # Note this can't be ternary as versioning.check_version()
77 # hasn't run yet and this python might be older than 2.5. 74 # hasn't run yet and this python might be older than 2.5.
78 if set(["-v", "--verbose"]).intersection(set(sys.argv)): 75 if set(["-v", "--verbose"]).intersection(set(sys.argv)):
79 logging_level = logging.DEBUG 76 logging_level = logging.DEBUG
80 else: 77 else:
81 logging_level = logging.INFO 78 logging_level = logging.INFO
82 configure_logging(logging_level=logging_level) 79 configure_logging(logging_level=logging_level)
83 WebKitPatch(os.path.abspath(__file__)).main() 80 WebKitPatch().main()
84 81
85 82
86 if __name__ == "__main__": 83 if __name__ == "__main__":
87 try: 84 try:
88 main() 85 main()
89 except KeyboardInterrupt: 86 except KeyboardInterrupt:
90 sys.exit(signal.SIGINT + 128) 87 sys.exit(signal.SIGINT + 128)
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Tools/Scripts/webkitpy/tool/multi_command_tool.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698