| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """ | 6 """ |
| 7 Tool to perform checkouts in one easy command line! | 7 Tool to perform checkouts in one easy command line! |
| 8 | 8 |
| 9 Usage: | 9 Usage: |
| 10 fetch <recipe> [--property=value [--property2=value2 ...]] | 10 fetch <recipe> [--property=value [--property2=value2 ...]] |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 self.run_git( | 132 self.run_git( |
| 133 'config', '--add', 'remote.origin.fetch', | 133 'config', '--add', 'remote.origin.fetch', |
| 134 '+refs/tags/*:refs/tags/*', cwd=wd) | 134 '+refs/tags/*:refs/tags/*', cwd=wd) |
| 135 self.run_git('config', 'diff.ignoreSubmodules', 'all', cwd=wd) | 135 self.run_git('config', 'diff.ignoreSubmodules', 'all', cwd=wd) |
| 136 | 136 |
| 137 | 137 |
| 138 class GclientGitSvnCheckout(GclientGitCheckout, SvnCheckout): | 138 class GclientGitSvnCheckout(GclientGitCheckout, SvnCheckout): |
| 139 | 139 |
| 140 def __init__(self, options, spec, root): | 140 def __init__(self, options, spec, root): |
| 141 super(GclientGitSvnCheckout, self).__init__(options, spec, root) | 141 super(GclientGitSvnCheckout, self).__init__(options, spec, root) |
| 142 assert 'svn_url' in self.spec | |
| 143 assert 'svn_branch' in self.spec | |
| 144 assert 'svn_ref' in self.spec | |
| 145 | 142 |
| 146 def init(self): | 143 def init(self): |
| 147 # Ensure we are authenticated with subversion for all submodules. | 144 # Ensure we are authenticated with subversion for all submodules. |
| 148 git_svn_dirs = json.loads(self.spec.get('submodule_git_svn_spec', '{}')) | 145 git_svn_dirs = json.loads(self.spec.get('submodule_git_svn_spec', '{}')) |
| 149 git_svn_dirs.update({self.root: self.spec}) | 146 git_svn_dirs.update({self.root: self.spec}) |
| 150 for _, svn_spec in git_svn_dirs.iteritems(): | 147 for _, svn_spec in git_svn_dirs.iteritems(): |
| 151 try: | 148 if svn_spec.get('svn_url'): |
| 152 self.run_svn('ls', '--non-interactive', svn_spec['svn_url']) | 149 try: |
| 153 except subprocess.CalledProcessError: | 150 self.run_svn('ls', '--non-interactive', svn_spec['svn_url']) |
| 154 print 'Please run `svn ls %s`' % svn_spec['svn_url'] | 151 except subprocess.CalledProcessError: |
| 155 return 1 | 152 print 'Please run `svn ls %s`' % svn_spec['svn_url'] |
| 153 return 1 |
| 156 | 154 |
| 157 super(GclientGitSvnCheckout, self).init() | 155 super(GclientGitSvnCheckout, self).init() |
| 158 | 156 |
| 159 # Configure git-svn. | 157 # Configure git-svn. |
| 160 for path, svn_spec in git_svn_dirs.iteritems(): | 158 for path, svn_spec in git_svn_dirs.iteritems(): |
| 161 real_path = os.path.join(*path.split('/')) | 159 real_path = os.path.join(*path.split('/')) |
| 162 if real_path != self.root: | 160 if real_path != self.root: |
| 163 real_path = os.path.join(self.root, real_path) | 161 real_path = os.path.join(self.root, real_path) |
| 164 wd = os.path.join(self.base, real_path) | 162 wd = os.path.join(self.base, real_path) |
| 165 if self.options.dry_run: | 163 if self.options.dry_run: |
| 166 print 'cd %s' % wd | 164 print 'cd %s' % wd |
| 167 prefix = svn_spec.get('svn_prefix', 'origin/') | 165 if svn_spec.get('auto'): |
| 168 self.run_git('svn', 'init', '--prefix=' + prefix, '-T', | 166 self.run_git('auto-svn', cwd=wd) |
| 169 svn_spec['svn_branch'], svn_spec['svn_url'], cwd=wd) | 167 continue |
| 170 self.run_git('config', '--replace', 'svn-remote.svn.fetch', | 168 self.run_git('svn', 'init', svn_spec['svn_url'], cwd=wd) |
| 171 svn_spec['svn_branch'] + ':refs/remotes/' + prefix + | 169 self.run_git('config', '--unset-all', 'svn-remote.svn.fetch', cwd=wd) |
| 172 svn_spec['svn_ref'], cwd=wd) | 170 for svn_branch, git_ref in svn_spec.get('git_svn_fetch', {}).items(): |
| 171 self.run_git('config', '--add', 'svn-remote.svn.fetch', |
| 172 '%s:%s' % (svn_branch, git_ref), cwd=wd) |
| 173 for svn_branch, git_ref in svn_spec.get('git_svn_branches', {}).items(): |
| 174 self.run_git('config', '--add', 'svn-remote.svn.branches', |
| 175 '%s:%s' % (svn_branch, git_ref), cwd=wd) |
| 173 self.run_git('svn', 'fetch', cwd=wd) | 176 self.run_git('svn', 'fetch', cwd=wd) |
| 174 | 177 |
| 175 | 178 |
| 176 | 179 |
| 177 CHECKOUT_TYPE_MAP = { | 180 CHECKOUT_TYPE_MAP = { |
| 178 'gclient': GclientCheckout, | 181 'gclient': GclientCheckout, |
| 179 'gclient_git': GclientGitCheckout, | 182 'gclient_git': GclientGitCheckout, |
| 180 'gclient_git_svn': GclientGitSvnCheckout, | 183 'gclient_git_svn': GclientGitSvnCheckout, |
| 181 'git': GitCheckout, | 184 'git': GitCheckout, |
| 182 } | 185 } |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 311 |
| 309 | 312 |
| 310 def main(): | 313 def main(): |
| 311 options, recipe, props = handle_args(sys.argv) | 314 options, recipe, props = handle_args(sys.argv) |
| 312 spec, root = run_recipe_fetch(recipe, props) | 315 spec, root = run_recipe_fetch(recipe, props) |
| 313 return run(options, spec, root) | 316 return run(options, spec, root) |
| 314 | 317 |
| 315 | 318 |
| 316 if __name__ == '__main__': | 319 if __name__ == '__main__': |
| 317 sys.exit(main()) | 320 sys.exit(main()) |
| OLD | NEW |