Mercurial > public > mercurial-scm > hg-stable
diff mercurial/upgrade_utils/auto_upgrade.py @ 49232:71774d799de7
auto-upgrade: skip the operation if the repository cannot be locked
This seems like a fine default behavior for now. If some users wants something
more aggressive we can make the behavior configurable in the future.
Differential Revision: https://phab.mercurial-scm.org/D12619
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 05 Apr 2022 05:01:58 +0200 |
parents | 411d591e0a27 |
children | 9e203cda3238 |
line wrap: on
line diff
--- a/mercurial/upgrade_utils/auto_upgrade.py Tue Apr 05 04:45:48 2022 +0200 +++ b/mercurial/upgrade_utils/auto_upgrade.py Tue Apr 05 05:01:58 2022 +0200 @@ -217,19 +217,26 @@ loop = 0 - while not clear: - loop += 1 - if loop > 100: - # XXX basic protection against infinite loop, make it better. - raise error.ProgrammingError("Too many auto upgrade loops") - clear = True - for get_action in AUTO_UPGRADE_ACTIONS: - action = get_action(repo) - if action is not None: - clear = False - with repo.wlock(wait=False), repo.lock(wait=False): - action = get_action(repo) - if action is not None: - action() - repo = maker_func() + try: + while not clear: + loop += 1 + if loop > 100: + # XXX basic protection against infinite loop, make it better. + raise error.ProgrammingError("Too many auto upgrade loops") + clear = True + for get_action in AUTO_UPGRADE_ACTIONS: + action = get_action(repo) + if action is not None: + clear = False + with repo.wlock(wait=False), repo.lock(wait=False): + action = get_action(repo) + if action is not None: + action() + repo = maker_func() + except error.LockError: + # if we cannot get the lock, ignore the auto-upgrade attemps and + # proceed. We might want to make this behavior configurable in the + # future. + pass + return repo