comparison mercurial/cmdutil.py @ 24479:871485bd03fd

revert: move calculation of targetsubs earlier
author Matt Mackall <mpm@selenic.com>
date Fri, 27 Mar 2015 13:48:51 -0500
parents 1378f20c8564
children 3df7fc75afc5
comparison
equal deleted inserted replaced
24478:95cbc77c0cad 24479:871485bd03fd
2809 # walk dirstate to fill `names` 2809 # walk dirstate to fill `names`
2810 2810
2811 interactive = opts.get('interactive', False) 2811 interactive = opts.get('interactive', False)
2812 wctx = repo[None] 2812 wctx = repo[None]
2813 m = scmutil.match(wctx, pats, opts) 2813 m = scmutil.match(wctx, pats, opts)
2814
2815 # we'll need this later
2816 targetsubs = sorted(s for s in wctx.substate if m(s))
2817
2814 if not m.always(): 2818 if not m.always():
2815 m.bad = lambda x, y: False 2819 m.bad = lambda x, y: False
2816 for abs in repo.walk(m): 2820 for abs in repo.walk(m):
2817 names[abs] = m.rel(abs), m.exact(abs) 2821 names[abs] = m.rel(abs), m.exact(abs)
2818 2822
3046 if not opts.get('dry_run'): 3050 if not opts.get('dry_run'):
3047 needdata = ('revert', 'add', 'undelete') 3051 needdata = ('revert', 'add', 'undelete')
3048 _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata]) 3052 _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata])
3049 _performrevert(repo, parents, ctx, actions, interactive) 3053 _performrevert(repo, parents, ctx, actions, interactive)
3050 3054
3051 # get the list of subrepos that must be reverted
3052 subrepomatch = scmutil.match(wctx, pats, opts)
3053 targetsubs = sorted(s for s in wctx.substate if subrepomatch(s))
3054
3055 if targetsubs: 3055 if targetsubs:
3056 # Revert the subrepos on the revert list 3056 # Revert the subrepos on the revert list
3057 for sub in targetsubs: 3057 for sub in targetsubs:
3058 try: 3058 try:
3059 wctx.sub(sub).revert(ctx.substate[sub], *pats, **opts) 3059 wctx.sub(sub).revert(ctx.substate[sub], *pats, **opts)