comparison mercurial/cmdutil.py @ 41653:16a49c778bde

forget: pass around uipathfn and use instead of m.rel() (API) Differential Revision: https://phab.mercurial-scm.org/D5911
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 08 Feb 2019 13:08:01 -0800
parents 6a447a3d1bd0
children e41449818bee
comparison
equal deleted inserted replaced
41652:6a447a3d1bd0 41653:16a49c778bde
2082 for r in repo.revs('filelog("path:.hgsub")'): 2082 for r in repo.revs('filelog("path:.hgsub")'):
2083 ctx = repo[r] 2083 ctx = repo[r]
2084 for subpath in ctx.substate: 2084 for subpath in ctx.substate:
2085 ctx.sub(subpath).addwebdirpath(serverpath, webconf) 2085 ctx.sub(subpath).addwebdirpath(serverpath, webconf)
2086 2086
2087 def forget(ui, repo, match, prefix, explicitonly, dryrun, interactive): 2087 def forget(ui, repo, match, prefix, uipathfn, explicitonly, dryrun,
2088 interactive):
2088 if dryrun and interactive: 2089 if dryrun and interactive:
2089 raise error.Abort(_("cannot specify both --dry-run and --interactive")) 2090 raise error.Abort(_("cannot specify both --dry-run and --interactive"))
2090 bad = [] 2091 bad = []
2091 badfn = lambda x, y: bad.append(x) or match.bad(x, y) 2092 badfn = lambda x, y: bad.append(x) or match.bad(x, y)
2092 wctx = repo[None] 2093 wctx = repo[None]
2099 2100
2100 for subpath in sorted(wctx.substate): 2101 for subpath in sorted(wctx.substate):
2101 sub = wctx.sub(subpath) 2102 sub = wctx.sub(subpath)
2102 submatch = matchmod.subdirmatcher(subpath, match) 2103 submatch = matchmod.subdirmatcher(subpath, match)
2103 subprefix = repo.wvfs.reljoin(prefix, subpath) 2104 subprefix = repo.wvfs.reljoin(prefix, subpath)
2105 subuipathfn = scmutil.subdiruipathfn(subpath, uipathfn)
2104 try: 2106 try:
2105 subbad, subforgot = sub.forget(submatch, subprefix, dryrun=dryrun, 2107 subbad, subforgot = sub.forget(submatch, subprefix, subuipathfn,
2108 dryrun=dryrun,
2106 interactive=interactive) 2109 interactive=interactive)
2107 bad.extend([subpath + '/' + f for f in subbad]) 2110 bad.extend([subpath + '/' + f for f in subbad])
2108 forgot.extend([subpath + '/' + f for f in subforgot]) 2111 forgot.extend([subpath + '/' + f for f in subforgot])
2109 except error.LookupError: 2112 except error.LookupError:
2110 ui.status(_("skipping missing subrepository: %s\n") 2113 ui.status(_("skipping missing subrepository: %s\n")
2111 % match.rel(subpath)) 2114 % uipathfn(subpath))
2112 2115
2113 if not explicitonly: 2116 if not explicitonly:
2114 for f in match.files(): 2117 for f in match.files():
2115 if f not in repo.dirstate and not repo.wvfs.isdir(f): 2118 if f not in repo.dirstate and not repo.wvfs.isdir(f):
2116 if f not in forgot: 2119 if f not in forgot:
2121 # purely from data cached by the status walk above. 2124 # purely from data cached by the status walk above.
2122 if repo.dirstate.normalize(f) in repo.dirstate: 2125 if repo.dirstate.normalize(f) in repo.dirstate:
2123 continue 2126 continue
2124 ui.warn(_('not removing %s: ' 2127 ui.warn(_('not removing %s: '
2125 'file is already untracked\n') 2128 'file is already untracked\n')
2126 % match.rel(f)) 2129 % uipathfn(f))
2127 bad.append(f) 2130 bad.append(f)
2128 2131
2129 if interactive: 2132 if interactive:
2130 responses = _('[Ynsa?]' 2133 responses = _('[Ynsa?]'
2131 '$$ &Yes, forget this file' 2134 '$$ &Yes, forget this file'
2152 elif r == 3: # All 2155 elif r == 3: # All
2153 break 2156 break
2154 2157
2155 for f in forget: 2158 for f in forget:
2156 if ui.verbose or not match.exact(f) or interactive: 2159 if ui.verbose or not match.exact(f) or interactive:
2157 ui.status(_('removing %s\n') % match.rel(f), 2160 ui.status(_('removing %s\n') % uipathfn(f),
2158 label='ui.addremove.removed') 2161 label='ui.addremove.removed')
2159 2162
2160 if not dryrun: 2163 if not dryrun:
2161 rejected = wctx.forget(forget, prefix) 2164 rejected = wctx.forget(forget, prefix)
2162 bad.extend(f for f in rejected if f in match.files()) 2165 bad.extend(f for f in rejected if f in match.files())