Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 6109:242595e612ed
revert: unify forget and remove lists
This doesn't make a difference right now, but after the next revision
some files in state 'a' may end up in the deleted list, and revert
won't be able to just remove all files in that list.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Thu, 14 Feb 2008 18:08:16 -0200 |
parents | 5086576a2152 |
children | 779f2309d67a |
comparison
equal
deleted
inserted
replaced
6108:5086576a2152 | 6109:242595e612ed |
---|---|
2244 src = repo.dirstate.copied(f) | 2244 src = repo.dirstate.copied(f) |
2245 if src and src not in names and repo.dirstate[src] == 'r': | 2245 if src and src not in names and repo.dirstate[src] == 'r': |
2246 removed[src] = None | 2246 removed[src] = None |
2247 names[src] = (repo.pathto(src, cwd), True) | 2247 names[src] = (repo.pathto(src, cwd), True) |
2248 | 2248 |
2249 def removeforget(abs): | |
2250 if repo.dirstate[abs] == 'a': | |
2251 return _('forgetting %s\n') | |
2252 return _('removing %s\n') | |
2253 | |
2249 revert = ([], _('reverting %s\n')) | 2254 revert = ([], _('reverting %s\n')) |
2250 add = ([], _('adding %s\n')) | 2255 add = ([], _('adding %s\n')) |
2251 remove = ([], _('removing %s\n')) | 2256 remove = ([], removeforget) |
2252 forget = ([], _('forgetting %s\n')) | |
2253 undelete = ([], _('undeleting %s\n')) | 2257 undelete = ([], _('undeleting %s\n')) |
2254 | 2258 |
2255 disptable = ( | 2259 disptable = ( |
2256 # dispatch table: | 2260 # dispatch table: |
2257 # file state | 2261 # file state |
2258 # action if in target manifest | 2262 # action if in target manifest |
2259 # action if not in target manifest | 2263 # action if not in target manifest |
2260 # make backup if in target manifest | 2264 # make backup if in target manifest |
2261 # make backup if not in target manifest | 2265 # make backup if not in target manifest |
2262 (modified, revert, remove, True, True), | 2266 (modified, revert, remove, True, True), |
2263 (added, revert, forget, True, False), | 2267 (added, revert, remove, True, False), |
2264 (removed, undelete, None, False, False), | 2268 (removed, undelete, None, False, False), |
2265 (deleted, revert, remove, False, False), | 2269 (deleted, revert, remove, False, False), |
2266 ) | 2270 ) |
2267 | 2271 |
2268 entries = names.items() | 2272 entries = names.items() |
2278 ui.note(_('saving current version of %s as %s\n') % | 2282 ui.note(_('saving current version of %s as %s\n') % |
2279 (rel, bakname)) | 2283 (rel, bakname)) |
2280 if not opts.get('dry_run'): | 2284 if not opts.get('dry_run'): |
2281 util.copyfile(target, bakname) | 2285 util.copyfile(target, bakname) |
2282 if ui.verbose or not exact: | 2286 if ui.verbose or not exact: |
2283 ui.status(xlist[1] % rel) | 2287 msg = xlist[1] |
2288 if not isinstance(msg, basestring): | |
2289 msg = msg(abs) | |
2290 ui.status(msg % rel) | |
2284 for table, hitlist, misslist, backuphit, backupmiss in disptable: | 2291 for table, hitlist, misslist, backuphit, backupmiss in disptable: |
2285 if abs not in table: continue | 2292 if abs not in table: continue |
2286 # file has changed in dirstate | 2293 # file has changed in dirstate |
2287 if mfentry: | 2294 if mfentry: |
2288 handle(hitlist, backuphit) | 2295 handle(hitlist, backuphit) |
2317 if not opts.get('dry_run'): | 2324 if not opts.get('dry_run'): |
2318 def checkout(f): | 2325 def checkout(f): |
2319 fc = ctx[f] | 2326 fc = ctx[f] |
2320 repo.wwrite(f, fc.data(), fc.fileflags()) | 2327 repo.wwrite(f, fc.data(), fc.fileflags()) |
2321 | 2328 |
2322 for f in forget[0]: | 2329 audit_path = util.path_auditor(repo.root) |
2323 repo.dirstate.forget(f) | 2330 for f in remove[0]: |
2331 if repo.dirstate[f] == 'a': | |
2332 repo.dirstate.forget(f) | |
2333 continue | |
2334 audit_path(f) | |
2335 try: | |
2336 util.unlink(repo.wjoin(f)) | |
2337 except OSError: | |
2338 pass | |
2339 repo.dirstate.remove(f) | |
2324 | 2340 |
2325 for f in revert[0]: | 2341 for f in revert[0]: |
2326 checkout(f) | 2342 checkout(f) |
2327 | 2343 |
2328 for f in add[0]: | 2344 for f in add[0]: |
2334 normal = repo.dirstate.normal | 2350 normal = repo.dirstate.normal |
2335 for f in undelete[0]: | 2351 for f in undelete[0]: |
2336 checkout(f) | 2352 checkout(f) |
2337 normal(f) | 2353 normal(f) |
2338 | 2354 |
2339 audit_path = util.path_auditor(repo.root) | |
2340 for f in remove[0]: | |
2341 audit_path(f) | |
2342 try: | |
2343 util.unlink(repo.wjoin(f)) | |
2344 except OSError: | |
2345 pass | |
2346 repo.dirstate.remove(f) | |
2347 finally: | 2355 finally: |
2348 del wlock | 2356 del wlock |
2349 | 2357 |
2350 def rollback(ui, repo): | 2358 def rollback(ui, repo): |
2351 """roll back the last transaction | 2359 """roll back the last transaction |