| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 gclient_spec = '\n'.join('%s = %s' % (key, self.spec[key]) | 104 gclient_spec = '\n'.join('%s = %s' % (key, self.spec[key]) |
| 105 for key in keys if key in self.spec) | 105 for key in keys if key in self.spec) |
| 106 self.spec['gclient_spec'] = gclient_spec | 106 self.spec['gclient_spec'] = gclient_spec |
| 107 | 107 |
| 108 def exists(self): | 108 def exists(self): |
| 109 return os.path.exists(os.path.join(os.getcwd(), self.root)) | 109 return os.path.exists(os.path.join(os.getcwd(), self.root)) |
| 110 | 110 |
| 111 def init(self): | 111 def init(self): |
| 112 # Configure and do the gclient checkout. | 112 # Configure and do the gclient checkout. |
| 113 self.run_gclient('config', '--spec', self.spec['gclient_spec']) | 113 self.run_gclient('config', '--spec', self.spec['gclient_spec']) |
| 114 sync_cmd = ['sync'] |
| 114 if self.options.nohooks: | 115 if self.options.nohooks: |
| 115 self.run_gclient('sync', '--nohooks') | 116 sync_cmd.append('--nohooks') |
| 116 else: | 117 if self.spec.get('with_branch_heads', False): |
| 117 self.run_gclient('sync') | 118 sync_cmd.append('--with_branch_heads') |
| 119 self.run_gclient(*sync_cmd) |
| 118 | 120 |
| 119 # Configure git. | 121 # Configure git. |
| 120 wd = os.path.join(self.base, self.root) | 122 wd = os.path.join(self.base, self.root) |
| 121 if self.options.dry_run: | 123 if self.options.dry_run: |
| 122 print 'cd %s' % wd | 124 print 'cd %s' % wd |
| 123 self.run_git( | 125 self.run_git( |
| 124 'submodule', 'foreach', | 126 'submodule', 'foreach', |
| 125 'git config -f $toplevel/.git/config submodule.$name.ignore all', | 127 'git config -f $toplevel/.git/config submodule.$name.ignore all', |
| 126 cwd=wd) | 128 cwd=wd) |
| 127 self.run_git( | 129 self.run_git( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 152 super(GclientGitSvnCheckout, self).init() | 154 super(GclientGitSvnCheckout, self).init() |
| 153 | 155 |
| 154 # Configure git-svn. | 156 # Configure git-svn. |
| 155 for path, svn_spec in git_svn_dirs.iteritems(): | 157 for path, svn_spec in git_svn_dirs.iteritems(): |
| 156 real_path = os.path.join(*path.split('/')) | 158 real_path = os.path.join(*path.split('/')) |
| 157 if real_path != self.root: | 159 if real_path != self.root: |
| 158 real_path = os.path.join(self.root, real_path) | 160 real_path = os.path.join(self.root, real_path) |
| 159 wd = os.path.join(self.base, real_path) | 161 wd = os.path.join(self.base, real_path) |
| 160 if self.options.dry_run: | 162 if self.options.dry_run: |
| 161 print 'cd %s' % wd | 163 print 'cd %s' % wd |
| 162 self.run_git('svn', 'init', '--prefix=origin/', '-T', | 164 prefix = svn_spec.get('svn_prefix', 'origin/') |
| 165 self.run_git('svn', 'init', '--prefix=' + prefix, '-T', |
| 163 svn_spec['svn_branch'], svn_spec['svn_url'], cwd=wd) | 166 svn_spec['svn_branch'], svn_spec['svn_url'], cwd=wd) |
| 164 self.run_git('config', '--replace', 'svn-remote.svn.fetch', | 167 self.run_git('config', '--replace', 'svn-remote.svn.fetch', |
| 165 svn_spec['svn_branch'] + ':refs/remotes/origin/' + | 168 svn_spec['svn_branch'] + ':refs/remotes/' + prefix + |
| 166 svn_spec['svn_ref'], cwd=wd) | 169 svn_spec['svn_ref'], cwd=wd) |
| 167 self.run_git('svn', 'fetch', cwd=wd) | 170 self.run_git('svn', 'fetch', cwd=wd) |
| 168 | 171 |
| 169 | 172 |
| 170 | 173 |
| 171 CHECKOUT_TYPE_MAP = { | 174 CHECKOUT_TYPE_MAP = { |
| 172 'gclient': GclientCheckout, | 175 'gclient': GclientCheckout, |
| 173 'gclient_git': GclientGitCheckout, | 176 'gclient_git': GclientGitCheckout, |
| 174 'gclient_git_svn': GclientGitSvnCheckout, | 177 'gclient_git_svn': GclientGitSvnCheckout, |
| 175 'git': GitCheckout, | 178 'git': GitCheckout, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 293 |
| 291 | 294 |
| 292 def main(): | 295 def main(): |
| 293 options, recipe, props = handle_args(sys.argv) | 296 options, recipe, props = handle_args(sys.argv) |
| 294 spec, root = run_recipe_fetch(recipe, props) | 297 spec, root = run_recipe_fetch(recipe, props) |
| 295 return run(options, spec, root) | 298 return run(options, spec, root) |
| 296 | 299 |
| 297 | 300 |
| 298 if __name__ == '__main__': | 301 if __name__ == '__main__': |
| 299 sys.exit(main()) | 302 sys.exit(main()) |
| OLD | NEW |