Show More
@@ -2782,6 +2782,7 b' def revert(ui, repo, ctx, parents, *pats' | |||
|
2782 | 2782 | # The mapping is in the form: |
|
2783 | 2783 | # <abs path in repo> -> (<path from CWD>, <exactly specified by matcher?>) |
|
2784 | 2784 | names = {} |
|
2785 | uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True) | |
|
2785 | 2786 | |
|
2786 | 2787 | with repo.wlock(): |
|
2787 | 2788 | ## filling of the `names` mapping |
@@ -2797,7 +2798,7 b' def revert(ui, repo, ctx, parents, *pats' | |||
|
2797 | 2798 | if not m.always(): |
|
2798 | 2799 | matcher = matchmod.badmatch(m, lambda x, y: False) |
|
2799 | 2800 | for abs in wctx.walk(matcher): |
|
2800 |
names[abs] = m. |
|
|
2801 | names[abs] = m.exact(abs) | |
|
2801 | 2802 | |
|
2802 | 2803 | # walk target manifest to fill `names` |
|
2803 | 2804 | |
@@ -2814,7 +2815,7 b' def revert(ui, repo, ctx, parents, *pats' | |||
|
2814 | 2815 | |
|
2815 | 2816 | for abs in ctx.walk(matchmod.badmatch(m, badfn)): |
|
2816 | 2817 | if abs not in names: |
|
2817 |
names[abs] = m. |
|
|
2818 | names[abs] = m.exact(abs) | |
|
2818 | 2819 | |
|
2819 | 2820 | # Find status of all file in `names`. |
|
2820 | 2821 | m = scmutil.matchfiles(repo, names) |
@@ -2825,7 +2826,7 b' def revert(ui, repo, ctx, parents, *pats' | |||
|
2825 | 2826 | changes = repo.status(node1=node, match=m) |
|
2826 | 2827 | for kind in changes: |
|
2827 | 2828 | for abs in kind: |
|
2828 |
names[abs] = m. |
|
|
2829 | names[abs] = m.exact(abs) | |
|
2829 | 2830 | |
|
2830 | 2831 | m = scmutil.matchfiles(repo, names) |
|
2831 | 2832 | |
@@ -2887,13 +2888,12 b' def revert(ui, repo, ctx, parents, *pats' | |||
|
2887 | 2888 | dsmodified -= mergeadd |
|
2888 | 2889 | |
|
2889 | 2890 | # if f is a rename, update `names` to also revert the source |
|
2890 | cwd = repo.getcwd() | |
|
2891 | 2891 | for f in localchanges: |
|
2892 | 2892 | src = repo.dirstate.copied(f) |
|
2893 | 2893 | # XXX should we check for rename down to target node? |
|
2894 | 2894 | if src and src not in names and repo.dirstate[src] == 'r': |
|
2895 | 2895 | dsremoved.add(src) |
|
2896 |
names[src] = |
|
|
2896 | names[src] = True | |
|
2897 | 2897 | |
|
2898 | 2898 | # determine the exact nature of the deleted changesets |
|
2899 | 2899 | deladded = set(_deleted) |
@@ -3000,7 +3000,7 b' def revert(ui, repo, ctx, parents, *pats' | |||
|
3000 | 3000 | (unknown, actions['unknown'], discard), |
|
3001 | 3001 | ) |
|
3002 | 3002 | |
|
3003 |
for abs, |
|
|
3003 | for abs, exact in sorted(names.items()): | |
|
3004 | 3004 | # target file to be touch on disk (relative to cwd) |
|
3005 | 3005 | target = repo.wjoin(abs) |
|
3006 | 3006 | # search the entry in the dispatch table. |
@@ -3017,20 +3017,21 b' def revert(ui, repo, ctx, parents, *pats' | |||
|
3017 | 3017 | if dobackup == backupinteractive: |
|
3018 | 3018 | tobackup.add(abs) |
|
3019 | 3019 | elif (backup <= dobackup or wctx[abs].cmp(ctx[abs])): |
|
3020 | bakname = scmutil.backuppath(ui, repo, abs) | |
|
3021 |
|
|
|
3020 | absbakname = scmutil.backuppath(ui, repo, abs) | |
|
3021 | bakname = os.path.relpath(absbakname, | |
|
3022 | start=repo.root) | |
|
3022 | 3023 | ui.note(_('saving current version of %s as %s\n') % |
|
3023 |
( |
|
|
3024 | (uipathfn(abs), uipathfn(bakname))) | |
|
3024 | 3025 | if not opts.get('dry_run'): |
|
3025 | 3026 | if interactive: |
|
3026 | util.copyfile(target, bakname) | |
|
3027 | util.copyfile(target, absbakname) | |
|
3027 | 3028 | else: |
|
3028 | util.rename(target, bakname) | |
|
3029 | util.rename(target, absbakname) | |
|
3029 | 3030 | if opts.get('dry_run'): |
|
3030 | 3031 | if ui.verbose or not exact: |
|
3031 |
ui.status(msg % |
|
|
3032 | ui.status(msg % uipathfn(abs)) | |
|
3032 | 3033 | elif exact: |
|
3033 |
ui.warn(msg % |
|
|
3034 | ui.warn(msg % uipathfn(abs)) | |
|
3034 | 3035 | break |
|
3035 | 3036 | |
|
3036 | 3037 | if not opts.get('dry_run'): |
@@ -3041,8 +3042,8 b' def revert(ui, repo, ctx, parents, *pats' | |||
|
3041 | 3042 | prefetch(repo, [ctx.rev()], |
|
3042 | 3043 | matchfiles(repo, |
|
3043 | 3044 | [f for sublist in oplist for f in sublist])) |
|
3044 |
_performrevert(repo, parents, ctx, names, actions, |
|
|
3045 | tobackup) | |
|
3045 | _performrevert(repo, parents, ctx, names, uipathfn, actions, | |
|
3046 | interactive, tobackup) | |
|
3046 | 3047 | |
|
3047 | 3048 | if targetsubs: |
|
3048 | 3049 | # Revert the subrepos on the revert list |
@@ -3054,8 +3055,8 b' def revert(ui, repo, ctx, parents, *pats' | |||
|
3054 | 3055 | raise error.Abort("subrepository '%s' does not exist in %s!" |
|
3055 | 3056 | % (sub, short(ctx.node()))) |
|
3056 | 3057 | |
|
3057 |
def _performrevert(repo, parents, ctx, names, actions, |
|
|
3058 | tobackup=None): | |
|
3058 | def _performrevert(repo, parents, ctx, names, uipathfn, actions, | |
|
3059 | interactive=False, tobackup=None): | |
|
3059 | 3060 | """function that actually perform all the actions computed for revert |
|
3060 | 3061 | |
|
3061 | 3062 | This is an independent function to let extension to plug in and react to |
@@ -3080,15 +3081,15 b' def _performrevert(repo, parents, ctx, n' | |||
|
3080 | 3081 | repo.dirstate.remove(f) |
|
3081 | 3082 | |
|
3082 | 3083 | def prntstatusmsg(action, f): |
|
3083 |
|
|
|
3084 | exact = names[f] | |
|
3084 | 3085 | if repo.ui.verbose or not exact: |
|
3085 |
repo.ui.status(actions[action][1] % |
|
|
3086 | repo.ui.status(actions[action][1] % uipathfn(f)) | |
|
3086 | 3087 | |
|
3087 | 3088 | audit_path = pathutil.pathauditor(repo.root, cached=True) |
|
3088 | 3089 | for f in actions['forget'][0]: |
|
3089 | 3090 | if interactive: |
|
3090 | 3091 | choice = repo.ui.promptchoice( |
|
3091 | _("forget added file %s (Yn)?$$ &Yes $$ &No") % f) | |
|
3092 | _("forget added file %s (Yn)?$$ &Yes $$ &No") % uipathfn(f)) | |
|
3092 | 3093 | if choice == 0: |
|
3093 | 3094 | prntstatusmsg('forget', f) |
|
3094 | 3095 | repo.dirstate.drop(f) |
@@ -3101,7 +3102,7 b' def _performrevert(repo, parents, ctx, n' | |||
|
3101 | 3102 | audit_path(f) |
|
3102 | 3103 | if interactive: |
|
3103 | 3104 | choice = repo.ui.promptchoice( |
|
3104 | _("remove added file %s (Yn)?$$ &Yes $$ &No") % f) | |
|
3105 | _("remove added file %s (Yn)?$$ &Yes $$ &No") % uipathfn(f)) | |
|
3105 | 3106 | if choice == 0: |
|
3106 | 3107 | prntstatusmsg('remove', f) |
|
3107 | 3108 | doremove(f) |
@@ -289,6 +289,23 b' Issue332: confusing message when reverti' | |||
|
289 | 289 | $ hg revert . |
|
290 | 290 | reverting b/b |
|
291 | 291 | |
|
292 | respects ui.relative-paths | |
|
293 | -------------------------- | |
|
294 | ||
|
295 | $ echo foo > newdir/newfile | |
|
296 | $ hg add newdir/newfile | |
|
297 | $ hg revert --all --cwd newdir | |
|
298 | forgetting newfile | |
|
299 | ||
|
300 | $ echo foo > newdir/newfile | |
|
301 | $ hg add newdir/newfile | |
|
302 | $ hg revert --all --cwd newdir --config ui.relative-paths=True | |
|
303 | forgetting newfile | |
|
304 | ||
|
305 | $ echo foo > newdir/newfile | |
|
306 | $ hg add newdir/newfile | |
|
307 | $ hg revert --all --cwd newdir --config ui.relative-paths=False | |
|
308 | forgetting newdir/newfile | |
|
292 | 309 | |
|
293 | 310 | reverting a rename target should revert the source |
|
294 | 311 | -------------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now