comparison mercurial/commands.py @ 14542:afe0d4c24866

revert: drop requirement to use -r to revert with two parents This reduces documentation confusion between the need to: a) hg revert -a -r . (drop all changes from a merge) b) hg up -C . (drop the second parent entirely) Currently revert is one of two commands (the other being tag) that still complains about uncommitted merges, dating from its former use of a generic defaultrev function that aborted.
author Matt Mackall <mpm@selenic.com>
date Tue, 07 Jun 2011 14:19:05 -0500
parents 07ee46a2ece3
children 691925bd8bb8
comparison
equal deleted inserted replaced
14541:07ee46a2ece3 14542:afe0d4c24866
4091 .. note:: 4091 .. note::
4092 To check out earlier revisions, you should use :hg:`update REV`. 4092 To check out earlier revisions, you should use :hg:`update REV`.
4093 To cancel a merge (and lose your changes), use :hg:`update --clean .`. 4093 To cancel a merge (and lose your changes), use :hg:`update --clean .`.
4094 4094
4095 With no revision specified, revert the named files or directories 4095 With no revision specified, revert the named files or directories
4096 to the contents they had in the parent of the working directory. 4096 to the contents they had in the first parent of the working directory.
4097 This restores the contents of the affected files to an unmodified 4097 This restores the contents of the affected files to an unmodified
4098 state and unschedules adds, removes, copies, and renames. If the 4098 state and unschedules adds, removes, copies, and renames.
4099 working directory has two parents, you must explicitly specify a
4100 revision.
4101 4099
4102 Using the -r/--rev option, revert the given files or directories 4100 Using the -r/--rev option, revert the given files or directories
4103 to their contents as of a specific revision. This can be helpful 4101 to their contents as of a specific revision. This can be helpful
4104 to "roll back" some or all of an earlier change. See :hg:`help 4102 to "roll back" some or all of an earlier change. See :hg:`help
4105 dates` for a list of formats valid for -d/--date. 4103 dates` for a list of formats valid for -d/--date.
4127 if opts.get("rev"): 4125 if opts.get("rev"):
4128 raise util.Abort(_("you can't specify a revision and a date")) 4126 raise util.Abort(_("you can't specify a revision and a date"))
4129 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) 4127 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
4130 4128
4131 parent, p2 = repo.dirstate.parents() 4129 parent, p2 = repo.dirstate.parents()
4132 if not opts.get('rev') and p2 != nullid:
4133 raise util.Abort(_('uncommitted merge - '
4134 'use "hg update", see "hg help revert"'))
4135 4130
4136 if not pats and not opts.get('all'): 4131 if not pats and not opts.get('all'):
4137 raise util.Abort(_('no files or directories specified; ' 4132 raise util.Abort(_('no files or directories specified'),
4138 'use --all to revert the whole repo')) 4133 hint=_('use --all to revert all files'))
4139 4134
4140 ctx = scmutil.revsingle(repo, opts.get('rev')) 4135 ctx = scmutil.revsingle(repo, opts.get('rev'))
4141 node = ctx.node() 4136 node = ctx.node()
4142 mf = ctx.manifest() 4137 mf = ctx.manifest()
4143 if node == parent: 4138 if node == parent: