Mercurial > public > mercurial-scm > hg
comparison mercurial/upgrade_utils/auto_upgrade.py @ 49200: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 |
comparison
equal
deleted
inserted
replaced
49199:575f3dedb69a | 49200:71774d799de7 |
---|---|
215 """ | 215 """ |
216 clear = False | 216 clear = False |
217 | 217 |
218 loop = 0 | 218 loop = 0 |
219 | 219 |
220 while not clear: | 220 try: |
221 loop += 1 | 221 while not clear: |
222 if loop > 100: | 222 loop += 1 |
223 # XXX basic protection against infinite loop, make it better. | 223 if loop > 100: |
224 raise error.ProgrammingError("Too many auto upgrade loops") | 224 # XXX basic protection against infinite loop, make it better. |
225 clear = True | 225 raise error.ProgrammingError("Too many auto upgrade loops") |
226 for get_action in AUTO_UPGRADE_ACTIONS: | 226 clear = True |
227 action = get_action(repo) | 227 for get_action in AUTO_UPGRADE_ACTIONS: |
228 if action is not None: | 228 action = get_action(repo) |
229 clear = False | 229 if action is not None: |
230 with repo.wlock(wait=False), repo.lock(wait=False): | 230 clear = False |
231 action = get_action(repo) | 231 with repo.wlock(wait=False), repo.lock(wait=False): |
232 if action is not None: | 232 action = get_action(repo) |
233 action() | 233 if action is not None: |
234 repo = maker_func() | 234 action() |
235 repo = maker_func() | |
236 except error.LockError: | |
237 # if we cannot get the lock, ignore the auto-upgrade attemps and | |
238 # proceed. We might want to make this behavior configurable in the | |
239 # future. | |
240 pass | |
241 | |
235 return repo | 242 return repo |