summaryrefslogtreecommitdiffstats
path: root/subcmds/init.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/init.py')
-rw-r--r--subcmds/init.py30
1 files changed, 26 insertions, 4 deletions
diff --git a/subcmds/init.py b/subcmds/init.py
index 11312601..a44fb7a9 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -20,6 +20,15 @@ import re
20import shutil 20import shutil
21import sys 21import sys
22 22
23from pyversion import is_python3
24if is_python3():
25 import urllib.parse
26else:
27 import imp
28 import urlparse
29 urllib = imp.new_module('urllib')
30 urllib.parse = urlparse.urlparse
31
23from color import Coloring 32from color import Coloring
24from command import InteractiveCommand, MirrorSafeCommand 33from command import InteractiveCommand, MirrorSafeCommand
25from error import ManifestParseError 34from error import ManifestParseError
@@ -91,8 +100,9 @@ to update the working directory files.
91 dest='depth', 100 dest='depth',
92 help='create a shallow clone with given depth; see git clone') 101 help='create a shallow clone with given depth; see git clone')
93 g.add_option('-g', '--groups', 102 g.add_option('-g', '--groups',
94 dest='groups', default='all,-notdefault', 103 dest='groups', default='default',
95 help='restrict manifest projects to ones with a specified group', 104 help='restrict manifest projects to ones with specified '
105 'group(s) [default|all|G1,G2,G3|G4,-G5,-G6]',
96 metavar='GROUP') 106 metavar='GROUP')
97 g.add_option('-p', '--platform', 107 g.add_option('-p', '--platform',
98 dest='platform', default='auto', 108 dest='platform', default='auto',
@@ -134,7 +144,19 @@ to update the working directory files.
134 if not opt.quiet: 144 if not opt.quiet:
135 print('Get %s' % GitConfig.ForUser().UrlInsteadOf(opt.manifest_url), 145 print('Get %s' % GitConfig.ForUser().UrlInsteadOf(opt.manifest_url),
136 file=sys.stderr) 146 file=sys.stderr)
137 m._InitGitDir() 147
148 # The manifest project object doesn't keep track of the path on the
149 # server where this git is located, so let's save that here.
150 mirrored_manifest_git = None
151 if opt.reference:
152 manifest_git_path = urllib.parse(opt.manifest_url).path[1:]
153 mirrored_manifest_git = os.path.join(opt.reference, manifest_git_path)
154 if not mirrored_manifest_git.endswith(".git"):
155 mirrored_manifest_git += ".git"
156 if not os.path.exists(mirrored_manifest_git):
157 mirrored_manifest_git = os.path.join(opt.reference + '/.repo/manifests.git')
158
159 m._InitGitDir(mirror_git=mirrored_manifest_git)
138 160
139 if opt.manifest_branch: 161 if opt.manifest_branch:
140 m.revisionExpr = opt.manifest_branch 162 m.revisionExpr = opt.manifest_branch
@@ -169,7 +191,7 @@ to update the working directory files.
169 191
170 groups = [x for x in groups if x] 192 groups = [x for x in groups if x]
171 groupstr = ','.join(groups) 193 groupstr = ','.join(groups)
172 if opt.platform == 'auto' and groupstr == 'all,-notdefault,platform-' + platform.system().lower(): 194 if opt.platform == 'auto' and groupstr == 'default,platform-' + platform.system().lower():
173 groupstr = None 195 groupstr = None
174 m.config.SetString('manifest.groups', groupstr) 196 m.config.SetString('manifest.groups', groupstr)
175 197