changeset 1189:4cbcc54695b2

Make removal check more complete and informative.
author Bryan O'Sullivan <bos@serpentine.com>
date Thu, 01 Sep 2005 08:01:10 -0700
parents b3ceb2d470fc
children 737f9b90c571
files mercurial/commands.py
diffstat 1 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- 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)