diff mercurial/commands.py @ 12129:07ac2a560fce stable

remove: properly set return code when warnings are issued This removes the warn() function in favor of issuing warnings directly for each kind of file that Mercurial won't remove. This also uses three separate translatable strings instead of using string formatting to build the message. This should make it easier to localize.
author Brodie Rao <brodie@bitheap.org>
date Mon, 30 Aug 2010 20:27:25 -0400
parents 090dc5eef746
children 48735ce02345 28ddf67198b2
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Sep 01 12:05:57 2010 +0200
+++ b/mercurial/commands.py	Mon Aug 30 20:27:25 2010 -0400
@@ -2916,21 +2916,24 @@
             ui.warn(_('not removing %s: file is untracked\n') % m.rel(f))
             ret = 1
 
-    def warn(files, reason):
-        for f in files:
-            ui.warn(_('not removing %s: file %s (use -f to force removal)\n')
-                    % (m.rel(f), reason))
-            ret = 1
-
     if force:
         remove, forget = modified + deleted + clean, added
     elif after:
         remove, forget = deleted, []
-        warn(modified + added + clean, _('still exists'))
+        for f in modified + added + clean:
+            ui.warn(_('not removing %s: file still exists (use -f'
+                      ' to force removal)\n') % m.rel(f))
+            ret = 1
     else:
         remove, forget = deleted + clean, []
-        warn(modified, _('is modified'))
-        warn(added, _('has been marked for add'))
+        for f in modified:
+            ui.warn(_('not removing %s: file is modified (use -f'
+                      ' to force removal)\n') % m.rel(f))
+            ret = 1
+        for f in added:
+            ui.warn(_('not removing %s: file has been marked for add (use -f'
+                      ' to force removal)\n') % m.rel(f))
+            ret = 1
 
     for f in sorted(remove + forget):
         if ui.verbose or not m.exact(f):