hginit.com, revert vs update

Mads Kiilerich mads at kiilerich.com
Thu Aug 4 11:21:50 UTC 2011


On 08/04/2011 12:46 PM, 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".

The main difference is that 'hg update' changes the parent revision of 
the working directory - and then it updates the working directory 
correspondingly (by "merging" uncommitted changes in the working 
directory with the new parent version).

'hg revert' only changes the working directory content without changing 
the parent revision. Reverting to the parent revision is a great way to 
loose uncommitted changes (like 'hg update -C' is), and reverting to 
other revisions is a great way to make a terrible mess (or make some 
clever hacks).

Another difference (that follows from that) is that 'hg update' works on 
the whole repository while 'hg revert' can mess with individual files.

/Mads



More information about the Mercurial mailing list