Show More
@@ -2246,10 +2246,14 b' def revert(ui, repo, *pats, **opts):' | |||||
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 = ([], |
|
2256 | remove = ([], removeforget) | |
2252 | forget = ([], _('forgetting %s\n')) |
|
|||
2253 | undelete = ([], _('undeleting %s\n')) |
|
2257 | undelete = ([], _('undeleting %s\n')) | |
2254 |
|
2258 | |||
2255 | disptable = ( |
|
2259 | disptable = ( | |
@@ -2260,7 +2264,7 b' def revert(ui, repo, *pats, **opts):' | |||||
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, |
|
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 | ) | |
@@ -2280,7 +2284,10 b' def revert(ui, repo, *pats, **opts):' | |||||
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 |
|
|
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 | |
@@ -2319,8 +2326,17 b' def revert(ui, repo, *pats, **opts):' | |||||
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) | |
@@ -2336,14 +2352,6 b' def revert(ui, repo, *pats, **opts):' | |||||
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 |
@@ -28,7 +28,16 b' hg status' | |||||
28 | hg revert --no-backup c |
|
28 | hg revert --no-backup c | |
29 | echo %% should show unknown: b |
|
29 | echo %% should show unknown: b | |
30 | hg status |
|
30 | hg status | |
31 | echo %% should show a b c e |
|
31 | hg add b | |
|
32 | echo %% should show b added | |||
|
33 | hg status b | |||
|
34 | rm b | |||
|
35 | echo %% should show b added | |||
|
36 | hg status b | |||
|
37 | hg revert -v b | |||
|
38 | echo %% should not find b | |||
|
39 | hg status b | |||
|
40 | echo %% should show a c e | |||
32 | ls |
|
41 | ls | |
33 | echo %% should verbosely save backup to e.orig |
|
42 | echo %% should verbosely save backup to e.orig | |
34 | echo z > e |
|
43 | echo z > e |
@@ -18,9 +18,15 b' M c' | |||||
18 | ? b |
|
18 | ? b | |
19 | %% should show unknown: b |
|
19 | %% should show unknown: b | |
20 | ? b |
|
20 | ? b | |
21 |
%% should show |
|
21 | %% should show b added | |
|
22 | A b | |||
|
23 | %% should show b added | |||
|
24 | A b | |||
|
25 | forgetting b | |||
|
26 | %% should not find b | |||
|
27 | b: No such file or directory | |||
|
28 | %% should show a c e | |||
22 | a |
|
29 | a | |
23 | b |
|
|||
24 | c |
|
30 | c | |
25 | e |
|
31 | e | |
26 | %% should verbosely save backup to e.orig |
|
32 | %% should verbosely save backup to e.orig | |
@@ -33,7 +39,6 b' file not managed: q' | |||||
33 | %% should say file not found |
|
39 | %% should say file not found | |
34 | notfound: No such file in rev 095eacd0c0d7 |
|
40 | notfound: No such file in rev 095eacd0c0d7 | |
35 | A z |
|
41 | A z | |
36 | ? b |
|
|||
37 | ? e.orig |
|
42 | ? e.orig | |
38 | %% should add a, remove d, forget z |
|
43 | %% should add a, remove d, forget z | |
39 | adding a |
|
44 | adding a |
General Comments 0
You need to be logged in to leave comments.
Login now