##// END OF EJS Templates
remove: queue warnings until after status messages (issue5140) (API)...
timeless -
r28607:a88959ae default
parent child Browse files
Show More
@@ -2404,7 +2404,7 b' def files(ui, ctx, m, fm, fmt, subrepos)'
2404 2404
2405 2405 return ret
2406 2406
2407 def remove(ui, repo, m, prefix, after, force, subrepos):
2407 def remove(ui, repo, m, prefix, after, force, subrepos, warnings=None):
2408 2408 join = lambda f: os.path.join(prefix, f)
2409 2409 ret = 0
2410 2410 s = repo.status(match=m, clean=True)
@@ -2412,6 +2412,12 b' def remove(ui, repo, m, prefix, after, f'
2412 2412
2413 2413 wctx = repo[None]
2414 2414
2415 if warnings is None:
2416 warnings = []
2417 warn = True
2418 else:
2419 warn = False
2420
2415 2421 for subpath in sorted(wctx.substate):
2416 2422 def matchessubrepo(matcher, subpath):
2417 2423 if matcher.exact(subpath):
@@ -2425,10 +2431,11 b' def remove(ui, repo, m, prefix, after, f'
2425 2431 sub = wctx.sub(subpath)
2426 2432 try:
2427 2433 submatch = matchmod.subdirmatcher(subpath, m)
2428 if sub.removefiles(submatch, prefix, after, force, subrepos):
2434 if sub.removefiles(submatch, prefix, after, force, subrepos,
2435 warnings):
2429 2436 ret = 1
2430 2437 except error.LookupError:
2431 ui.status(_("skipping missing subrepository: %s\n")
2438 warnings.append(_("skipping missing subrepository: %s\n")
2432 2439 % join(subpath))
2433 2440
2434 2441 # warn about failure to delete explicit files/dirs
@@ -2446,10 +2453,10 b' def remove(ui, repo, m, prefix, after, f'
2446 2453
2447 2454 if repo.wvfs.exists(f):
2448 2455 if repo.wvfs.isdir(f):
2449 ui.warn(_('not removing %s: no tracked files\n')
2456 warnings.append(_('not removing %s: no tracked files\n')
2450 2457 % m.rel(f))
2451 2458 else:
2452 ui.warn(_('not removing %s: file is untracked\n')
2459 warnings.append(_('not removing %s: file is untracked\n')
2453 2460 % m.rel(f))
2454 2461 # missing files will generate a warning elsewhere
2455 2462 ret = 1
@@ -2459,16 +2466,16 b' def remove(ui, repo, m, prefix, after, f'
2459 2466 elif after:
2460 2467 list = deleted
2461 2468 for f in modified + added + clean:
2462 ui.warn(_('not removing %s: file still exists\n') % m.rel(f))
2469 warnings.append(_('not removing %s: file still exists\n') % m.rel(f))
2463 2470 ret = 1
2464 2471 else:
2465 2472 list = deleted + clean
2466 2473 for f in modified:
2467 ui.warn(_('not removing %s: file is modified (use -f'
2474 warnings.append(_('not removing %s: file is modified (use -f'
2468 2475 ' to force removal)\n') % m.rel(f))
2469 2476 ret = 1
2470 2477 for f in added:
2471 ui.warn(_('not removing %s: file has been marked for add'
2478 warnings.append(_('not removing %s: file has been marked for add'
2472 2479 ' (use forget to undo)\n') % m.rel(f))
2473 2480 ret = 1
2474 2481
@@ -2484,6 +2491,10 b' def remove(ui, repo, m, prefix, after, f'
2484 2491 util.unlinkpath(repo.wjoin(f), ignoremissing=True)
2485 2492 repo[None].forget(list)
2486 2493
2494 if warn:
2495 for warning in warnings:
2496 ui.warn(warning)
2497
2487 2498 return ret
2488 2499
2489 2500 def cat(ui, repo, ctx, matcher, prefix, **opts):
@@ -575,11 +575,13 b' class abstractsubrepo(object):'
575 575 def forget(self, match, prefix):
576 576 return ([], [])
577 577
578 def removefiles(self, matcher, prefix, after, force, subrepos):
578 def removefiles(self, matcher, prefix, after, force, subrepos, warnings):
579 579 """remove the matched files from the subrepository and the filesystem,
580 580 possibly by force and/or after the file has been removed from the
581 581 filesystem. Return 0 on success, 1 on any warning.
582 582 """
583 warnings.append(_("warning: removefiles not implemented (%s)")
584 % self._path)
583 585 return 1
584 586
585 587 def revert(self, substate, *pats, **opts):
@@ -991,7 +993,7 b' class hgsubrepo(abstractsubrepo):'
991 993 self.wvfs.reljoin(prefix, self._path), True)
992 994
993 995 @annotatesubrepoerror
994 def removefiles(self, matcher, prefix, after, force, subrepos):
996 def removefiles(self, matcher, prefix, after, force, subrepos, warnings):
995 997 return cmdutil.remove(self.ui, self._repo, matcher,
996 998 self.wvfs.reljoin(prefix, self._path),
997 999 after, force, subrepos)
@@ -277,8 +277,8 b' dir, options -A'
277 277
278 278 $ rm test/bar
279 279 $ remove -A test
280 removing test/bar (glob)
280 281 not removing test/foo: file still exists (glob)
281 removing test/bar (glob)
282 282 exit code: 1
283 283 R test/bar
284 284 ./foo
General Comments 0
You need to be logged in to leave comments. Login now