comparison mercurial/cmdutil.py @ 38353:89db59e5cf3e

remove: use progress helper Differential Revision: https://phab.mercurial-scm.org/D3767
author Martin von Zweigbergk <martinvonz@google.com>
date Sat, 16 Jun 2018 00:03:23 -0700
parents b8f45fc27370
children ef692614e601
comparison
equal deleted inserted replaced
38352:83534c4ec58b 38353:89db59e5cf3e
2179 warn = True 2179 warn = True
2180 else: 2180 else:
2181 warn = False 2181 warn = False
2182 2182
2183 subs = sorted(wctx.substate) 2183 subs = sorted(wctx.substate)
2184 total = len(subs) 2184 progress = ui.makeprogress(_('searching'), total=len(subs),
2185 count = 0 2185 unit=_('subrepos'))
2186 for subpath in subs: 2186 for subpath in subs:
2187 count += 1
2188 submatch = matchmod.subdirmatcher(subpath, m) 2187 submatch = matchmod.subdirmatcher(subpath, m)
2189 if subrepos or m.exact(subpath) or any(submatch.files()): 2188 if subrepos or m.exact(subpath) or any(submatch.files()):
2190 ui.progress(_('searching'), count, total=total, unit=_('subrepos')) 2189 progress.increment()
2191 sub = wctx.sub(subpath) 2190 sub = wctx.sub(subpath)
2192 try: 2191 try:
2193 if sub.removefiles(submatch, prefix, after, force, subrepos, 2192 if sub.removefiles(submatch, prefix, after, force, subrepos,
2194 dryrun, warnings): 2193 dryrun, warnings):
2195 ret = 1 2194 ret = 1
2196 except error.LookupError: 2195 except error.LookupError:
2197 warnings.append(_("skipping missing subrepository: %s\n") 2196 warnings.append(_("skipping missing subrepository: %s\n")
2198 % join(subpath)) 2197 % join(subpath))
2199 ui.progress(_('searching'), None) 2198 progress.update(None)
2200 2199
2201 # warn about failure to delete explicit files/dirs 2200 # warn about failure to delete explicit files/dirs
2202 deleteddirs = util.dirs(deleted) 2201 deleteddirs = util.dirs(deleted)
2203 files = m.files() 2202 files = m.files()
2204 total = len(files) 2203 progress = ui.makeprogress(_('deleting'), total=len(files),
2205 count = 0 2204 unit=_('files'))
2206 for f in files: 2205 for f in files:
2207 def insubrepo(): 2206 def insubrepo():
2208 for subpath in wctx.substate: 2207 for subpath in wctx.substate:
2209 if f.startswith(subpath + '/'): 2208 if f.startswith(subpath + '/'):
2210 return True 2209 return True
2211 return False 2210 return False
2212 2211
2213 count += 1 2212 progress.increment()
2214 ui.progress(_('deleting'), count, total=total, unit=_('files'))
2215 isdir = f in deleteddirs or wctx.hasdir(f) 2213 isdir = f in deleteddirs or wctx.hasdir(f)
2216 if (f in repo.dirstate or isdir or f == '.' 2214 if (f in repo.dirstate or isdir or f == '.'
2217 or insubrepo() or f in subs): 2215 or insubrepo() or f in subs):
2218 continue 2216 continue
2219 2217
2224 else: 2222 else:
2225 warnings.append(_('not removing %s: file is untracked\n') 2223 warnings.append(_('not removing %s: file is untracked\n')
2226 % m.rel(f)) 2224 % m.rel(f))
2227 # missing files will generate a warning elsewhere 2225 # missing files will generate a warning elsewhere
2228 ret = 1 2226 ret = 1
2229 ui.progress(_('deleting'), None) 2227 progress.update(None)
2230 2228
2231 if force: 2229 if force:
2232 list = modified + deleted + clean + added 2230 list = modified + deleted + clean + added
2233 elif after: 2231 elif after:
2234 list = deleted 2232 list = deleted
2235 remaining = modified + added + clean 2233 remaining = modified + added + clean
2236 total = len(remaining) 2234 progress = ui.makeprogress(_('skipping'), total=len(remaining),
2237 count = 0 2235 unit=_('files'))
2238 for f in remaining: 2236 for f in remaining:
2239 count += 1 2237 progress.increment()
2240 ui.progress(_('skipping'), count, total=total, unit=_('files'))
2241 if ui.verbose or (f in files): 2238 if ui.verbose or (f in files):
2242 warnings.append(_('not removing %s: file still exists\n') 2239 warnings.append(_('not removing %s: file still exists\n')
2243 % m.rel(f)) 2240 % m.rel(f))
2244 ret = 1 2241 ret = 1
2245 ui.progress(_('skipping'), None) 2242 progress.update(None)
2246 else: 2243 else:
2247 list = deleted + clean 2244 list = deleted + clean
2248 total = len(modified) + len(added) 2245 progress = ui.makeprogress(_('skipping'),
2249 count = 0 2246 total=(len(modified) + len(added)),
2247 unit=_('files'))
2250 for f in modified: 2248 for f in modified:
2251 count += 1 2249 progress.increment()
2252 ui.progress(_('skipping'), count, total=total, unit=_('files'))
2253 warnings.append(_('not removing %s: file is modified (use -f' 2250 warnings.append(_('not removing %s: file is modified (use -f'
2254 ' to force removal)\n') % m.rel(f)) 2251 ' to force removal)\n') % m.rel(f))
2255 ret = 1 2252 ret = 1
2256 for f in added: 2253 for f in added:
2257 count += 1 2254 progress.increment()
2258 ui.progress(_('skipping'), count, total=total, unit=_('files'))
2259 warnings.append(_("not removing %s: file has been marked for add" 2255 warnings.append(_("not removing %s: file has been marked for add"
2260 " (use 'hg forget' to undo add)\n") % m.rel(f)) 2256 " (use 'hg forget' to undo add)\n") % m.rel(f))
2261 ret = 1 2257 ret = 1
2262 ui.progress(_('skipping'), None) 2258 progress.update(None)
2263 2259
2264 list = sorted(list) 2260 list = sorted(list)
2265 total = len(list) 2261 progress = ui.makeprogress(_('deleting'), total=len(list),
2266 count = 0 2262 unit=_('files'))
2267 for f in list: 2263 for f in list:
2268 count += 1
2269 if ui.verbose or not m.exact(f): 2264 if ui.verbose or not m.exact(f):
2270 ui.progress(_('deleting'), count, total=total, unit=_('files')) 2265 progress.increment()
2271 ui.status(_('removing %s\n') % m.rel(f)) 2266 ui.status(_('removing %s\n') % m.rel(f))
2272 ui.progress(_('deleting'), None) 2267 progress.update(None)
2273 2268
2274 if not dryrun: 2269 if not dryrun:
2275 with repo.wlock(): 2270 with repo.wlock():
2276 if not after: 2271 if not after:
2277 for f in list: 2272 for f in list: