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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 def exists(self): | 89 def exists(self): |
90 return os.path.exists(os.path.join(os.getcwd(), self.root)) | 90 return os.path.exists(os.path.join(os.getcwd(), self.root)) |
91 | 91 |
92 def init(self): | 92 def init(self): |
93 # Configure and do the gclient checkout. | 93 # Configure and do the gclient checkout. |
94 self.run_gclient('config', '--spec', self.spec['gclient_spec']) | 94 self.run_gclient('config', '--spec', self.spec['gclient_spec']) |
95 self.run_gclient('sync') | 95 self.run_gclient('sync') |
96 | 96 |
97 # Configure git. | 97 # Configure git. |
98 wd = os.path.join(self.base, self.root) | 98 wd = os.path.join(self.base, self.root) |
| 99 if self.dryrun: |
| 100 print "cd %s" % wd |
99 self.run_git( | 101 self.run_git( |
100 'submodule', 'foreach', | 102 'submodule', 'foreach', |
101 'git config -f $toplevel/.git/config submodule.$name.ignore all', | 103 'git config -f $toplevel/.git/config submodule.$name.ignore all', |
102 cwd=wd) | 104 cwd=wd) |
103 self.run_git('config', 'diff.ignoreSubmodules', 'all', cwd=wd) | 105 self.run_git('config', 'diff.ignoreSubmodules', 'all', cwd=wd) |
104 | 106 |
105 # Configure git-svn. | 107 # Configure git-svn. |
106 self.run_git('svn', 'init', '--prefix=origin/', '-T', | 108 self.run_git('svn', 'init', '--prefix=origin/', '-T', |
107 self.spec['svn_branch'], self.spec['svn_url'], cwd=wd) | 109 self.spec['svn_branch'], self.spec['svn_url'], cwd=wd) |
108 self.run_git('config', 'svn-remote.svn.fetch', self.spec['svn_branch'] + | 110 self.run_git('config', 'svn-remote.svn.fetch', self.spec['svn_branch'] + |
109 ':refs/remotes/origin/' + self.spec['svn_ref'], cwd=wd) | 111 ':refs/remotes/origin/' + self.spec['svn_ref'], cwd=wd) |
110 self.run_git('svn', 'fetch', cwd=wd) | 112 self.run_git('svn', 'fetch', cwd=wd) |
111 | 113 |
112 # Configure git-svn submodules, if any. | 114 # Configure git-svn submodules, if any. |
113 submodules = json.loads(self.spec.get('submodule_git_svn_spec', '{}')) | 115 submodules = json.loads(self.spec.get('submodule_git_svn_spec', '{}')) |
114 for path, subspec in submodules.iteritems(): | 116 for path, subspec in submodules.iteritems(): |
115 subspec = submodules[path] | 117 subspec = submodules[path] |
116 ospath = os.path.join(*path.split('/')) | 118 ospath = os.path.join(*path.split('/')) |
117 wd = os.path.join(self.base, self.root, ospath) | 119 wd = os.path.join(self.base, self.root, ospath) |
| 120 if self.dryrun: |
| 121 print "cd %s" % wd |
118 self.run_git('svn', 'init', '--prefix=origin/', '-T', | 122 self.run_git('svn', 'init', '--prefix=origin/', '-T', |
119 subspec['svn_branch'], subspec['svn_url'], cwd=wd) | 123 subspec['svn_branch'], subspec['svn_url'], cwd=wd) |
120 self.run_git('config', '--replace', 'svn-remote.svn.fetch', | 124 self.run_git('config', '--replace', 'svn-remote.svn.fetch', |
121 subspec['svn_branch'] + ':refs/remotes/origin/' + | 125 subspec['svn_branch'] + ':refs/remotes/origin/' + |
122 subspec['svn_ref'], cwd=wd) | 126 subspec['svn_ref'], cwd=wd) |
123 self.run_git('svn', 'fetch', cwd=wd) | 127 self.run_git('svn', 'fetch', cwd=wd) |
124 | 128 |
125 | 129 |
126 CHECKOUT_TYPE_MAP = { | 130 CHECKOUT_TYPE_MAP = { |
127 'gclient': GclientCheckout, | 131 'gclient': GclientCheckout, |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 228 |
225 | 229 |
226 def main(): | 230 def main(): |
227 dryrun, recipe, props = handle_args(sys.argv) | 231 dryrun, recipe, props = handle_args(sys.argv) |
228 spec, root = run_recipe_fetch(recipe, props) | 232 spec, root = run_recipe_fetch(recipe, props) |
229 return run(dryrun, spec, root) | 233 return run(dryrun, spec, root) |
230 | 234 |
231 | 235 |
232 if __name__ == '__main__': | 236 if __name__ == '__main__': |
233 sys.exit(main()) | 237 sys.exit(main()) |
OLD | NEW |