diff options
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r-- | subcmds/sync.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 0a3cde7d..b1b6a6ef 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -354,6 +354,8 @@ later is required to fix a server side protocol bug. | |||
354 | # - We always make sure we unlock the lock if we locked it. | 354 | # - We always make sure we unlock the lock if we locked it. |
355 | start = time.time() | 355 | start = time.time() |
356 | success = False | 356 | success = False |
357 | with lock: | ||
358 | pm.start(project.name) | ||
357 | try: | 359 | try: |
358 | try: | 360 | try: |
359 | success = project.Sync_NetworkHalf( | 361 | success = project.Sync_NetworkHalf( |
@@ -383,7 +385,6 @@ later is required to fix a server side protocol bug. | |||
383 | raise _FetchError() | 385 | raise _FetchError() |
384 | 386 | ||
385 | fetched.add(project.gitdir) | 387 | fetched.add(project.gitdir) |
386 | pm.update(msg=project.name) | ||
387 | except _FetchError: | 388 | except _FetchError: |
388 | pass | 389 | pass |
389 | except Exception as e: | 390 | except Exception as e: |
@@ -392,8 +393,10 @@ later is required to fix a server side protocol bug. | |||
392 | err_event.set() | 393 | err_event.set() |
393 | raise | 394 | raise |
394 | finally: | 395 | finally: |
395 | if did_lock: | 396 | if not did_lock: |
396 | lock.release() | 397 | lock.acquire() |
398 | pm.finish(project.name) | ||
399 | lock.release() | ||
397 | finish = time.time() | 400 | finish = time.time() |
398 | self.event_log.AddSync(project, event_log.TASK_SYNC_NETWORK, | 401 | self.event_log.AddSync(project, event_log.TASK_SYNC_NETWORK, |
399 | start, finish, success) | 402 | start, finish, success) |
@@ -403,7 +406,7 @@ later is required to fix a server side protocol bug. | |||
403 | def _Fetch(self, projects, opt, err_event): | 406 | def _Fetch(self, projects, opt, err_event): |
404 | fetched = set() | 407 | fetched = set() |
405 | lock = _threading.Lock() | 408 | lock = _threading.Lock() |
406 | pm = Progress('Fetching projects', len(projects)) | 409 | pm = Progress('Fetching', len(projects)) |
407 | 410 | ||
408 | objdir_project_map = dict() | 411 | objdir_project_map = dict() |
409 | for project in projects: | 412 | for project in projects: |
@@ -493,6 +496,8 @@ later is required to fix a server side protocol bug. | |||
493 | syncbuf = SyncBuffer(self.manifest.manifestProject.config, | 496 | syncbuf = SyncBuffer(self.manifest.manifestProject.config, |
494 | detach_head=opt.detach_head) | 497 | detach_head=opt.detach_head) |
495 | success = False | 498 | success = False |
499 | with lock: | ||
500 | pm.start(project.name) | ||
496 | try: | 501 | try: |
497 | try: | 502 | try: |
498 | project.Sync_LocalHalf(syncbuf, force_sync=opt.force_sync) | 503 | project.Sync_LocalHalf(syncbuf, force_sync=opt.force_sync) |
@@ -508,8 +513,6 @@ later is required to fix a server side protocol bug. | |||
508 | print('error: Cannot checkout %s' % (project.name), | 513 | print('error: Cannot checkout %s' % (project.name), |
509 | file=sys.stderr) | 514 | file=sys.stderr) |
510 | raise _CheckoutError() | 515 | raise _CheckoutError() |
511 | |||
512 | pm.update(msg=project.name) | ||
513 | except _CheckoutError: | 516 | except _CheckoutError: |
514 | pass | 517 | pass |
515 | except Exception as e: | 518 | except Exception as e: |
@@ -519,10 +522,12 @@ later is required to fix a server side protocol bug. | |||
519 | err_event.set() | 522 | err_event.set() |
520 | raise | 523 | raise |
521 | finally: | 524 | finally: |
522 | if did_lock: | 525 | if not did_lock: |
523 | if not success: | 526 | lock.acquire() |
524 | err_results.append(project.relpath) | 527 | if not success: |
525 | lock.release() | 528 | err_results.append(project.relpath) |
529 | pm.finish(project.name) | ||
530 | lock.release() | ||
526 | finish = time.time() | 531 | finish = time.time() |
527 | self.event_log.AddSync(project, event_log.TASK_SYNC_LOCAL, | 532 | self.event_log.AddSync(project, event_log.TASK_SYNC_LOCAL, |
528 | start, finish, success) | 533 | start, finish, success) |
@@ -553,7 +558,7 @@ later is required to fix a server side protocol bug. | |||
553 | syncjobs = 1 | 558 | syncjobs = 1 |
554 | 559 | ||
555 | lock = _threading.Lock() | 560 | lock = _threading.Lock() |
556 | pm = Progress('Checking out projects', len(all_projects)) | 561 | pm = Progress('Checking out', len(all_projects)) |
557 | 562 | ||
558 | threads = set() | 563 | threads = set() |
559 | sem = _threading.Semaphore(syncjobs) | 564 | sem = _threading.Semaphore(syncjobs) |