[UX] history of user operations and undo/redo

anatoly techtonik techtonik at gmail.com
Thu Nov 21 03:35:36 CST 2013


I had trouble trying to understand how can I undo 'hg fold' operation
from new ChangesetEvolution concept. Should it be 'rollback',
'revert', 'update -C' or some new command? I really either don't know
or don't remember, or just can't figure out, because I miss some
details about HG internals from my education.

So I though that the next step in Mercurial evolution could be going
from "user command" to "user operation" concept.

Right now users type commands. Some affect the state of repository,
some are not. It is good when "user command" that modifies state has
"reverse command" that brings the changes back to the initial state.
But maintaining this on command level is too fine-grained, tedious and
fragile (and remembering all command/reverse pairs is hard).

"user operation" - is a set of changes that Mercurial does to
repository as a result of user command(s). Granularity is decided on
user level with the sole goal to provide ground for undo and redo of
these operations. For example 'hg fold' is an operation that can be
undone. It is a separate "user operation" and an entry in "undo
history".

"undo history" is a stack of "user operations". These can be undone or
not. It depends on the logic. It is not a commit log - it is
operations log. The direct analogy is GIMP undo history dialog.

http://docs.gimp.org/en/gimp-undo-dialog.html

>From the usability POV, a mercurial operations history dialog is a
list, where every entry contains:
- operation name
- if it can be undone
  - if not, state the reason
    the reason is necessary to understand either:
       1. current condition of repository
           - what should be adjusted to enable undo
           - why adjustment can not be automated
       2. what should be written in hg itself to make it possible
           - pointer to dev docs and status page

Summary:
 * user command ('hg inc', 'hg ci', ...)
 * user operation (hg command that changes state)
 * undo history (stack of latest user operations)
   * undo history items are frozen if reverting is impossible
   * undo history is local

https://www.google.by/search?q=undo+pattern
https://bitbucket.org/hstuart/hg-multiundo

The final test:
 hg undo
 hg redo
 hg undo --list

Please, CC.
--
anatoly t.


More information about the Mercurial mailing list