D12619: auto-upgrade: skip the operation if the repository cannot be locked
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Fri May 6 08:38:37 UTC 2022
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
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.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D12619
AFFECTED FILES
mercurial/helptext/config.txt
mercurial/upgrade_utils/auto_upgrade.py
tests/test-upgrade-repo.t
CHANGE DETAILS
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
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/mercurial/helptext/config.txt b/mercurial/helptext/config.txt
--- a/mercurial/helptext/config.txt
+++ b/mercurial/helptext/config.txt
@@ -957,6 +957,9 @@
needed. This also apply 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 attemps it again.
+
This configuration will apply for move 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 recommand
@@ -1008,6 +1011,9 @@
change is needed. This also apply 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 attemps it again.
+
This configuration will apply for move 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 apply 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 attemps it again.
+
This configuration will apply for move 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 recommand
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list