# HG changeset patch # User Bryan O'Sullivan # Date 1125586870 25200 # Node ID 4cbcc54695b201c06e140e22cbc5b00850af6811 # Parent b3ceb2d470fcac92d7ff74f42768dd50804f18be Make removal check more complete and informative. diff -r b3ceb2d470fc -r 4cbcc54695b2 mercurial/commands.py --- a/mercurial/commands.py Thu Sep 01 07:48:14 2005 -0700 +++ b/mercurial/commands.py Thu Sep 01 08:01:10 2005 -0700 @@ -1265,18 +1265,19 @@ def remove(ui, repo, pat, *pats, **opts): """remove the specified files on the next commit""" names = [] + def okaytoremove(abs, rel, exact): + c, a, d, u = repo.changes(files = [abs]) + reason = None + if c: reason = 'is modified' + elif a: reason = 'has been marked for add' + elif u: reason = 'not managed' + if reason and exact: + ui.warn('not removing %s: file %s\n' % (rel, reason)) + else: + return True for src, abs, rel, exact in walk(repo, (pat,) + pats, opts): - if exact: - skip = {'m': 'file has pending merge', - 'a': 'file has been marked for add (use forget)', - '?': 'file not managed'} - reason = skip.get(repo.dirstate.state(abs)) - if reason: - ui.warn('not removing %s: %s\n' % (rel, reason)) - else: - names.append(abs) - elif repo.dirstate.state(abs) == 'n': - ui.status('removing %s\n' % rel) + if okaytoremove(abs, rel, exact): + if not exact: ui.status('removing %s\n' % rel) names.append(abs) repo.remove(names)