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

Unified Diff: gclient_scm.py

Issue 208028: Revert "Use a factory method to abstract SCMWrapper creation." totally broke gclient. (Closed)
Patch Set: Created 11 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gclient.py ('k') | tests/gclient_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gclient_scm.py
diff --git a/gclient_scm.py b/gclient_scm.py
index 43eaca772c3a9433d15a5e9e3d1504ce9a1cd175..148855c89ffc597d645314df55274da19909f303 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -27,31 +27,23 @@ SVN_COMMAND = "svn"
### SCM abstraction layer
-# Factory Method for SCM wrapper creation
-
-def create_scm(url, root_dir, relpath, scm_name='svn'):
- # TODO(maruel): Deduce the SCM from the url.
- scm_map = {
- 'svn' : SVNWrapper,
- }
- if not scm_name in scm_map:
- raise gclient_utils.Error('Unsupported scm %s' % scm_name)
- return scm_map[scm_name](url, root_dir, relpath, scm_name)
-
-
-# SCMWrapper base class
-
class SCMWrapper(object):
"""Add necessary glue between all the supported SCM.
This is the abstraction layer to bind to different SCM. Since currently only
subversion is supported, a lot of subersionism remains. This can be sorted out
once another SCM is supported."""
- def __init__(self, url, root_dir, relpath, scm_name='svn'):
+ def __init__(self, url=None, root_dir=None, relpath=None,
+ scm_name='svn'):
+ # TODO(maruel): Deduce the SCM from the url.
self.scm_name = scm_name
self.url = url
- self._root_dir = root_dir.replace('/', os.sep)
- self.relpath = relpath.replace('/', os.sep)
+ self._root_dir = root_dir
+ if self._root_dir:
+ self._root_dir = self._root_dir.replace('/', os.sep)
+ self.relpath = relpath
+ if self.relpath:
+ self.relpath = self.relpath.replace('/', os.sep)
def FullUrlForRelativeUrl(self, url):
# Find the forth '/' and strip from there. A bit hackish.
@@ -62,21 +54,21 @@ class SCMWrapper(object):
if file_list is None:
file_list = []
- commands = ['cleanup', 'export', 'update', 'revert',
- 'status', 'diff', 'pack', 'runhooks']
+ commands = {
+ 'cleanup': self.cleanup,
+ 'export': self.export,
+ 'update': self.update,
+ 'revert': self.revert,
+ 'status': self.status,
+ 'diff': self.diff,
+ 'pack': self.pack,
+ 'runhooks': self.status,
+ }
if not command in commands:
raise gclient_utils.Error('Unknown command %s' % command)
- if not command in dir(self):
- raise gclient_utils.Error('Command %s not implemnted in %s wrapper' % (
- command, self.scm_name))
-
- return getattr(self, command)(options, args, file_list)
-
-
-class SVNWrapper(SCMWrapper):
- """ Wrapper for SVN """
+ return commands[command](options, args, file_list)
def cleanup(self, options, args, file_list):
"""Cleanup working copy."""
@@ -266,9 +258,6 @@ class SVNWrapper(SCMWrapper):
RunSVN(command + accumulated_paths,
os.path.join(self._root_dir, self.relpath))
- def runhooks(self, options, args, file_list):
- self.status(options, args, file_list)
-
def status(self, options, args, file_list):
"""Display status information."""
path = os.path.join(self._root_dir, self.relpath)
« no previous file with comments | « gclient.py ('k') | tests/gclient_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698