Mercurial > hg
changeset 2212:8164e3f31638
revert: require explicit revision when working dir has two parents.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Fri, 05 May 2006 10:31:03 -0700 |
parents | b8b7a79a4d88 |
children | 6f76a479ae51 |
files | mercurial/commands.py |
diffstat | 1 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Thu May 04 22:38:14 2006 -0700 +++ b/mercurial/commands.py Fri May 05 10:31:03 2006 -0700 @@ -2234,9 +2234,11 @@ def revert(ui, repo, *pats, **opts): """revert modified files or dirs to their states as of some revision - By default, revert the named files or directories to the contents - they had in the parent of the working directory. This restores - the contents of the affected files to an unmodified state. + With no revision specified, revert the named files or directories + to the contents they had in the parent of the working directory. + This restores the contents of the affected files to an unmodified + state. If the working directory has two parents, you must + explicitly specify the revision to revert to. Modified files are saved with a .orig suffix before reverting. To disable these backups, use --no-backup. @@ -2258,8 +2260,14 @@ If no arguments are given, all files in the repository are reverted. """ - parent = repo.dirstate.parents()[0] - node = opts['rev'] and repo.lookup(opts['rev']) or parent + parent, p2 = repo.dirstate.parents() + if opts['rev']: + node = repo.lookup(opts['rev']) + elif p2 != nullid: + raise util.Abort(_('working dir has two parents; ' + 'you must specify the revision to revert to')) + else: + node = parent mf = repo.manifest.read(repo.changelog.read(node)[0]) wlock = repo.wlock()