Mercurial > hg
changeset 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 b046b90c4ae5 |
files | mercurial/commands.py tests/test-remove tests/test-remove.out |
diffstat | 3 files changed, 34 insertions(+), 9 deletions(-) [+] |
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):
--- a/tests/test-remove Wed Sep 01 12:05:57 2010 +0200 +++ b/tests/test-remove Mon Aug 30 20:27:25 2010 -0400 @@ -2,6 +2,7 @@ remove() { hg rm $@ + echo "exit code: $?" hg st # do not use ls -R, which recurses in .hg subdirs on Mac OS X 10.5 find . -name .hg -prune -o -type f -print | sort
--- a/tests/test-remove.out Wed Sep 01 12:05:57 2010 +0200 +++ b/tests/test-remove.out Mon Aug 30 20:27:25 2010 -0400 @@ -1,83 +1,100 @@ % file not managed not removing foo: file is untracked +exit code: 1 ? foo ./foo 0 files updated, 0 files merged, 0 files removed, 0 files unresolved % 00 state added, options none not removing bar: file has been marked for add (use -f to force removal) +exit code: 1 A bar ./bar ./foo 0 files updated, 0 files merged, 0 files removed, 0 files unresolved % 01 state clean, options none +exit code: 0 R foo ? bar ./bar 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % 02 state modified, options none not removing foo: file is modified (use -f to force removal) +exit code: 1 M foo ? bar ./bar ./foo 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % 03 state missing, options none +exit code: 0 R foo ? bar ./bar 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % 10 state added, options -f +exit code: 0 ? bar ./bar ./foo 0 files updated, 0 files merged, 0 files removed, 0 files unresolved % 11 state clean, options -f +exit code: 0 R foo 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % 12 state modified, options -f +exit code: 0 R foo 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % 13 state missing, options -f +exit code: 0 R foo 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % 20 state added, options -A not removing bar: file still exists (use -f to force removal) +exit code: 1 A bar ./bar ./foo 0 files updated, 0 files merged, 0 files removed, 0 files unresolved % 21 state clean, options -A not removing foo: file still exists (use -f to force removal) +exit code: 1 ? bar ./bar ./foo 0 files updated, 0 files merged, 0 files removed, 0 files unresolved % 22 state modified, options -A not removing foo: file still exists (use -f to force removal) +exit code: 1 M foo ? bar ./bar ./foo 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % 23 state missing, options -A +exit code: 0 R foo ? bar ./bar 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % 30 state added, options -Af +exit code: 0 ? bar ./bar ./foo 0 files updated, 0 files merged, 0 files removed, 0 files unresolved % 31 state clean, options -Af +exit code: 0 R foo ./foo 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % 32 state modified, options -Af +exit code: 0 R foo ./foo 1 files updated, 0 files merged, 0 files removed, 0 files unresolved % 33 state missing, options -Af +exit code: 0 R foo 1 files updated, 0 files merged, 0 files removed, 0 files unresolved adding test/bar @@ -85,6 +102,7 @@ % dir, options none removing test/bar removing test/foo +exit code: 0 R test/bar R test/foo ./foo @@ -92,6 +110,7 @@ % dir, options -f removing test/bar removing test/foo +exit code: 0 R test/bar R test/foo ./foo @@ -99,6 +118,7 @@ % dir, options -A not removing test/foo: file still exists (use -f to force removal) removing test/bar +exit code: 1 R test/bar ./foo ./test/foo @@ -106,6 +126,7 @@ % dir, options -Af removing test/bar removing test/foo +exit code: 0 R test/bar R test/foo ./foo