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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/scm/scm.py

Issue 2248653002: Revert of Fix pylint warnings in webkitpy/common/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Manual Revert (Patch Set 1 causes patch failure in read_checksum_from_png_unittest.py) Created 4 years, 4 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
OLDNEW
1 # Copyright (c) 2009, Google Inc. All rights reserved. 1 # Copyright (c) 2009, Google Inc. All rights reserved.
2 # Copyright (c) 2009 Apple Inc. All rights reserved. 2 # Copyright (c) 2009 Apple Inc. All rights reserved.
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 16 matching lines...) Expand all
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 # 29 #
30 # Python module for interacting with an SCM system (like SVN or Git) 30 # Python module for interacting with an SCM system (like SVN or Git)
31 31
32 import logging 32 import logging
33 import re 33 import re
34 import sys 34 import sys
35 35
36 from webkitpy.common.system.executive import Executive 36 from webkitpy.common.system.executive import Executive
37 from webkitpy.common.system.executive import ScriptError
37 from webkitpy.common.system.filesystem import FileSystem 38 from webkitpy.common.system.filesystem import FileSystem
38 39
39 _log = logging.getLogger(__name__) 40 _log = logging.getLogger(__name__)
40 41
41 42
42 # SCM methods are expected to return paths relative to self.checkout_root. 43 # SCM methods are expected to return paths relative to self.checkout_root.
43 class SCM(object): 44 class SCM:
44 45
45 def __init__(self, cwd, executive=None, filesystem=None): 46 def __init__(self, cwd, executive=None, filesystem=None):
46 self.cwd = cwd 47 self.cwd = cwd
47 self._executive = executive or Executive() 48 self._executive = executive or Executive()
48 self._filesystem = filesystem or FileSystem() 49 self._filesystem = filesystem or FileSystem()
49 self.checkout_root = self.find_checkout_root(self.cwd) 50 self.checkout_root = self.find_checkout_root(self.cwd)
50 51
51 # A wrapper used by subclasses to create processes. 52 # A wrapper used by subclasses to create processes.
52 def _run(self, args, cwd=None, input_func=None, error_handler=None, 53 def _run(self, args, cwd=None, input=None, error_handler=None, return_exit_c ode=False, return_stderr=True, decode_output=True):
53 return_exit_code=False, return_stderr=True, decode_output=True):
54 # FIXME: We should set cwd appropriately. 54 # FIXME: We should set cwd appropriately.
55 return self._executive.run_command(args, 55 return self._executive.run_command(args,
56 cwd=cwd, 56 cwd=cwd,
57 input_func=input_func, 57 input=input,
58 error_handler=error_handler, 58 error_handler=error_handler,
59 return_exit_code=return_exit_code, 59 return_exit_code=return_exit_code,
60 return_stderr=return_stderr, 60 return_stderr=return_stderr,
61 decode_output=decode_output) 61 decode_output=decode_output)
62 62
63 # SCM always returns repository relative path, but sometimes we need 63 # SCM always returns repository relative path, but sometimes we need
64 # absolute paths to pass to rm, etc. 64 # absolute paths to pass to rm, etc.
65 def absolute_path(self, repository_relative_path): 65 def absolute_path(self, repository_relative_path):
66 return self._filesystem.join(self.checkout_root, repository_relative_pat h) 66 return self._filesystem.join(self.checkout_root, repository_relative_pat h)
67 67
68 def _run_status_and_extract_filenames(self, status_command, status_regexp): 68 def _run_status_and_extract_filenames(self, status_command, status_regexp):
69 filenames = [] 69 filenames = []
70 # We run with cwd=self.checkout_root so that returned-paths are root-rel ative. 70 # We run with cwd=self.checkout_root so that returned-paths are root-rel ative.
71 for line in self._run(status_command, cwd=self.checkout_root).splitlines (): 71 for line in self._run(status_command, cwd=self.checkout_root).splitlines ():
72 match = re.search(status_regexp, line) 72 match = re.search(status_regexp, line)
73 if not match: 73 if not match:
74 continue 74 continue
75 # status = match.group('status') 75 # status = match.group('status')
76 filename = match.group('filename') 76 filename = match.group('filename')
77 filenames.append(filename) 77 filenames.append(filename)
78 return filenames 78 return filenames
79 79
80 @staticmethod 80 @staticmethod
81 def _subclass_must_implement(): 81 def _subclass_must_implement():
82 raise NotImplementedError("subclasses must implement") 82 raise NotImplementedError("subclasses must implement")
83 83
84 # Most methods here are abstract methods which don't use their arguments.
85 # FIXME: Merge Git and SCM and remove the abstract base methods.
86 # pylint: disable=unused-argument
87
88 @classmethod 84 @classmethod
89 def in_working_directory(cls, path, executive=None): 85 def in_working_directory(cls, path, executive=None):
90 SCM._subclass_must_implement() 86 SCM._subclass_must_implement()
91 87
92 def find_checkout_root(self, path): 88 def find_checkout_root(self, path):
93 SCM._subclass_must_implement() 89 SCM._subclass_must_implement()
94 90
95 def add(self, path, return_exit_code=False, recurse=True): 91 def add(self, path, return_exit_code=False, recurse=True):
96 self.add_list([path], return_exit_code, recurse) 92 self.add_list([path], return_exit_code, recurse)
97 93
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 #-------------------------------------------------------------------------- 134 #--------------------------------------------------------------------------
139 # Subclasses must indicate if they support local commits, 135 # Subclasses must indicate if they support local commits,
140 # but the SCM baseclass will only call local_commits methods when this is tr ue. 136 # but the SCM baseclass will only call local_commits methods when this is tr ue.
141 @staticmethod 137 @staticmethod
142 def supports_local_commits(): 138 def supports_local_commits():
143 SCM._subclass_must_implement() 139 SCM._subclass_must_implement()
144 140
145 def commit_locally_with_message(self, message): 141 def commit_locally_with_message(self, message):
146 _log.error("Your source control manager does not support local commits." ) 142 _log.error("Your source control manager does not support local commits." )
147 sys.exit(1) 143 sys.exit(1)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698