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

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

Issue 2130093003: Fix pylint warnings in webkitpy/common/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased 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
38 from webkitpy.common.system.filesystem import FileSystem 37 from webkitpy.common.system.filesystem import FileSystem
39 38
40 _log = logging.getLogger(__name__) 39 _log = logging.getLogger(__name__)
41 40
42 41
43 # SCM methods are expected to return paths relative to self.checkout_root. 42 # SCM methods are expected to return paths relative to self.checkout_root.
44 class SCM: 43 class SCM(object):
45 44
46 def __init__(self, cwd, executive=None, filesystem=None): 45 def __init__(self, cwd, executive=None, filesystem=None):
47 self.cwd = cwd 46 self.cwd = cwd
48 self._executive = executive or Executive() 47 self._executive = executive or Executive()
49 self._filesystem = filesystem or FileSystem() 48 self._filesystem = filesystem or FileSystem()
50 self.checkout_root = self.find_checkout_root(self.cwd) 49 self.checkout_root = self.find_checkout_root(self.cwd)
51 50
52 # A wrapper used by subclasses to create processes. 51 # A wrapper used by subclasses to create processes.
53 def _run(self, args, cwd=None, input=None, error_handler=None, return_exit_c ode=False, return_stderr=True, decode_output=True): 52 def _run(self, args, cwd=None, input_func=None, error_handler=None,
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=input, 57 input_func=input_func,
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
84 @classmethod 88 @classmethod
85 def in_working_directory(cls, path, executive=None): 89 def in_working_directory(cls, path, executive=None):
86 SCM._subclass_must_implement() 90 SCM._subclass_must_implement()
87 91
88 def find_checkout_root(self, path): 92 def find_checkout_root(self, path):
89 SCM._subclass_must_implement() 93 SCM._subclass_must_implement()
90 94
91 def add(self, path, return_exit_code=False, recurse=True): 95 def add(self, path, return_exit_code=False, recurse=True):
92 self.add_list([path], return_exit_code, recurse) 96 self.add_list([path], return_exit_code, recurse)
93 97
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 #-------------------------------------------------------------------------- 138 #--------------------------------------------------------------------------
135 # Subclasses must indicate if they support local commits, 139 # Subclasses must indicate if they support local commits,
136 # but the SCM baseclass will only call local_commits methods when this is tr ue. 140 # but the SCM baseclass will only call local_commits methods when this is tr ue.
137 @staticmethod 141 @staticmethod
138 def supports_local_commits(): 142 def supports_local_commits():
139 SCM._subclass_must_implement() 143 SCM._subclass_must_implement()
140 144
141 def commit_locally_with_message(self, message): 145 def commit_locally_with_message(self, message):
142 _log.error("Your source control manager does not support local commits." ) 146 _log.error("Your source control manager does not support local commits." )
143 sys.exit(1) 147 sys.exit(1)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698