diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt --- a/mercurial/helptext/config.txt +++ b/mercurial/helptext/config.txt @@ -957,6 +957,9 @@ change is needed. This also applies to operations that would have been read-only (like hg status). + If the repository cannot be locked, the automatic-upgrade operation will be + skipped. The next operation will attempt it again. + This configuration will apply for moves in any direction, either adding the `dirstate-v2` format if `format.use-dirstate-v2=yes` or removing the `dirstate-v2` requirement if `format.use-dirstate-v2=no`. So we recommend @@ -1008,6 +1011,9 @@ triggers if a change is needed. This also applies to operations that would have been read-only (like hg status). + If the repository cannot be locked, the automatic-upgrade operation will be + skipped. The next operation will attempt it again. + This configuration will apply for moves in any direction, either adding the `dirstate-tracked-hint` format if `format.use-dirstate-tracked-hint=yes` or removing the `dirstate-tracked-hint` requirement if @@ -1084,6 +1090,9 @@ change is needed. This also applies to operation that would have been read-only (like hg status). + If the repository cannot be locked, the automatic-upgrade operation will be + skipped. The next operation will attempt it again. + This configuration will apply for moves in any direction, either adding the `share-safe` format if `format.use-share-safe=yes` or removing the `share-safe` requirement if `format.use-share-safe=no`. So we recommend diff --git a/mercurial/upgrade_utils/auto_upgrade.py b/mercurial/upgrade_utils/auto_upgrade.py --- a/mercurial/upgrade_utils/auto_upgrade.py +++ b/mercurial/upgrade_utils/auto_upgrade.py @@ -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 diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t --- a/tests/test-upgrade-repo.t +++ b/tests/test-upgrade-repo.t @@ -2069,8 +2069,6 @@ $ hg status -R auto-upgrade \ > --config format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \ > --config format.use-dirstate-v2=no - abort: could not lock working directory of auto-upgrade: Permission denied - [20] $ hg debugformat -R auto-upgrade | grep dirstate-v2 dirstate-v2: yes @@ -2085,8 +2083,6 @@ $ hg status -R auto-upgrade \ > --config format.use-dirstate-v2.automatic-upgrade-of-mismatching-repositories=yes \ > --config format.use-dirstate-v2=no - abort: repository auto-upgrade: timed out waiting for lock held by 'brunhoff/effffffc:1215708' - [20] $ hg debugformat -R auto-upgrade | grep dirstate-v2 dirstate-v2: yes