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