D6579: abort: added support for unshelve
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Wed Jul 10 13:10:52 EDT 2019
pulkit added inline comments.
INLINE COMMENTS
> shelve.py:628
>
> -def unshelveabort(ui, repo, state, opts):
> +def _loadshelvedstate(ui, repo, continuef=False, abortf=False, **opts):
> + try:
continuef and abortf can be read from opts, no need to pass them separately.
Also, `opts` should be pass as a dictionary here, no need to pass that as kwargs.
> shelve.py:648
> + 'commit\n')
> + ui.warn(msg)
> + shelvedstate.clear(repo)
I think we can convert this `ui.warn()` to `error.Abort()` and hence get rid of `sys.exit()`. Send a standalone patch before this one which make this an error instead of warn.
> shelve.py:656
> + if not state:
> + statetuple = _loadshelvedstate(ui, repo, abortf=True)
> + state, opts = statetuple
nit: `state, opts = _loadshelvedstate(ui, repo, {'abort'=True})`
> shelve.py:658
> + state, opts = statetuple
> + with repo.wlock(), repo.lock():
> try:
let's take `wlock()` only again when if we are processing `hg abort`. We can define this function as `unshelveabort(ui, repo, state, abortcommand=False)` and pass state as None, and abortcommand as True. When abortcommand is True, reassign state to new one and take wlock. Also make sure to release the wlock later in case of abortcommand.
> shelve.py:896
>
> - try:
> - state = shelvedstate.load(repo)
> - if opts.get('keep') is None:
> - opts['keep'] = state.keep
> - except IOError as err:
> - if err.errno != errno.ENOENT:
> - raise
> - cmdutil.wrongtooltocontinue(repo, _('unshelve'))
> - except error.CorruptedState as err:
> - ui.debug(pycompat.bytestr(err) + '\n')
> - if continuef:
> - msg = _('corrupted shelved state file')
> - hint = _('please run hg unshelve --abort to abort unshelve '
> - 'operation')
> - raise error.Abort(msg, hint=hint)
> - elif abortf:
> - msg = _('could not read shelved state file, your working copy '
> - 'may be in an unexpected state\nplease update to some '
> - 'commit\n')
> - ui.warn(msg)
> - shelvedstate.clear(repo)
> - return
> + statetuple = _loadshelvedstate(ui, repo, continuef=continuef,
> + abortf=abortf, **opts)
same as a comment above related to directly assigning it to `state, opts`
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D6579/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D6579
To: taapas1128, #hg-reviewers
Cc: mharbison72, pulkit, mercurial-devel
More information about the Mercurial-devel
mailing list