Commit 5e73b0cf authored by maruel@chromium.org's avatar maruel@chromium.org

Revert "Use a factory method to abstract SCMWrapper creation." totally broke gclient.

TBR=msb
TEST=none
BUG=none

Review URL: http://codereview.chromium.org/208028


git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@26606 0039d316-1c4b-4281-b951-d872f2087c98
parent 56237087
...@@ -554,7 +554,7 @@ class GClient(object): ...@@ -554,7 +554,7 @@ class GClient(object):
raise Error( raise Error(
"relative DEPS entry \"%s\" must begin with a slash" % d) "relative DEPS entry \"%s\" must begin with a slash" % d)
# Create a scm just to query the full url. # Create a scm just to query the full url.
scm = gclient_scm.create_scm(solution["url"], self._root_dir, scm = gclient_scm.SCMWrapper(solution["url"], self._root_dir,
None) None)
url = scm.FullUrlForRelativeUrl(url) url = scm.FullUrlForRelativeUrl(url)
if d in deps and deps[d] != url: if d in deps and deps[d] != url:
...@@ -671,7 +671,7 @@ class GClient(object): ...@@ -671,7 +671,7 @@ class GClient(object):
entries[name] = url entries[name] = url
if run_scm: if run_scm:
self._options.revision = revision_overrides.get(name) self._options.revision = revision_overrides.get(name)
scm = gclient_scm.create_scm(url, self._root_dir, name) scm = gclient_scm.SCMWrapper(url, self._root_dir, name)
scm.RunCommand(command, self._options, args, file_list) scm.RunCommand(command, self._options, args, file_list)
file_list = [os.path.join(name, file.strip()) for file in file_list] file_list = [os.path.join(name, file.strip()) for file in file_list]
self._options.revision = None self._options.revision = None
...@@ -697,7 +697,7 @@ class GClient(object): ...@@ -697,7 +697,7 @@ class GClient(object):
entries[d] = url entries[d] = url
if run_scm: if run_scm:
self._options.revision = revision_overrides.get(d) self._options.revision = revision_overrides.get(d)
scm = gclient_scm.create_scm(url, self._root_dir, d) scm = gclient_scm.SCMWrapper(url, self._root_dir, d)
scm.RunCommand(command, self._options, args, file_list) scm.RunCommand(command, self._options, args, file_list)
self._options.revision = None self._options.revision = None
...@@ -714,7 +714,7 @@ class GClient(object): ...@@ -714,7 +714,7 @@ class GClient(object):
entries[d] = url entries[d] = url
if run_scm: if run_scm:
self._options.revision = revision_overrides.get(d) self._options.revision = revision_overrides.get(d)
scm = gclient_scm.create_scm(url, self._root_dir, d) scm = gclient_scm.SCMWrapper(url, self._root_dir, d)
scm.RunCommand(command, self._options, args, file_list) scm.RunCommand(command, self._options, args, file_list)
self._options.revision = None self._options.revision = None
......
...@@ -27,31 +27,23 @@ SVN_COMMAND = "svn" ...@@ -27,31 +27,23 @@ SVN_COMMAND = "svn"
### SCM abstraction layer ### 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): class SCMWrapper(object):
"""Add necessary glue between all the supported SCM. """Add necessary glue between all the supported SCM.
This is the abstraction layer to bind to different SCM. Since currently only 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 subversion is supported, a lot of subersionism remains. This can be sorted out
once another SCM is supported.""" 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.scm_name = scm_name
self.url = url self.url = url
self._root_dir = root_dir.replace('/', os.sep) self._root_dir = root_dir
self.relpath = relpath.replace('/', os.sep) 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): def FullUrlForRelativeUrl(self, url):
# Find the forth '/' and strip from there. A bit hackish. # Find the forth '/' and strip from there. A bit hackish.
...@@ -62,21 +54,21 @@ class SCMWrapper(object): ...@@ -62,21 +54,21 @@ class SCMWrapper(object):
if file_list is None: if file_list is None:
file_list = [] file_list = []
commands = ['cleanup', 'export', 'update', 'revert', commands = {
'status', 'diff', 'pack', 'runhooks'] '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: if not command in commands:
raise gclient_utils.Error('Unknown command %s' % command) raise gclient_utils.Error('Unknown command %s' % command)
if not command in dir(self): return commands[command](options, args, file_list)
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 """
def cleanup(self, options, args, file_list): def cleanup(self, options, args, file_list):
"""Cleanup working copy.""" """Cleanup working copy."""
...@@ -266,9 +258,6 @@ class SVNWrapper(SCMWrapper): ...@@ -266,9 +258,6 @@ class SVNWrapper(SCMWrapper):
RunSVN(command + accumulated_paths, RunSVN(command + accumulated_paths,
os.path.join(self._root_dir, self.relpath)) 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): def status(self, options, args, file_list):
"""Display status information.""" """Display status information."""
path = os.path.join(self._root_dir, self.relpath) path = os.path.join(self._root_dir, self.relpath)
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment