[PATCH 2 of 5 STABLE] largefiles: exit from remove with 1 on warnings
Greg Ward
greg at gerg.ca
Thu Sep 6 12:55:25 CDT 2012
On 06 September 2012, Matt Harbison said:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1346896575 14400
> # Branch stable
> # Node ID 4d439f36e60ddd7b754c6ef9765467d193e7a45f
> # Parent 38f17c53cdaa924161b49ae92d5b82cb225f4f89
> largefiles: exit from remove with 1 on warnings
>
> This maintains the exit codes documented in commands.py.
>
> diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
> --- a/hgext/largefiles/overrides.py
> +++ b/hgext/largefiles/overrides.py
> @@ -138,17 +138,22 @@
> for list in [s[0], s[1], s[3], s[6]]]
>
> def warn(files, reason):
> + ret = 0
> for f in files:
> ui.warn(_('not removing %s: %s (use forget to undo)\n')
> % (m.rel(f), reason))
> + ret = 1
> + return ret
Hmmm. What about:
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -141,6 +141,7 @@
for f in files:
ui.warn(_('not removing %s: %s (use forget to undo)\n')
% (m.rel(f), reason))
+ return int(len(f) > 0)
if after:
remove, forget = deleted, []
instead? Concise is good, but is it as clear?
Alternately:
return int(bool(f))
return f and 1 or 0
...but I think I like my original approach best.
--
Greg Ward http://www.gerg.ca/
Eschew obfuscation!
More information about the Mercurial-devel
mailing list