Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 24475:06cbff4674a3
revert: fix --interactive on local modification (issue4576)
We were moving files during the backup phase and it was incompatible with the
way record/crecord is working
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Wed, 25 Mar 2015 14:01:14 -0700 |
parents | 1bf71faf042e |
children | 1378f20c8564 |
comparison
equal
deleted
inserted
replaced
24474:61a99993f8a7 | 24475:06cbff4674a3 |
---|---|
2808 wlock = repo.wlock() | 2808 wlock = repo.wlock() |
2809 try: | 2809 try: |
2810 ## filling of the `names` mapping | 2810 ## filling of the `names` mapping |
2811 # walk dirstate to fill `names` | 2811 # walk dirstate to fill `names` |
2812 | 2812 |
2813 interactive = opts.get('interactive', False) | |
2813 wctx = repo[None] | 2814 wctx = repo[None] |
2814 m = scmutil.match(wctx, pats, opts) | 2815 m = scmutil.match(wctx, pats, opts) |
2815 if not m.always(): | 2816 if not m.always(): |
2816 m.bad = lambda x, y: False | 2817 m.bad = lambda x, y: False |
2817 for abs in repo.walk(m): | 2818 for abs in repo.walk(m): |
3029 or wctx[abs].cmp(ctx[abs])): | 3030 or wctx[abs].cmp(ctx[abs])): |
3030 bakname = "%s.orig" % rel | 3031 bakname = "%s.orig" % rel |
3031 ui.note(_('saving current version of %s as %s\n') % | 3032 ui.note(_('saving current version of %s as %s\n') % |
3032 (rel, bakname)) | 3033 (rel, bakname)) |
3033 if not opts.get('dry_run'): | 3034 if not opts.get('dry_run'): |
3034 util.rename(target, bakname) | 3035 if interactive: |
3036 util.copyfile(target, bakname) | |
3037 else: | |
3038 util.rename(target, bakname) | |
3035 if ui.verbose or not exact: | 3039 if ui.verbose or not exact: |
3036 if not isinstance(msg, basestring): | 3040 if not isinstance(msg, basestring): |
3037 msg = msg(abs) | 3041 msg = msg(abs) |
3038 ui.status(msg % rel) | 3042 ui.status(msg % rel) |
3039 elif exact: | 3043 elif exact: |
3042 | 3046 |
3043 | 3047 |
3044 if not opts.get('dry_run'): | 3048 if not opts.get('dry_run'): |
3045 needdata = ('revert', 'add', 'undelete') | 3049 needdata = ('revert', 'add', 'undelete') |
3046 _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata]) | 3050 _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata]) |
3047 interactive = opts.get('interactive', False) | |
3048 _performrevert(repo, parents, ctx, actions, interactive) | 3051 _performrevert(repo, parents, ctx, actions, interactive) |
3049 | 3052 |
3050 # get the list of subrepos that must be reverted | 3053 # get the list of subrepos that must be reverted |
3051 subrepomatch = scmutil.match(wctx, pats, opts) | 3054 subrepomatch = scmutil.match(wctx, pats, opts) |
3052 targetsubs = sorted(s for s in wctx.substate if subrepomatch(s)) | 3055 targetsubs = sorted(s for s in wctx.substate if subrepomatch(s)) |