Mercurial > hg-stable
changeset 51856:54b1a3738530
shelve: raise an error when loading a corrupt state file in an impossible case
The old return statement was flagged by pytype 2023.06.16 running under python
3.10.11. No idea why it isn't caught in CI running the same pytype with py3.7.
This function is only called by `unshelvecmd()` (which first checks that either
`--abort` or `--continue` is specified), and `hgabortunshelve()` and
`hgcontinueunshelve()`, which locally apply `--abort` or `--continue`
respectively. Therefore, there is no other way to call this, and this error
should never be seen, but pytype can't figure that out on its own. Given that
the abort case clears the state, it seems reasonable to defensively code this
and not make that a blanket `else` case, on the off chance a 3rd way of calling
this appears in the future.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 20 Aug 2024 16:32:13 -0400 |
parents | 68ec9743ef04 |
children | f1ef512e14ab |
files | mercurial/shelve.py |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/shelve.py Tue Aug 20 11:18:10 2024 -0400 +++ b/mercurial/shelve.py Tue Aug 20 16:32:13 2024 -0400 @@ -792,6 +792,7 @@ state = shelvedstate.load(repo) if opts.get(b'keep') is None: opts[b'keep'] = state.keep + return state except FileNotFoundError: cmdutil.wrongtooltocontinue(repo, _(b'unshelve')) except error.CorruptedState as err: @@ -812,7 +813,10 @@ b'please update to some commit\n' ) ) - return state + else: + raise error.ProgrammingError( + "a corrupted shelvedstate exists without --abort or --continue" + ) def unshelveabort(ui, repo, state):