Undo a commit?

Matt Mackall mpm at selenic.com
Wed Jul 15 13:06:54 CDT 2009


On Wed, 2009-07-15 at 05:36 -0700, rupert.thurner wrote:
> On Jul 15, 12:38 am, Martin Geisler <m... at lazybytes.net> wrote:
> > "rupert.thurner" <rupert.thur... at gmail.com> writes:
> > > is strip the same as rollback? and if yes why it has a different name?
> >
> > They overlap a bit, but are really quite different:
> >
> > * 'hg rollback' will remove the last transaction. Transactions are a
> >   concept often found in databases. In Mercurial we start a transaction
> >   when certain operations are run, such as commit, push, pull...
> >
> >   When the operation finishes succesfully, the transaction is marked as
> >   complete. If an error occurs, the transaction is "rolled back" and the
> >   repository is left in the same state as before.
> >
> >   You can manually trigger a rollback with 'hg rollback'. This will undo
> >   the last transactional command. If a pull command brought 10 new
> >   changesets into the repository on different branches, then 'hg
> >   rollback' will remove them all.
> >
> >   Please not: there is *no backup* when you rollback a transaction!
> >
> > * 'hg strip' will remove a changeset and all its descendants. The
> >   changesets are saved as a bundle, which you can apply again if you
> >   need them back.
> >
> > --
> > Martin Geisler
> 
> you are so right with your explanation, but our users feel that
> stripping the last changeset and rolling back the last change set both
> remove the last change set. and they ask, and they get a lengthy
> explanation.
> 
> and they do not understand the various concepts of "backup". one time
> its a .rej, then a .orig, then a bundle. they learn that "purge"
> removes all these backups, but it is not valid for all of them, e.g.
> strip bundles. merges which are not done need to be stopped with up --
> clean.

Both .rej and .orig files are standards that predate Mercurial by
decades.

Purge is not part of hg, it is an extension. It is explicitly not
recommended for anyone who is not already comfortable with Mercurial's
core functionality. Therefore, you do not get to complain about it being
confusing to beginners.

Strip is not part of hg either, and it's also only for advanced users.
Telling a beginner to use strip is like handing them a loaded gun.[1]

> if one looks at the wealth of commands in mercurial, it became quite a
> challenge to get into it.  just to name a couple of examples:
> 
> * complicated command to do something simple and often needed:
>   hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip

Mq is also an extension. It is explicitly for power users.

> * different commands for approximately the same thing, e.g. undo/
> clean:
>   hg revert, hg backout, hg strip, hg rollback, hg update --clean, hg
> purge

Rollback, as the only history-destroying command in the core command
set, is also recommended only for experts.

Revert and backout are also intended for advanced users, which is why
they're not listed in the short command list. Basically everything you'd
ever need to do in hg can be accomplished with the commands in the short
command list with no extensions.

Which leaves update -C, which is pretty straightforward.

> * asymetries:
>   hg branch to create a branch
>   hg commit to close it

There's a corresponding asymmetry that most branches you open should
never get closed so I'm not really concerned about this one.

> what would be the best strategy to reduce the command and option set
> and make it more intuitive?

Reducing the command set is not on the table, as it breaks our backwards
compatibility rules.

[1] Hey list folks: stop recommending strip and rollback to people as
the first course of action. They are really good ways for people to
shoot themselves in the foot and have a bad Mercurial experience. There
are alternatives that are safer for new users; if you don't know what
they are, then you are not expert enough to be advising people to use
strip.

-- 
http://selenic.com : development and support for Mercurial and Linux




More information about the Mercurial mailing list