Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 14726:e0039716f3ea stable
revert: mention update in hint of abort when reverting to non-parent
and explicitly warn about uncommitted changes
Examples:
BEFORE:
$ hg par -q
7:e81a2efd53d4
$ hg revert -r 2
abort: no files or directories specified
(use --all to discard all changes)
AFTER:
Clean working directory (revert can be easily undone, no edits to be lost):
$ hg revert -r 2
abort: no files or directories specified
(use --all to revert all files, or 'hg update 2' to update)
Uncommitted changes (revert --all *does* discard edits and is pretty hard to
undo or even impossible if --no-backup is specified):
$ hg revert -r 2
abort: no files or directories specified
(uncommitted changes, use --all to discard all changes, or 'hg update 2' to update)
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Fri, 24 Jun 2011 12:37:29 +0200 |
parents | 2852933fc942 |
children | 94eea58da2a3 |
comparison
equal
deleted
inserted
replaced
14725:2852933fc942 | 14726:e0039716f3ea |
---|---|
4177 if opts.get("rev"): | 4177 if opts.get("rev"): |
4178 raise util.Abort(_("you can't specify a revision and a date")) | 4178 raise util.Abort(_("you can't specify a revision and a date")) |
4179 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) | 4179 opts["rev"] = cmdutil.finddate(ui, repo, opts["date"]) |
4180 | 4180 |
4181 parent, p2 = repo.dirstate.parents() | 4181 parent, p2 = repo.dirstate.parents() |
4182 ctx = scmutil.revsingle(repo, opts.get('rev')) | |
4183 node = ctx.node() | |
4182 | 4184 |
4183 if not pats and not opts.get('all'): | 4185 if not pats and not opts.get('all'): |
4184 msg = _("no files or directories specified") | 4186 msg = _("no files or directories specified") |
4185 hint = _("use --all to discard all changes") | 4187 hint = _("use --all to discard all changes") |
4186 if p2 != nullid: | 4188 if p2 != nullid: |
4187 hint = _("uncommitted merge, use --all to discard all changes," | 4189 hint = _("uncommitted merge, use --all to discard all changes," |
4188 " or 'hg update -C .' to abort the merge") | 4190 " or 'hg update -C .' to abort the merge") |
4191 elif node != parent: | |
4192 if util.any(repo.status()): | |
4193 hint = _("uncommitted changes, use --all to discard all" | |
4194 " changes, or 'hg update %s' to update") % ctx.rev() | |
4195 else: | |
4196 hint = _("use --all to revert all files," | |
4197 " or 'hg update %s' to update") % ctx.rev() | |
4189 raise util.Abort(msg, hint=hint) | 4198 raise util.Abort(msg, hint=hint) |
4190 | 4199 |
4191 ctx = scmutil.revsingle(repo, opts.get('rev')) | |
4192 node = ctx.node() | |
4193 mf = ctx.manifest() | 4200 mf = ctx.manifest() |
4194 if node == parent: | 4201 if node == parent: |
4195 pmf = mf | 4202 pmf = mf |
4196 else: | 4203 else: |
4197 pmf = None | 4204 pmf = None |