diff options
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r-- | subcmds/sync.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 36b1b0ac..b41b20b7 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -501,34 +501,39 @@ later is required to fix a server side protocol bug. | |||
501 | return ret and not err_results | 501 | return ret and not err_results |
502 | 502 | ||
503 | def _GCProjects(self, projects, opt, err_event): | 503 | def _GCProjects(self, projects, opt, err_event): |
504 | pm = Progress('Garbage collecting', len(projects), delay=False) | ||
505 | pm.update(inc=0, msg='prescan') | ||
506 | |||
504 | gc_gitdirs = {} | 507 | gc_gitdirs = {} |
505 | for project in projects: | 508 | for project in projects: |
506 | # Make sure pruning never kicks in with shared projects. | 509 | # Make sure pruning never kicks in with shared projects. |
507 | if (not project.use_git_worktrees and | 510 | if (not project.use_git_worktrees and |
508 | len(project.manifest.GetProjectsWithName(project.name)) > 1): | 511 | len(project.manifest.GetProjectsWithName(project.name)) > 1): |
509 | if not opt.quiet: | 512 | if not opt.quiet: |
510 | print('%s: Shared project %s found, disabling pruning.' % | 513 | #pm.update(inc=0, msg='Shared project found') |
514 | print('\r%s: Shared project %s found, disabling pruning.' % | ||
511 | (project.relpath, project.name)) | 515 | (project.relpath, project.name)) |
512 | if git_require((2, 7, 0)): | 516 | if git_require((2, 7, 0)): |
513 | project.EnableRepositoryExtension('preciousObjects') | 517 | project.EnableRepositoryExtension('preciousObjects') |
514 | else: | 518 | else: |
515 | # This isn't perfect, but it's the best we can do with old git. | 519 | # This isn't perfect, but it's the best we can do with old git. |
516 | print('%s: WARNING: shared projects are unreliable when using old ' | 520 | print('\r%s: WARNING: shared projects are unreliable when using old ' |
517 | 'versions of git; please upgrade to git-2.7.0+.' | 521 | 'versions of git; please upgrade to git-2.7.0+.' |
518 | % (project.relpath,), | 522 | % (project.relpath,), |
519 | file=sys.stderr) | 523 | file=sys.stderr) |
520 | project.config.SetString('gc.pruneExpire', 'never') | 524 | project.config.SetString('gc.pruneExpire', 'never') |
521 | gc_gitdirs[project.gitdir] = project.bare_git | 525 | gc_gitdirs[project.gitdir] = project.bare_git |
522 | 526 | ||
523 | if multiprocessing: | 527 | pm.update(inc=len(projects) - len(gc_gitdirs), msg='warming up') |
524 | cpu_count = multiprocessing.cpu_count() | 528 | |
525 | else: | 529 | cpu_count = os.cpu_count() |
526 | cpu_count = 1 | ||
527 | jobs = min(self.jobs, cpu_count) | 530 | jobs = min(self.jobs, cpu_count) |
528 | 531 | ||
529 | if jobs < 2: | 532 | if jobs < 2: |
530 | for bare_git in gc_gitdirs.values(): | 533 | for bare_git in gc_gitdirs.values(): |
534 | pm.update(msg=bare_git._project.name) | ||
531 | bare_git.gc('--auto') | 535 | bare_git.gc('--auto') |
536 | pm.end() | ||
532 | return | 537 | return |
533 | 538 | ||
534 | config = {'pack.threads': cpu_count // jobs if cpu_count > jobs else 1} | 539 | config = {'pack.threads': cpu_count // jobs if cpu_count > jobs else 1} |
@@ -537,6 +542,7 @@ later is required to fix a server side protocol bug. | |||
537 | sem = _threading.Semaphore(jobs) | 542 | sem = _threading.Semaphore(jobs) |
538 | 543 | ||
539 | def GC(bare_git): | 544 | def GC(bare_git): |
545 | pm.start(bare_git._project.name) | ||
540 | try: | 546 | try: |
541 | try: | 547 | try: |
542 | bare_git.gc('--auto', config=config) | 548 | bare_git.gc('--auto', config=config) |
@@ -546,6 +552,7 @@ later is required to fix a server side protocol bug. | |||
546 | err_event.set() | 552 | err_event.set() |
547 | raise | 553 | raise |
548 | finally: | 554 | finally: |
555 | pm.finish(bare_git._project.name) | ||
549 | sem.release() | 556 | sem.release() |
550 | 557 | ||
551 | for bare_git in gc_gitdirs.values(): | 558 | for bare_git in gc_gitdirs.values(): |
@@ -559,6 +566,7 @@ later is required to fix a server side protocol bug. | |||
559 | 566 | ||
560 | for t in threads: | 567 | for t in threads: |
561 | t.join() | 568 | t.join() |
569 | pm.end() | ||
562 | 570 | ||
563 | def _ReloadManifest(self, manifest_name=None): | 571 | def _ReloadManifest(self, manifest_name=None): |
564 | if manifest_name: | 572 | if manifest_name: |