UI discussions for revert --interactive and uncommit --interactive

Laurent Charignon lcharignon at fb.com
Fri May 22 22:37:46 UTC 2015


Hi,

As you may have seen I worked on revert --interactive and soon I will send some patches for hg uncommit --interactive.

Both these commands raise a UI question that I have been debating with marmoute and sid0.
The --interactive session let your choose what changes are reverted. There is two main way to ask the question
We wanted to have your thoughts on it, so I put a minimal example below with the two propositions.
For the record, I want proposition 1 and marmoute wants proposition 2

# First commit an empty file
$  touch x ; hg add x ; hg commit -m "adding x"
# Add 4 lines to this file and commit
$  printf "1\n2\n3\n4\n" > x ; hg commit -m "change x"
# Show the diff of the last commit
$  hg diff -c .
diff --git a/x b/x
--- a/x
+++ b/x
@@ -0,0 +1,4 @@
+1
+2
+3
+4

# Both propositions end up with x being an empty file

# proposition 1: show the changes to be applied to the workdir
$ hg revert -i -r .^
reverting x
diff -r 38385f891157 x
1 hunks, 4 lines changed
examine changes to 'x'? [Ynesfdaq?] y

@@ -1,4 +0,0 @@
-1
-2
-3
-4
\ No newline at end of file
apply this change to 'x'? [Ynesfdaq?] y
# end of proposition 1

# proposition 2: show the change revert will cancel
$ hg revert -i -r .^
reverting x
diff -r 38385f891157 x
1 hunks, 4 lines changed
examine changes to 'x'? [Ynesfdaq?] y

@@ -1,4 +0,0 @@
+1
+2
+3
+4
\ No newline at end of file
revert this change to 'x'? [Ynesfdaq?] y
# end of proposition 2

Why proposition 1 (from Laurent)?
You see what change will be applied.
If you select a line starting with a minus, it will remove the line in the workdir.

Why proposition 2 (from Pierre-Yves)?
Proposition 2 as the advantage of using the same output as the one in `hg diff`. This allow the following mind flows:

Mind Flow 1, nuking silly changes you just spotted
1) call `hg diff`
2) spot change you want reverted
3) call `hg revert -i`
4) spot the very same change again, select them, remove them.

Having the diff in the same order in `hg diff` and `hg revert` allow you to spot the same one quickly. Otherwise the patch inversion will swap the order of line and render pattern magic quick difficult (color change is also another offuscation)

Mind Flow 2, direct cleanup:
1) You already know there is a lot of debut output in your code
2) call `hg revert -i`
3) triage before valide change and invalid change

Having the diff in the "change" order here allow you to do the triage directly, without having to reverse it in your head.

What are your thoughts on this?

Thanks!

Laurent

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150522/7363c2f3/attachment.html>


More information about the Mercurial-devel mailing list