Is this the expected revert behaviour ?

Christian Boos cboos at neuf.fr
Fri May 5 18:13:57 CDT 2006


Sébastien Pierre wrote:
> ...
> While revert has a connotation of "backward in time", update has a
> connotation of "forward in time" (but maybe it's a cultural thing) --
> but both do the same operation, the only difference being the fact that
> the parent is set or not.

You need to consider what will happen to your local modifications.

When you do an update, it's like you're moving the "referential"
of your working directory, and this can be backward or forward
in the history.
Your local changes will move along if they can be merged with
the specified rev: they will be "updated". For them, the
connotation "moved forward in time" appears legitimate.

Note that the above doesn't apply for the two other "variants"
of update:
- update -m refuses to work when there are local changes
- update -C ignores local changes, and simply moves the referential
   and reset the working directory to the content of the specified
   revision; I think it would clarify things further if there was a
   specific alias for doing this ("hg reset"?)

When you do a revert, you stay in the same referential and you
simply "revert" the changes. Again, regarding local modifications,
one could consider they were "moved backward in time".
In case you revert to a [rev], you're even moving backward further,
not only undoing your local changes, but also re-introducing
some previously existing state in your working directory.

Here's my updated proposal for the command help:

update [-b TAG] [-m] [-C] [-f] [REV]
   Change the working directory's parent revision, keeping local changes.

merge [-b TAG] [-f] [REV]
   Add an extra parent to the working directory, for preparing a merge.

reset [-b TAG] [-f] [REV]
   Reset the working directory to have a single parent and no local changes.

revert [-r REV] [NAME]…
   Change only the content of the working directory to match the one of
a revision.

>
> Put differently, if I ask somebody "what would be the difference between
> updating and reverting", should I expect "updating is a specific case of
> reverting, where the parent revision is set" as an answer ?

No, and hopefully the above made that clear :)

-- Christian




More information about the Mercurial mailing list