Mercurial > hg
changeset 50324:e6532a7336d0 stable
dirstate: try refreshing the changelog when parent are unknown
See inline comment for details.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 23 Mar 2023 21:18:54 +0000 |
parents | 6901916458bd |
children | 2761ce777fc4 |
files | mercurial/localrepo.py tests/test-dirstate-read-race.t tests/test-hook.t |
diffstat | 3 files changed, 22 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Thu Mar 23 21:18:14 2023 +0000 +++ b/mercurial/localrepo.py Thu Mar 23 21:18:54 2023 +0000 @@ -1805,10 +1805,29 @@ ) def _dirstatevalidate(self, node): + okay = True try: self.changelog.rev(node) + except error.LookupError: + # If the parent are unknown it might just be because the changelog + # in memory is lagging behind the dirstate in memory. So try to + # refresh the changelog first. + # + # We only do so if we don't hold the lock, if we do hold the lock + # the invalidation at that time should have taken care of this and + # something is very fishy. + if self.currentlock() is None: + self.invalidate() + try: + self.changelog.rev(node) + except error.LookupError: + okay = False + else: + # XXX we should consider raising an error here. + okay = False + if okay: return node - except error.LookupError: + else: if not self._dirstatevalidatewarned: self._dirstatevalidatewarned = True self.ui.warn(
--- a/tests/test-dirstate-read-race.t Thu Mar 23 21:18:14 2023 +0000 +++ b/tests/test-dirstate-read-race.t Thu Mar 23 21:18:54 2023 +0000 @@ -249,7 +249,7 @@ The status process should return a consistent result and not crash. -#if rust no-rhg dirstate-v2-append +#if no-rhg $ cat $TESTTMP/status-race-lock.out A dir/o R dir/nested/m @@ -258,7 +258,7 @@ ? q $ cat $TESTTMP/status-race-lock.log #else -#if rhg pre-some-read dirstate-v2-append +#if pre-some-read dirstate-v2-append $ cat $TESTTMP/status-race-lock.out A dir/o R dir/nested/m @@ -268,12 +268,10 @@ $ cat $TESTTMP/status-race-lock.log #else $ cat $TESTTMP/status-race-lock.out - M dir/o (no-rhg known-bad-output !) ? dir/n ? p ? q $ cat $TESTTMP/status-race-lock.log - warning: ignoring unknown working parent 02a67a77ee9b! (no-rhg !) #endif #endif
--- a/tests/test-hook.t Thu Mar 23 21:18:14 2023 +0000 +++ b/tests/test-hook.t Thu Mar 23 21:18:54 2023 +0000 @@ -1466,6 +1466,5 @@ $ hg merge 1 1 files updated, 0 files merged, 0 files removed, 0 files unresolved (branch merge, don't forget to commit) - warning: ignoring unknown working parent 449f60fb3fe2! (known-bad-output !) $ cd ..