diff options
author | Xin Li <delphij@google.com> | 2019-06-03 11:24:30 -0700 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2019-07-16 00:23:16 +0000 |
commit | 745be2ede1e67421275afc00c04d996d9d6908ee (patch) | |
tree | 6b7bfbd187a33eeeb14108518ece5440ce9456c0 /project.py | |
parent | 87fb5a1894354ec0e34ccec427a9803e24157847 (diff) | |
download | git-repo-745be2ede1e67421275afc00c04d996d9d6908ee.tar.gz |
Add support for partial clone.v1.13.4
A new option, --partial-clone is added to 'repo init' which tells repo
to utilize git's partial clone functionality, which reduces disk and
bandwidth usage when downloading by omitting blob downloads initially.
Different from restricting clone-depth, the user will have full access
to change history, etc., as the objects are downloaded on demand.
Change-Id: I60326744875eac16521a007bd7d5481112a98749
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/229532
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Xin Li <delphij@google.com>
Diffstat (limited to 'project.py')
-rwxr-xr-x | project.py | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -1226,7 +1226,8 @@ class Project(object): | |||
1226 | archive=False, | 1226 | archive=False, |
1227 | optimized_fetch=False, | 1227 | optimized_fetch=False, |
1228 | prune=False, | 1228 | prune=False, |
1229 | submodules=False): | 1229 | submodules=False, |
1230 | clone_filter=None): | ||
1230 | """Perform only the network IO portion of the sync process. | 1231 | """Perform only the network IO portion of the sync process. |
1231 | Local working directory/branch state is not affected. | 1232 | Local working directory/branch state is not affected. |
1232 | """ | 1233 | """ |
@@ -1309,7 +1310,8 @@ class Project(object): | |||
1309 | not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, | 1310 | not self._RemoteFetch(initial=is_new, quiet=quiet, alt_dir=alt_dir, |
1310 | current_branch_only=current_branch_only, | 1311 | current_branch_only=current_branch_only, |
1311 | no_tags=no_tags, prune=prune, depth=depth, | 1312 | no_tags=no_tags, prune=prune, depth=depth, |
1312 | submodules=submodules, force_sync=force_sync)): | 1313 | submodules=submodules, force_sync=force_sync, |
1314 | clone_filter=clone_filter)): | ||
1313 | return False | 1315 | return False |
1314 | 1316 | ||
1315 | mp = self.manifest.manifestProject | 1317 | mp = self.manifest.manifestProject |
@@ -1959,7 +1961,8 @@ class Project(object): | |||
1959 | prune=False, | 1961 | prune=False, |
1960 | depth=None, | 1962 | depth=None, |
1961 | submodules=False, | 1963 | submodules=False, |
1962 | force_sync=False): | 1964 | force_sync=False, |
1965 | clone_filter=None): | ||
1963 | 1966 | ||
1964 | is_sha1 = False | 1967 | is_sha1 = False |
1965 | tag_name = None | 1968 | tag_name = None |
@@ -2050,6 +2053,11 @@ class Project(object): | |||
2050 | 2053 | ||
2051 | cmd = ['fetch'] | 2054 | cmd = ['fetch'] |
2052 | 2055 | ||
2056 | if clone_filter: | ||
2057 | git_require((2, 19, 0), fail=True, msg='partial clones') | ||
2058 | cmd.append('--filter=%s' % clone_filter) | ||
2059 | self.config.SetString('extensions.partialclone', self.remote.name) | ||
2060 | |||
2053 | if depth: | 2061 | if depth: |
2054 | cmd.append('--depth=%s' % depth) | 2062 | cmd.append('--depth=%s' % depth) |
2055 | else: | 2063 | else: |
@@ -2150,12 +2158,12 @@ class Project(object): | |||
2150 | return self._RemoteFetch(name=name, | 2158 | return self._RemoteFetch(name=name, |
2151 | current_branch_only=current_branch_only, | 2159 | current_branch_only=current_branch_only, |
2152 | initial=False, quiet=quiet, alt_dir=alt_dir, | 2160 | initial=False, quiet=quiet, alt_dir=alt_dir, |
2153 | depth=None) | 2161 | depth=None, clone_filter=clone_filter) |
2154 | else: | 2162 | else: |
2155 | # Avoid infinite recursion: sync all branches with depth set to None | 2163 | # Avoid infinite recursion: sync all branches with depth set to None |
2156 | return self._RemoteFetch(name=name, current_branch_only=False, | 2164 | return self._RemoteFetch(name=name, current_branch_only=False, |
2157 | initial=False, quiet=quiet, alt_dir=alt_dir, | 2165 | initial=False, quiet=quiet, alt_dir=alt_dir, |
2158 | depth=None) | 2166 | depth=None, clone_filter=clone_filter) |
2159 | 2167 | ||
2160 | return ok | 2168 | return ok |
2161 | 2169 | ||