Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 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 | eb5fa83ffcfa |
children | 4f072bb06e89 |
comparison
equal
deleted
inserted
replaced
2211:b8b7a79a4d88 | 2212:8164e3f31638 |
---|---|
2232 return errs | 2232 return errs |
2233 | 2233 |
2234 def revert(ui, repo, *pats, **opts): | 2234 def revert(ui, repo, *pats, **opts): |
2235 """revert modified files or dirs to their states as of some revision | 2235 """revert modified files or dirs to their states as of some revision |
2236 | 2236 |
2237 By default, revert the named files or directories to the contents | 2237 With no revision specified, revert the named files or directories |
2238 they had in the parent of the working directory. This restores | 2238 to the contents they had in the parent of the working directory. |
2239 the contents of the affected files to an unmodified state. | 2239 This restores the contents of the affected files to an unmodified |
2240 state. If the working directory has two parents, you must | |
2241 explicitly specify the revision to revert to. | |
2240 | 2242 |
2241 Modified files are saved with a .orig suffix before reverting. | 2243 Modified files are saved with a .orig suffix before reverting. |
2242 To disable these backups, use --no-backup. | 2244 To disable these backups, use --no-backup. |
2243 | 2245 |
2244 Using the -r option, revert the given files or directories to | 2246 Using the -r option, revert the given files or directories to |
2256 | 2258 |
2257 If names are given, all files matching the names are reverted. | 2259 If names are given, all files matching the names are reverted. |
2258 | 2260 |
2259 If no arguments are given, all files in the repository are reverted. | 2261 If no arguments are given, all files in the repository are reverted. |
2260 """ | 2262 """ |
2261 parent = repo.dirstate.parents()[0] | 2263 parent, p2 = repo.dirstate.parents() |
2262 node = opts['rev'] and repo.lookup(opts['rev']) or parent | 2264 if opts['rev']: |
2265 node = repo.lookup(opts['rev']) | |
2266 elif p2 != nullid: | |
2267 raise util.Abort(_('working dir has two parents; ' | |
2268 'you must specify the revision to revert to')) | |
2269 else: | |
2270 node = parent | |
2263 mf = repo.manifest.read(repo.changelog.read(node)[0]) | 2271 mf = repo.manifest.read(repo.changelog.read(node)[0]) |
2264 | 2272 |
2265 wlock = repo.wlock() | 2273 wlock = repo.wlock() |
2266 | 2274 |
2267 # need all matching names in dirstate and manifest of target rev, | 2275 # need all matching names in dirstate and manifest of target rev, |