diff options
| author | Julien Campergue <julien.campergue@parrot.com> | 2013-10-16 11:02:35 +0200 |
|---|---|---|
| committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-12-10 08:27:07 +0000 |
| commit | 335f5ef4ad25a85c69fe6d8c848c5d1d447e22c8 (patch) | |
| tree | 6a64a34ce5063d8d255c7840e167db2484e68c9a /subcmds | |
| parent | 61df418c599a0359b33b8a65a12660023fc37a2a (diff) | |
| download | git-repo-335f5ef4ad25a85c69fe6d8c848c5d1d447e22c8.tar.gz | |
Add --archive option to init to sync using git archive
This significantly reduces sync time and used brandwidth as only
a tar of each project's revision is checked out, but git is not
accessible from projects anymore.
This is relevant when git is not needed in projects but sync
speed/brandwidth may be important like on CI servers when building
several versions from scratch regularly for example.
Archive is not supported over http/https.
Change-Id: I48c3c7de2cd5a1faec33e295fcdafbc7807d0e4d
Signed-off-by: Julien Campergue <julien.campergue@parrot.com>
Diffstat (limited to 'subcmds')
| -rw-r--r-- | subcmds/init.py | 21 | ||||
| -rw-r--r-- | subcmds/sync.py | 11 |
2 files changed, 28 insertions, 4 deletions
diff --git a/subcmds/init.py b/subcmds/init.py index a44fb7a9..b1fcb69c 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
| @@ -99,6 +99,10 @@ to update the working directory files. | |||
| 99 | g.add_option('--depth', type='int', default=None, | 99 | g.add_option('--depth', type='int', default=None, |
| 100 | dest='depth', | 100 | dest='depth', |
| 101 | help='create a shallow clone with given depth; see git clone') | 101 | help='create a shallow clone with given depth; see git clone') |
| 102 | g.add_option('--archive', | ||
| 103 | dest='archive', action='store_true', | ||
| 104 | help='checkout an archive instead of a git repository for ' | ||
| 105 | 'each project. See git archive.') | ||
| 102 | g.add_option('-g', '--groups', | 106 | g.add_option('-g', '--groups', |
| 103 | dest='groups', default='default', | 107 | dest='groups', default='default', |
| 104 | help='restrict manifest projects to ones with specified ' | 108 | help='restrict manifest projects to ones with specified ' |
| @@ -198,6 +202,16 @@ to update the working directory files. | |||
| 198 | if opt.reference: | 202 | if opt.reference: |
| 199 | m.config.SetString('repo.reference', opt.reference) | 203 | m.config.SetString('repo.reference', opt.reference) |
| 200 | 204 | ||
| 205 | if opt.archive: | ||
| 206 | if is_new: | ||
| 207 | m.config.SetString('repo.archive', 'true') | ||
| 208 | else: | ||
| 209 | print('fatal: --archive is only supported when initializing a new ' | ||
| 210 | 'workspace.', file=sys.stderr) | ||
| 211 | print('Either delete the .repo folder in this workspace, or initialize ' | ||
| 212 | 'in another location.', file=sys.stderr) | ||
| 213 | sys.exit(1) | ||
| 214 | |||
| 201 | if opt.mirror: | 215 | if opt.mirror: |
| 202 | if is_new: | 216 | if is_new: |
| 203 | m.config.SetString('repo.mirror', 'true') | 217 | m.config.SetString('repo.mirror', 'true') |
| @@ -366,6 +380,13 @@ to update the working directory files. | |||
| 366 | if opt.reference: | 380 | if opt.reference: |
| 367 | opt.reference = os.path.expanduser(opt.reference) | 381 | opt.reference = os.path.expanduser(opt.reference) |
| 368 | 382 | ||
| 383 | # Check this here, else manifest will be tagged "not new" and init won't be | ||
| 384 | # possible anymore without removing the .repo/manifests directory. | ||
| 385 | if opt.archive and opt.mirror: | ||
| 386 | print('fatal: --mirror and --archive cannot be used together.', | ||
| 387 | file=sys.stderr) | ||
| 388 | sys.exit(1) | ||
| 389 | |||
| 369 | self._SyncManifest(opt) | 390 | self._SyncManifest(opt) |
| 370 | self._LinkManifest(opt.manifest_name) | 391 | self._LinkManifest(opt.manifest_name) |
| 371 | 392 | ||
diff --git a/subcmds/sync.py b/subcmds/sync.py index d8aec59b..0279ff60 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
| @@ -253,7 +253,7 @@ later is required to fix a server side protocol bug. | |||
| 253 | quiet=opt.quiet, | 253 | quiet=opt.quiet, |
| 254 | current_branch_only=opt.current_branch_only, | 254 | current_branch_only=opt.current_branch_only, |
| 255 | clone_bundle=not opt.no_clone_bundle, | 255 | clone_bundle=not opt.no_clone_bundle, |
| 256 | no_tags=opt.no_tags) | 256 | no_tags=opt.no_tags, archive=self.manifest.IsArchive) |
| 257 | self._fetch_times.Set(project, time.time() - start) | 257 | self._fetch_times.Set(project, time.time() - start) |
| 258 | 258 | ||
| 259 | # Lock around all the rest of the code, since printing, updating a set | 259 | # Lock around all the rest of the code, since printing, updating a set |
| @@ -294,7 +294,8 @@ later is required to fix a server side protocol bug. | |||
| 294 | quiet=opt.quiet, | 294 | quiet=opt.quiet, |
| 295 | current_branch_only=opt.current_branch_only, | 295 | current_branch_only=opt.current_branch_only, |
| 296 | clone_bundle=not opt.no_clone_bundle, | 296 | clone_bundle=not opt.no_clone_bundle, |
| 297 | no_tags=opt.no_tags): | 297 | no_tags=opt.no_tags, |
| 298 | archive=self.manifest.IsArchive): | ||
| 298 | fetched.add(project.gitdir) | 299 | fetched.add(project.gitdir) |
| 299 | else: | 300 | else: |
| 300 | print('error: Cannot fetch %s' % project.name, file=sys.stderr) | 301 | print('error: Cannot fetch %s' % project.name, file=sys.stderr) |
| @@ -338,7 +339,9 @@ later is required to fix a server side protocol bug. | |||
| 338 | pm.end() | 339 | pm.end() |
| 339 | self._fetch_times.Save() | 340 | self._fetch_times.Save() |
| 340 | 341 | ||
| 341 | self._GCProjects(projects) | 342 | if not self.manifest.IsArchive: |
| 343 | self._GCProjects(projects) | ||
| 344 | |||
| 342 | return fetched | 345 | return fetched |
| 343 | 346 | ||
| 344 | def _GCProjects(self, projects): | 347 | def _GCProjects(self, projects): |
| @@ -641,7 +644,7 @@ later is required to fix a server side protocol bug. | |||
| 641 | previously_missing_set = missing_set | 644 | previously_missing_set = missing_set |
| 642 | fetched.update(self._Fetch(missing, opt)) | 645 | fetched.update(self._Fetch(missing, opt)) |
| 643 | 646 | ||
| 644 | if self.manifest.IsMirror: | 647 | if self.manifest.IsMirror or self.manifest.IsArchive: |
| 645 | # bail out now, we have no working tree | 648 | # bail out now, we have no working tree |
| 646 | return | 649 | return |
| 647 | 650 | ||
