hginit.com, revert vs update

Adrian Buehlmann adrian at cadifra.com
Thu Aug 4 11:57:03 UTC 2011


On 2011-08-04 12:46, Mihamina Rakotomandimby wrote:
> Hi all,
> 
> Looking at: http://hginit.com/01.html
> I see in the "hg revert" section:
> [...]
> So, when you’re working on source code with Mercurial:
>      1. Make some changes
>      2. See if they work
>      3. If they do, commit them
>      4. If they don’t, revert them
>      5. GOTO 1
> [...]
> 
> It's alright, I understand.
> what's the difference between "revert" and "update" then?

..

> Because I have the same behaviour if I replace "revert" with "update".

'hg revert -a --no-backup' is indeed equivalent to 'hg update -C .'

But 'update' can be used to safely switch the parent revision, whereas
revert will never switch the parent (see 'hg parents' -- there can be two).

If you use revert with a target revision other than the parent revision
(option -r), you will introduce (uncommitted) changes (compared to the
working directory parent -- see 'hg status' and 'hg diff').

See 'hg help revert' for the details.

BTW, the help text of 'hg revert' (and some warnings when using it) has
been much improved for Mercurial 1.9, so make sure you've got that
version (latest bugfix release is 1.9.1).

Or read it online: http://selenic.com/repo/hg/help/revert

hg help revert

  hg revert [OPTION]... [-r REV] [NAME]...

  restore files to their checkout state

hg help update

  hg update [-c] [-C] [-d DATE] [[-r] REV]

  update working directory (or switch revisions)



More information about the Mercurial mailing list