summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
Diffstat (limited to 'project.py')
-rw-r--r--project.py108
1 files changed, 91 insertions, 17 deletions
diff --git a/project.py b/project.py
index 43cac88c..2989e09d 100644
--- a/project.py
+++ b/project.py
@@ -16,6 +16,7 @@ import errno
16import filecmp 16import filecmp
17import glob 17import glob
18import os 18import os
19import platform
19import random 20import random
20import re 21import re
21import shutil 22import shutil
@@ -1162,7 +1163,7 @@ class Project(object):
1162 if self.clone_depth: 1163 if self.clone_depth:
1163 depth = self.clone_depth 1164 depth = self.clone_depth
1164 else: 1165 else:
1165 depth = self.manifest.manifestProject.config.GetString('repo.depth') 1166 depth = self.manifest.manifestProject.depth
1166 1167
1167 # See if we can skip the network fetch entirely. 1168 # See if we can skip the network fetch entirely.
1168 if not (optimized_fetch and 1169 if not (optimized_fetch and
@@ -1179,7 +1180,7 @@ class Project(object):
1179 return False 1180 return False
1180 1181
1181 mp = self.manifest.manifestProject 1182 mp = self.manifest.manifestProject
1182 dissociate = mp.config.GetBoolean('repo.dissociate') 1183 dissociate = mp.dissociate
1183 if dissociate: 1184 if dissociate:
1184 alternates_file = os.path.join(self.objdir, 'objects/info/alternates') 1185 alternates_file = os.path.join(self.objdir, 'objects/info/alternates')
1185 if os.path.exists(alternates_file): 1186 if os.path.exists(alternates_file):
@@ -2282,9 +2283,7 @@ class Project(object):
2282 return ok 2283 return ok
2283 2284
2284 def _ApplyCloneBundle(self, initial=False, quiet=False, verbose=False): 2285 def _ApplyCloneBundle(self, initial=False, quiet=False, verbose=False):
2285 if initial and \ 2286 if initial and (self.manifest.manifestProject.depth or self.clone_depth):
2286 (self.manifest.manifestProject.config.GetString('repo.depth') or
2287 self.clone_depth):
2288 return False 2287 return False
2289 2288
2290 remote = self.GetRemote(self.remote.name) 2289 remote = self.GetRemote(self.remote.name)
@@ -2513,7 +2512,7 @@ class Project(object):
2513 2512
2514 if init_git_dir: 2513 if init_git_dir:
2515 mp = self.manifest.manifestProject 2514 mp = self.manifest.manifestProject
2516 ref_dir = mp.config.GetString('repo.reference') or '' 2515 ref_dir = mp.reference or ''
2517 2516
2518 def _expanded_ref_dirs(): 2517 def _expanded_ref_dirs():
2519 """Iterate through the possible git reference directory paths.""" 2518 """Iterate through the possible git reference directory paths."""
@@ -3359,17 +3358,92 @@ class ManifestProject(MetaProject):
3359 capture_stderr=True).Wait() == 0 3358 capture_stderr=True).Wait() == 0
3360 3359
3361 @property 3360 @property
3361 def standalone_manifest_url(self):
3362 """The URL of the standalone manifest, or None."""
3363 return self.config.getString('manifest.standalone')
3364
3365 @property
3366 def manifest_groups(self):
3367 """The manifest groups string."""
3368 return self.config.GetString('manifest.groups')
3369
3370 @property
3371 def reference(self):
3372 """The --reference for this manifest."""
3373 self.config.GetString('repo.reference')
3374
3375 @property
3376 def dissociate(self):
3377 """Whether to dissociate."""
3378 self.config.GetBoolean('repo.dissociate')
3379
3380 @property
3381 def archive(self):
3382 """Whether we use archive."""
3383 self.config.GetBoolean('repo.archive')
3384
3385 @property
3386 def mirror(self):
3387 """Whether we use mirror."""
3388 self.config.GetBoolean('repo.mirror')
3389
3390 @property
3391 def use_worktree(self):
3392 """Whether we use worktree."""
3393 self.config.GetBoolean('repo.worktree')
3394
3395 @property
3396 def clone_bundle(self):
3397 """Whether we use clone_bundle."""
3398 self.config.GetBoolean('repo.clonebundle')
3399
3400 @property
3401 def submodules(self):
3402 """Whether we use submodules."""
3403 self.config.GetBoolean('repo.submodules')
3404
3405 @property
3406 def git_lfs(self):
3407 """Whether we use git_lfs."""
3408 self.config.GetBoolean('repo.git-lfs')
3409
3410 @property
3411 def use_superproject(self):
3412 """Whether we use superproject."""
3413 self.config.GetBoolean('repo.superproject')
3414
3415 @property
3416 def partial_clone(self):
3417 """Whether this is a partial clone."""
3418 self.config.GetBoolean('repo.partialclone')
3419
3420 @property
3421 def depth(self):
3422 """Partial clone depth."""
3423 self.config.GetString('repo.depth')
3424
3425 @property
3426 def clone_filter(self):
3427 """The clone filter."""
3428 self.config.GetString('repo.clonefilter')
3429
3430 @property
3431 def partial_clone_exclude(self):
3432 """Partial clone exclude string"""
3433 self.config.GetBoolean('repo.partialcloneexclude')
3434
3435 @property
3362 def _platform_name(self): 3436 def _platform_name(self):
3363 """Return the name of the platform.""" 3437 """Return the name of the platform."""
3364 return platform.system().lower() 3438 return platform.system().lower()
3365 3439
3366 def Sync(self, _kwargs_only=(), manifest_url='', manifest_branch=None, 3440 def Sync(self, _kwargs_only=(), manifest_url='', manifest_branch=None,
3367 standalone_manifest=False, groups='', platform='', mirror=False, 3441 standalone_manifest=False, groups='', mirror=False, reference='',
3368 dissociate=False, reference='', worktree=False, submodules=False, 3442 dissociate=False, worktree=False, submodules=False, archive=False,
3369 archive=False, partial_clone=None, clone_filter='blob:none', 3443 partial_clone=None, depth=None, clone_filter='blob:none',
3370 partial_clone_exclude=None, clone_bundle=None, git_lfs=None, 3444 partial_clone_exclude=None, clone_bundle=None, git_lfs=None,
3371 use_superproject=None, verbose=False, current_branch_only=False, 3445 use_superproject=None, verbose=False, current_branch_only=False,
3372 tags='', depth=None): 3446 platform='', tags=''):
3373 """Sync the manifest and all submanifests. 3447 """Sync the manifest and all submanifests.
3374 3448
3375 Args: 3449 Args:
@@ -3379,8 +3453,6 @@ class ManifestProject(MetaProject):
3379 file. 3453 file.
3380 groups: a string, restricts the checkout to projects with the specified 3454 groups: a string, restricts the checkout to projects with the specified
3381 groups. 3455 groups.
3382 platform: a string, restrict the checkout to projects with the specified
3383 platform group.
3384 mirror: a boolean, whether to create a mirror of the remote repository. 3456 mirror: a boolean, whether to create a mirror of the remote repository.
3385 reference: a string, location of a repo instance to use as a reference. 3457 reference: a string, location of a repo instance to use as a reference.
3386 dissociate: a boolean, whether to dissociate from reference mirrors after 3458 dissociate: a boolean, whether to dissociate from reference mirrors after
@@ -3391,6 +3463,7 @@ class ManifestProject(MetaProject):
3391 archive: a boolean, whether to checkout each project as an archive. See 3463 archive: a boolean, whether to checkout each project as an archive. See
3392 git-archive. 3464 git-archive.
3393 partial_clone: a boolean, whether to perform a partial clone. 3465 partial_clone: a boolean, whether to perform a partial clone.
3466 depth: an int, how deep of a shallow clone to create.
3394 clone_filter: a string, filter to use with partial_clone. 3467 clone_filter: a string, filter to use with partial_clone.
3395 partial_clone_exclude : a string, comma-delimeted list of project namess 3468 partial_clone_exclude : a string, comma-delimeted list of project namess
3396 to exclude from partial clone. 3469 to exclude from partial clone.
@@ -3401,8 +3474,9 @@ class ManifestProject(MetaProject):
3401 verbose: a boolean, whether to show all output, rather than only errors. 3474 verbose: a boolean, whether to show all output, rather than only errors.
3402 current_branch_only: a boolean, whether to only fetch the current manifest 3475 current_branch_only: a boolean, whether to only fetch the current manifest
3403 branch from the server. 3476 branch from the server.
3477 platform: a string, restrict the checkout to projects with the specified
3478 platform group.
3404 tags: a boolean, whether to fetch tags., 3479 tags: a boolean, whether to fetch tags.,
3405 depth: an int, how deep of a shallow clone to create.
3406 3480
3407 Returns: 3481 Returns:
3408 a boolean, whether the sync was successful. 3482 a boolean, whether the sync was successful.
@@ -3493,11 +3567,11 @@ class ManifestProject(MetaProject):
3493 else: 3567 else:
3494 self.PreSync() 3568 self.PreSync()
3495 3569
3496 groups = re.split(r'[,\s]+', groups) 3570 groups = re.split(r'[,\s]+', groups or '')
3497 all_platforms = ['linux', 'darwin', 'windows'] 3571 all_platforms = ['linux', 'darwin', 'windows']
3498 platformize = lambda x: 'platform-' + x 3572 platformize = lambda x: 'platform-' + x
3499 if platform == 'auto': 3573 if platform == 'auto':
3500 if (not mirror and not self.config.GetString('repo.mirror') == 'true'): 3574 if not mirror and not self.mirror:
3501 groups.append(platformize(self._platform_name)) 3575 groups.append(platformize(self._platform_name))
3502 elif platform == 'all': 3576 elif platform == 'all':
3503 groups.extend(map(platformize, all_platforms)) 3577 groups.extend(map(platformize, all_platforms))
@@ -3561,8 +3635,8 @@ class ManifestProject(MetaProject):
3561 self.config.SetBoolean('repo.partialclone', partial_clone) 3635 self.config.SetBoolean('repo.partialclone', partial_clone)
3562 if clone_filter: 3636 if clone_filter:
3563 self.config.SetString('repo.clonefilter', clone_filter) 3637 self.config.SetString('repo.clonefilter', clone_filter)
3564 elif self.config.GetBoolean('repo.partialclone'): 3638 elif self.partialclone:
3565 clone_filter = self.config.GetString('repo.clonefilter') 3639 clone_filter = self.clone_filter
3566 else: 3640 else:
3567 clone_filter = None 3641 clone_filter = None
3568 3642