Chromium Code Reviews| Index: fetch.py |
| diff --git a/fetch.py b/fetch.py |
| index 80dcce9a2f13a0e7aeefaf8871298a7737154af3..bf86fcef310a3fb3bf194b14dbdebb24711496e7 100755 |
| --- a/fetch.py |
| +++ b/fetch.py |
| @@ -66,6 +66,9 @@ class GclientCheckout(Checkout): |
| (sys.executable, os.path.join(SCRIPT_PATH, 'gclient.py')) + cmd, |
| **kwargs) |
| + def exists(self): |
|
Dirk Pranke
2013/04/06 01:45:25
I know this name was already chosen, but it's not
|
| + return os.path.exists(os.path.join(os.getcwd(), self.root)) |
|
iannucci
2013/04/06 01:38:18
Let's make self.root abspath from the initial set.
|
| + |
| class GitCheckout(Checkout): |
| @@ -83,6 +86,35 @@ class SvnCheckout(Checkout): |
| return subprocess.check_call(('svn',) + cmd, **kwargs) |
| +class GclientGitCheckout(GclientCheckout, GitCheckout): |
| + |
| + def __init__(self, dryrun, spec, root): |
| + super(GclientGitCheckout, self).__init__(dryrun, spec, root) |
| + assert 'solutions' in self.spec |
| + keys = ['solutions', 'target_os', 'target_os_only'] |
| + gclient_spec = '\n'.join('%s = %s' % (key, self.spec[key]) |
| + for key in self.spec if key in keys) |
|
iannucci
2013/04/06 01:38:18
This should be a function (spec'ifying a dict).
|
| + self.spec['gclient_spec'] = gclient_spec |
| + |
| + def init(self): |
|
iannucci
2013/04/06 01:38:18
This should call super.
|
| + # TODO(dpranke): Work around issues w/ delta compression on big repos. |
| + self.run_git('config', '--global', 'core.deltaBaseCacheLimit', '1G') |
|
iannucci
2013/04/06 01:38:18
*grumble*
|
| + |
| + # Configure and do the gclient checkout. |
| + self.run_gclient('config', '--spec', self.spec['gclient_spec']) |
| + self.run_gclient('sync') |
| + |
| + # Configure git. |
| + wd = os.path.join(self.base, self.root) |
| + if self.dryrun: |
| + print 'cd %s' % wd |
| + self.run_git( |
|
iannucci
2013/04/06 01:38:18
run_git should print cwd on dryrun... don't need t
|
| + 'submodule', 'foreach', |
| + 'git config -f $toplevel/.git/config submodule.$name.ignore all', |
| + cwd=wd) |
| + self.run_git('config', 'diff.ignoreSubmodules', 'all', cwd=wd) |
| + |
| + |
| class GclientGitSvnCheckout(GclientCheckout, GitCheckout, SvnCheckout): |
|
Dirk Pranke
2013/04/06 01:45:25
Should this inherit from GclientGitCheckout instea
|
| def __init__(self, dryrun, spec, root): |
| @@ -96,20 +128,7 @@ class GclientGitSvnCheckout(GclientCheckout, GitCheckout, SvnCheckout): |
| assert 'svn_branch' in self.spec |
| assert 'svn_ref' in self.spec |
| - def exists(self): |
| - return os.path.exists(os.path.join(os.getcwd(), self.root)) |
| - |
| def init(self): |
| - # Ensure we are authenticated with subversion for all submodules. |
| - git_svn_dirs = json.loads(self.spec.get('submodule_git_svn_spec', '{}')) |
| - git_svn_dirs.update({self.root: self.spec}) |
| - for _, svn_spec in git_svn_dirs.iteritems(): |
| - try: |
| - self.run_svn('ls', '--non-interactive', svn_spec['svn_url']) |
| - except subprocess.CalledProcessError: |
| - print 'Please run `svn ls %s`' % svn_spec['svn_url'] |
| - return 1 |
| - |
| # TODO(dpranke): Work around issues w/ delta compression on big repos. |
| self.run_git('config', '--global', 'core.deltaBaseCacheLimit', '1G') |
| @@ -128,6 +147,8 @@ class GclientGitSvnCheckout(GclientCheckout, GitCheckout, SvnCheckout): |
| self.run_git('config', 'diff.ignoreSubmodules', 'all', cwd=wd) |
|
iannucci
2013/04/06 01:38:18
This should be a call to super
|
| # Configure git-svn. |
| + git_svn_dirs = json.loads(self.spec.get('submodule_git_svn_spec', '{}')) |
| + git_svn_dirs.update({self.root: self.spec}) |
| for path, svn_spec in git_svn_dirs.iteritems(): |
| real_path = os.path.join(*path.split('/')) |
| if real_path != self.root: |
| @@ -143,9 +164,9 @@ class GclientGitSvnCheckout(GclientCheckout, GitCheckout, SvnCheckout): |
| self.run_git('svn', 'fetch', cwd=wd) |
| - |
| CHECKOUT_TYPE_MAP = { |
| 'gclient': GclientCheckout, |
| + 'gclient_git': GclientGitCheckout, |
| 'gclient_git_svn': GclientGitSvnCheckout, |
| 'git': GitCheckout, |
| } |