Mercurial > hg > mercurial-source
comparison mercurial/exchange.py @ 34577:389f7b17ffb3
exchange: simplify unbundle locking using context managers
Differential Revision: https://phab.mercurial-scm.org/D393
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 28 Jul 2017 22:04:27 -0700 |
parents | bbbbd3c30bfc |
children | 800bb35d891e |
comparison
equal
deleted
inserted
replaced
34576:bbbbd3c30bfc | 34577:389f7b17ffb3 |
---|---|
457 # We do not abort the push, but just disable the local phase | 457 # We do not abort the push, but just disable the local phase |
458 # synchronisation. | 458 # synchronisation. |
459 msg = 'cannot lock source repository: %s\n' % err | 459 msg = 'cannot lock source repository: %s\n' % err |
460 pushop.ui.debug(msg) | 460 pushop.ui.debug(msg) |
461 | 461 |
462 try: | 462 with wlock or util.nullcontextmanager(), \ |
463 lock or util.nullcontextmanager(), \ | |
464 pushop.trmanager or util.nullcontextmanager(): | |
463 pushop.repo.checkpush(pushop) | 465 pushop.repo.checkpush(pushop) |
464 _pushdiscovery(pushop) | 466 _pushdiscovery(pushop) |
465 if not _forcebundle1(pushop): | 467 if not _forcebundle1(pushop): |
466 _pushbundle2(pushop) | 468 _pushbundle2(pushop) |
467 _pushchangeset(pushop) | 469 _pushchangeset(pushop) |
468 _pushsyncphase(pushop) | 470 _pushsyncphase(pushop) |
469 _pushobsolete(pushop) | 471 _pushobsolete(pushop) |
470 _pushbookmark(pushop) | 472 _pushbookmark(pushop) |
471 | |
472 if pushop.trmanager: | |
473 pushop.trmanager.close() | |
474 finally: | |
475 if pushop.trmanager: | |
476 pushop.trmanager.release() | |
477 if lock is not None: | |
478 lock.release() | |
479 if wlock is not None: | |
480 wlock.release() | |
481 | 473 |
482 return pushop | 474 return pushop |
483 | 475 |
484 # list of steps to perform discovery before push | 476 # list of steps to perform discovery before push |
485 pushdiscoveryorder = [] | 477 pushdiscoveryorder = [] |