largefiles: exit from remove with 1 on warnings
This maintains the exit codes documented in commands.py.
--- a/hgext/largefiles/overrides.py Wed Sep 05 21:26:08 2012 -0400
+++ b/hgext/largefiles/overrides.py Sun Sep 09 20:18:08 2012 -0400
@@ -141,14 +141,17 @@
for f in files:
ui.warn(_('not removing %s: %s (use forget to undo)\n')
% (m.rel(f), reason))
+ return int(len(files) > 0)
+
+ result = 0
if after:
remove, forget = deleted, []
- warn(modified + added + clean, _('file still exists'))
+ result = warn(modified + added + clean, _('file still exists'))
else:
remove, forget = deleted + clean, []
- warn(modified, _('file is modified'))
- warn(added, _('file has been marked for add'))
+ result = warn(modified, _('file is modified'))
+ result = warn(added, _('file has been marked for add')) or result
for f in sorted(remove + forget):
if ui.verbose or not m.exact(f):
@@ -181,6 +184,8 @@
finally:
wlock.release()
+ return result
+
# For overriding mercurial.hgweb.webcommands so that largefiles will
# appear at their right place in the manifests.
def decodepath(orig, path):
@@ -207,9 +212,9 @@
def overrideremove(orig, ui, repo, *pats, **opts):
installnormalfilesmatchfn(repo[None].manifest())
- orig(ui, repo, *pats, **opts)
+ result = orig(ui, repo, *pats, **opts)
restorematchfn()
- removelargefiles(ui, repo, *pats, **opts)
+ return removelargefiles(ui, repo, *pats, **opts) or result
def overridestatusfn(orig, repo, rev2, **opts):
try:
--- a/tests/test-largefiles.t Wed Sep 05 21:26:08 2012 -0400
+++ b/tests/test-largefiles.t Sun Sep 09 20:18:08 2012 -0400
@@ -79,6 +79,17 @@
C sub/normal2
$ rm sub/unknown
+Test exit codes for remove warning cases (modified and still exiting)
+
+ $ hg remove -A large1
+ not removing large1: file still exists (use forget to undo)
+ [1]
+ $ echo 'modified' > large1
+ $ hg remove large1
+ not removing large1: file is modified (use forget to undo)
+ [1]
+ $ hg up -Cq
+
Remove both largefiles and normal files.
$ hg remove normal1 large1
@@ -96,11 +107,15 @@
A large1-test
$ hg rm large1-test
not removing large1-test: file has been marked for add (use forget to undo)
+ [1]
$ hg st
A large1-test
$ hg forget large1-test
$ hg st
? large1-test
+ $ hg remove large1-test
+ not removing large1-test: file is untracked
+ [1]
$ rm large1-test
Copy both largefiles and normal files (testing that status output is correct).