summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
Diffstat (limited to 'project.py')
-rw-r--r--project.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/project.py b/project.py
index ff018393..83f3eff9 100644
--- a/project.py
+++ b/project.py
@@ -1186,6 +1186,7 @@ class Project(object):
1186 ssh_proxy=None, 1186 ssh_proxy=None,
1187 clone_filter=None, 1187 clone_filter=None,
1188 partial_clone_exclude=set(), 1188 partial_clone_exclude=set(),
1189 clone_filter_for_depth=None,
1189 ): 1190 ):
1190 """Perform only the network IO portion of the sync process. 1191 """Perform only the network IO portion of the sync process.
1191 Local working directory/branch state is not affected. 1192 Local working directory/branch state is not affected.
@@ -1295,6 +1296,10 @@ class Project(object):
1295 else: 1296 else:
1296 depth = self.manifest.manifestProject.depth 1297 depth = self.manifest.manifestProject.depth
1297 1298
1299 if depth and clone_filter_for_depth:
1300 depth = None
1301 clone_filter = clone_filter_for_depth
1302
1298 # See if we can skip the network fetch entirely. 1303 # See if we can skip the network fetch entirely.
1299 remote_fetched = False 1304 remote_fetched = False
1300 if not ( 1305 if not (
@@ -3885,6 +3890,11 @@ class ManifestProject(MetaProject):
3885 return self.config.GetString("repo.partialcloneexclude") 3890 return self.config.GetString("repo.partialcloneexclude")
3886 3891
3887 @property 3892 @property
3893 def clone_filter_for_depth(self):
3894 """Replace shallow clone with partial clone."""
3895 return self.config.GetString("repo.clonefilterfordepth")
3896
3897 @property
3888 def manifest_platform(self): 3898 def manifest_platform(self):
3889 """The --platform argument from `repo init`.""" 3899 """The --platform argument from `repo init`."""
3890 return self.config.GetString("manifest.platform") 3900 return self.config.GetString("manifest.platform")
@@ -3961,6 +3971,7 @@ class ManifestProject(MetaProject):
3961 manifest_name=spec.manifestName, 3971 manifest_name=spec.manifestName,
3962 this_manifest_only=True, 3972 this_manifest_only=True,
3963 outer_manifest=False, 3973 outer_manifest=False,
3974 clone_filter_for_depth=mp.clone_filter_for_depth,
3964 ) 3975 )
3965 3976
3966 def Sync( 3977 def Sync(
@@ -3991,6 +4002,7 @@ class ManifestProject(MetaProject):
3991 tags="", 4002 tags="",
3992 this_manifest_only=False, 4003 this_manifest_only=False,
3993 outer_manifest=True, 4004 outer_manifest=True,
4005 clone_filter_for_depth=None,
3994 ): 4006 ):
3995 """Sync the manifest and all submanifests. 4007 """Sync the manifest and all submanifests.
3996 4008
@@ -4035,6 +4047,8 @@ class ManifestProject(MetaProject):
4035 current sub manifest. 4047 current sub manifest.
4036 outer_manifest: a boolean, whether to start at the outermost 4048 outer_manifest: a boolean, whether to start at the outermost
4037 manifest. 4049 manifest.
4050 clone_filter_for_depth: a string, when specified replaces shallow
4051 clones with partial.
4038 4052
4039 Returns: 4053 Returns:
4040 a boolean, whether the sync was successful. 4054 a boolean, whether the sync was successful.
@@ -4297,6 +4311,9 @@ class ManifestProject(MetaProject):
4297 file=sys.stderr, 4311 file=sys.stderr,
4298 ) 4312 )
4299 4313
4314 if clone_filter_for_depth is not None:
4315 self.ConfigureCloneFilterForDepth(clone_filter_for_depth)
4316
4300 if use_superproject is not None: 4317 if use_superproject is not None:
4301 self.config.SetBoolean("repo.superproject", use_superproject) 4318 self.config.SetBoolean("repo.superproject", use_superproject)
4302 4319
@@ -4311,6 +4328,7 @@ class ManifestProject(MetaProject):
4311 submodules=submodules, 4328 submodules=submodules,
4312 clone_filter=clone_filter, 4329 clone_filter=clone_filter,
4313 partial_clone_exclude=self.manifest.PartialCloneExclude, 4330 partial_clone_exclude=self.manifest.PartialCloneExclude,
4331 clone_filter_for_depth=self.manifest.CloneFilterForDepth,
4314 ).success 4332 ).success
4315 if not success: 4333 if not success:
4316 r = self.GetRemote() 4334 r = self.GetRemote()
@@ -4415,6 +4433,18 @@ class ManifestProject(MetaProject):
4415 4433
4416 return True 4434 return True
4417 4435
4436 def ConfigureCloneFilterForDepth(self, clone_filter_for_depth):
4437 """Configure clone filter to replace shallow clones.
4438
4439 Args:
4440 clone_filter_for_depth: a string or None, e.g. 'blob:none' will
4441 disable shallow clones and replace with partial clone. None will
4442 enable shallow clones.
4443 """
4444 self.config.SetString(
4445 "repo.clonefilterfordepth", clone_filter_for_depth
4446 )
4447
4418 def _ConfigureDepth(self, depth): 4448 def _ConfigureDepth(self, depth):
4419 """Configure the depth we'll sync down. 4449 """Configure the depth we'll sync down.
4420 4450