This is an archive of the discontinued Mercurial Phabricator instance.

abort: added support for merge
ClosedPublic

Authored by taapas1128 on Jun 29 2019, 3:38 PM.

Details

Summary

This adds support of hg merge --abort to hg abort plan.

This involves refactoring hg.merge into two different
functions removing the abort logic of merge from hg.merge
and then creating a seperate hg.abortmerge to handle the
abort logic so that the abortion of merge can be called
independently.

hg.abortmerge is then registered as abortfunc for the
state detection API so that commands.abort can use it to
deal with an unfinished merge operation.

Results are shown as tests.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

taapas1128 created this revision.Jun 29 2019, 3:38 PM
pulkit added a subscriber: pulkit.Jun 30 2019, 3:23 PM
pulkit added inline comments.
mercurial/commands.py
151

let's refactor some code and create a function for merge abort instead of special casing it.

mercurial/hg.py
958–959

We can compute node required here again, and hence take this abort related code into a separate function.

taapas1128 updated this revision to Diff 15749.Jul 2 2019, 4:00 PM
taapas1128 marked 2 inline comments as done.Jul 2 2019, 4:01 PM
pulkit added inline comments.Jul 2 2019, 5:51 PM
mercurial/hg.py
959

we can directly pass repo.ui here. No need to have a ui variable

959

we actually don't need stats back here is we call _showstats() in abort merge. The stats related lines below can be moved to if condition above. Hence removing the asflag argument.

taapas1128 edited the summary of this revision. (Show Details)Jul 3 2019, 7:02 PM
taapas1128 updated this revision to Diff 15755.
taapas1128 marked 2 inline comments as done.Jul 3 2019, 7:07 PM
taapas1128 updated this revision to Diff 15760.Jul 4 2019, 1:29 PM
pulkit added inline comments.Jul 4 2019, 1:38 PM
tests/test-commit-unresolved.t
51

since there are only two cases, you can use #else here.

150

We can put only the command in if and else part. The output is same on the both sides.

pulkit added inline comments.Jul 4 2019, 1:40 PM
tests/test-commit-unresolved.t
2

abortcommand will be better name instead of hgabort as that will match the way we named abortflag and will be more easier to realise the difference between them.

taapas1128 updated this revision to Diff 15761.Jul 4 2019, 1:45 PM
taapas1128 marked 3 inline comments as done.Jul 4 2019, 1:48 PM
taapas1128 marked an inline comment as not done.
pulkit added inline comments.Jul 4 2019, 1:49 PM
tests/test-commit-unresolved.t
46–47

hg abort can be used. we can case the output here.

taapas1128 updated this revision to Diff 15770.Jul 4 2019, 5:08 PM
taapas1128 marked 2 inline comments as done.Jul 4 2019, 5:10 PM
taapas1128 updated this revision to Diff 15783.Jul 6 2019, 2:55 PM
taapas1128 edited the summary of this revision. (Show Details)Jul 8 2019, 2:18 PM
taapas1128 updated this revision to Diff 15808.
taapas1128 edited the summary of this revision. (Show Details)Jul 9 2019, 8:25 AM
taapas1128 updated this revision to Diff 15835.
pulkit accepted this revision.Jul 10 2019, 8:58 AM
This revision is now accepted and ready to land.Jul 10 2019, 8:58 AM
pulkit added inline comments.Jul 10 2019, 1:12 PM
mercurial/hg.py
985

We lost return stats.unresolvedcount > 0 in this code movement.

taapas1128 updated this revision to Diff 15858.Jul 10 2019, 2:22 PM
taapas1128 marked an inline comment as done.Jul 10 2019, 2:22 PM
taapas1128 updated this revision to Diff 15867.Jul 10 2019, 3:35 PM
pulkit requested changes to this revision.Jul 10 2019, 4:25 PM
pulkit added inline comments.
mercurial/hg.py
985

This is not yet addressed.

This revision now requires changes to proceed.Jul 10 2019, 4:25 PM
taapas1128 updated this revision to Diff 15879.Jul 10 2019, 4:40 PM
taapas1128 marked an inline comment as done.Jul 10 2019, 4:41 PM
pulkit added inline comments.Jul 10 2019, 4:46 PM
mercurial/hg.py
987

Here the user is already running hg merge --abort, so we should not show this message.

Ideally, this if condition should not never when aborting a merge.

pulkit accepted this revision.Jul 10 2019, 4:50 PM
pulkit added inline comments.
mercurial/hg.py
987

Turns out I am blind and the previous version already had everything correct. I will either apply previous version of fix things in flight.

This revision is now accepted and ready to land.Jul 10 2019, 4:50 PM
taapas1128 updated this revision to Diff 15880.Jul 10 2019, 4:52 PM
taapas1128 marked an inline comment as done.Jul 10 2019, 4:55 PM
This revision was automatically updated to reflect the committed changes.