summaryrefslogtreecommitdiffstats
path: root/subcmds/init.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/init.py')
-rw-r--r--subcmds/init.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/subcmds/init.py b/subcmds/init.py
index 45d69b79..eeddca06 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -17,7 +17,6 @@ from __future__ import print_function
17import os 17import os
18import platform 18import platform
19import re 19import re
20import shutil
21import sys 20import sys
22 21
23from pyversion import is_python3 22from pyversion import is_python3
@@ -35,6 +34,7 @@ from error import ManifestParseError
35from project import SyncBuffer 34from project import SyncBuffer
36from git_config import GitConfig 35from git_config import GitConfig
37from git_command import git_require, MIN_GIT_VERSION 36from git_command import git_require, MIN_GIT_VERSION
37import platform_utils
38 38
39class Init(InteractiveCommand, MirrorSafeCommand): 39class Init(InteractiveCommand, MirrorSafeCommand):
40 common = True 40 common = True
@@ -91,6 +91,9 @@ to update the working directory files.
91 g.add_option('-b', '--manifest-branch', 91 g.add_option('-b', '--manifest-branch',
92 dest='manifest_branch', 92 dest='manifest_branch',
93 help='manifest branch or revision', metavar='REVISION') 93 help='manifest branch or revision', metavar='REVISION')
94 g.add_option('-c', '--current-branch',
95 dest='current_branch_only', action='store_true',
96 help='fetch only current manifest branch from server')
94 g.add_option('-m', '--manifest-name', 97 g.add_option('-m', '--manifest-name',
95 dest='manifest_name', default='default.xml', 98 dest='manifest_name', default='default.xml',
96 help='initial manifest file', metavar='NAME.xml') 99 help='initial manifest file', metavar='NAME.xml')
@@ -108,6 +111,9 @@ to update the working directory files.
108 dest='archive', action='store_true', 111 dest='archive', action='store_true',
109 help='checkout an archive instead of a git repository for ' 112 help='checkout an archive instead of a git repository for '
110 'each project. See git archive.') 113 'each project. See git archive.')
114 g.add_option('--submodules',
115 dest='submodules', action='store_true',
116 help='sync any submodules associated with the manifest repo')
111 g.add_option('-g', '--groups', 117 g.add_option('-g', '--groups',
112 dest='groups', default='default', 118 dest='groups', default='default',
113 help='restrict manifest projects to ones with specified ' 119 help='restrict manifest projects to ones with specified '
@@ -121,6 +127,9 @@ to update the working directory files.
121 g.add_option('--no-clone-bundle', 127 g.add_option('--no-clone-bundle',
122 dest='no_clone_bundle', action='store_true', 128 dest='no_clone_bundle', action='store_true',
123 help='disable use of /clone.bundle on HTTP/HTTPS') 129 help='disable use of /clone.bundle on HTTP/HTTPS')
130 g.add_option('--no-tags',
131 dest='no_tags', action='store_true',
132 help="don't fetch tags in the manifest")
124 133
125 # Tool 134 # Tool
126 g = p.add_option_group('repo Version options') 135 g = p.add_option_group('repo Version options')
@@ -230,22 +239,27 @@ to update the working directory files.
230 'in another location.', file=sys.stderr) 239 'in another location.', file=sys.stderr)
231 sys.exit(1) 240 sys.exit(1)
232 241
242 if opt.submodules:
243 m.config.SetString('repo.submodules', 'true')
244
233 if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet, 245 if not m.Sync_NetworkHalf(is_new=is_new, quiet=opt.quiet,
234 clone_bundle=not opt.no_clone_bundle): 246 clone_bundle=not opt.no_clone_bundle,
247 current_branch_only=opt.current_branch_only,
248 no_tags=opt.no_tags, submodules=opt.submodules):
235 r = m.GetRemote(m.remote.name) 249 r = m.GetRemote(m.remote.name)
236 print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr) 250 print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr)
237 251
238 # Better delete the manifest git dir if we created it; otherwise next 252 # Better delete the manifest git dir if we created it; otherwise next
239 # time (when user fixes problems) we won't go through the "is_new" logic. 253 # time (when user fixes problems) we won't go through the "is_new" logic.
240 if is_new: 254 if is_new:
241 shutil.rmtree(m.gitdir) 255 platform_utils.rmtree(m.gitdir)
242 sys.exit(1) 256 sys.exit(1)
243 257
244 if opt.manifest_branch: 258 if opt.manifest_branch:
245 m.MetaBranchSwitch() 259 m.MetaBranchSwitch(submodules=opt.submodules)
246 260
247 syncbuf = SyncBuffer(m.config) 261 syncbuf = SyncBuffer(m.config)
248 m.Sync_LocalHalf(syncbuf) 262 m.Sync_LocalHalf(syncbuf, submodules=opt.submodules)
249 syncbuf.Finish() 263 syncbuf.Finish()
250 264
251 if is_new or m.CurrentBranch is None: 265 if is_new or m.CurrentBranch is None:
@@ -387,7 +401,7 @@ to update the working directory files.
387 git_require(MIN_GIT_VERSION, fail=True) 401 git_require(MIN_GIT_VERSION, fail=True)
388 402
389 if opt.reference: 403 if opt.reference:
390 opt.reference = os.path.expanduser(opt.reference) 404 opt.reference = os.path.abspath(os.path.expanduser(opt.reference))
391 405
392 # Check this here, else manifest will be tagged "not new" and init won't be 406 # Check this here, else manifest will be tagged "not new" and init won't be
393 # possible anymore without removing the .repo/manifests directory. 407 # possible anymore without removing the .repo/manifests directory.