( )⚙ D6566 abort: added logic for of hg abort

This is an archive of the discontinued Mercurial Phabricator instance.

abort: added logic for of hg abort
ClosedPublic

Authored by taapas1128 on Jun 23 2019, 1:42 PM.

Details

Summary

This is part of GSoC19 project `Implement abort and
continue commands`. This patch is part of the abort plan.

This adds the basic logic for hg abort. This command
aborts an multistep operation like graft, histedit, rebase,
merge and unshelve if they are in an unfinished state.

The first part of the logic is determining the unfinished
operation from the state detection API under statemod.
This API is extended to support hg abort by adding a method
to register the abort logic as a function (here abortfunc).

Once the unfinished operation is determined the registered
logic is used to abort the command. The benefit of this kind
of framework is that any new extension developed can support
hg abort by registering the command and logic under
statedetection API.

hg abort currently supports --dry-run/-n flag only.
It is used to dry run hg abort

Further patches sequentially add support for graft, rebase,
unshelve, histedit and merge.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

taapas1128 created this revision.Jun 23 2019, 1:42 PM

Need to set the parent of this patch

@martinvonz I wanted this as a seperate stack for now so that the previous stack can be committed first. Do you want me to update its parents and add it to the previous stack?

pulkit added a subscriber: pulkit.Jun 30 2019, 3:08 PM
pulkit added inline comments.
mercurial/commands.py
147

return state.abortfunc(ui, repo, **opts) instead of storing and calling that later.

152

we should pass opts to abortfunc too. I can think of --no-backup as a flag which tells not to store a backup when aborting.

A nice addition will be --dry-run flag which tells which operation will be aborted. Also, maybe add a message saying aborting <command>.

mercurial/state.py
102

the new argument needs documentation.

136

since we will be using this argument outside of this class, let's not prepend _ to the name.

taapas1128 updated this revision to Diff 15731.Jul 1 2019, 5:49 PM
taapas1128 marked 3 inline comments as done.Jul 1 2019, 5:58 PM
pulkit added inline comments.Jul 2 2019, 5:28 PM
mercurial/commands.py
164

Arguments for abort can increase in future. Rather pass the opts directly to abort functions for now and make related functions look for flag which they need.

I agree it's not nice, but seems like a good tradeoff to start and have better code.

171

should be ui.status() instead of error.Abort()

taapas1128 retitled this revision from abort: first prototype of hg abort to abort: added logic for of hg abort.Jul 3 2019, 7:01 PM
taapas1128 edited the summary of this revision. (Show Details)
taapas1128 updated this revision to Diff 15750.
taapas1128 marked 3 inline comments as done.Jul 3 2019, 7:04 PM
taapas1128 updated this revision to Diff 15775.Jul 5 2019, 2:21 PM
pulkit added inline comments.Jul 5 2019, 5:49 PM
mercurial/commands.py
134

Can you mark this command as experimental for now, we will be close to release soon. Marking this as experimental will help us take more time to smoothen things out.

135

This help should be 'do not save backup bundle' as similar to strip command.

141

s/an/a

153

need to prepend r'' in front of dry_run for py3 compat.

164

we should return here so that abortstate.abortfunc() is not called below in case of dry-run.

taapas1128 marked 4 inline comments as done.Jul 6 2019, 2:56 PM
pulkit added a comment.Jul 9 2019, 6:25 AM

hg abort currently supports --dry-run/-n flag only.
It is used to dry run hg abort

We should specify what does dry run does i.e. it prints the operation which will be aborted if hg abort is run.

mercurial/commands.py
138

You need a space between operation and (EXPERIMENTAL)

152

%s is in progress but does not support 'hg abort'.

157

Now that we don't have backup flag, and --dry-run is tackled before calling abortfunc, we can prevent passing **opts.

taapas1128 marked 3 inline comments as done.Jul 9 2019, 8:27 AM
taapas1128 updated this revision to Diff 15836.
pulkit accepted this revision.Jul 10 2019, 8:39 AM
This revision is now accepted and ready to land.Jul 10 2019, 8:39 AM
This revision was automatically updated to reflect the committed changes.