diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2404,7 +2404,7 @@ def files(ui, ctx, m, fm, fmt, subrepos) return ret -def remove(ui, repo, m, prefix, after, force, subrepos): +def remove(ui, repo, m, prefix, after, force, subrepos, warnings=None): join = lambda f: os.path.join(prefix, f) ret = 0 s = repo.status(match=m, clean=True) @@ -2412,6 +2412,12 @@ def remove(ui, repo, m, prefix, after, f wctx = repo[None] + if warnings is None: + warnings = [] + warn = True + else: + warn = False + for subpath in sorted(wctx.substate): def matchessubrepo(matcher, subpath): if matcher.exact(subpath): @@ -2425,10 +2431,11 @@ def remove(ui, repo, m, prefix, after, f sub = wctx.sub(subpath) try: submatch = matchmod.subdirmatcher(subpath, m) - if sub.removefiles(submatch, prefix, after, force, subrepos): + if sub.removefiles(submatch, prefix, after, force, subrepos, + warnings): ret = 1 except error.LookupError: - ui.status(_("skipping missing subrepository: %s\n") + warnings.append(_("skipping missing subrepository: %s\n") % join(subpath)) # warn about failure to delete explicit files/dirs @@ -2446,10 +2453,10 @@ def remove(ui, repo, m, prefix, after, f if repo.wvfs.exists(f): if repo.wvfs.isdir(f): - ui.warn(_('not removing %s: no tracked files\n') + warnings.append(_('not removing %s: no tracked files\n') % m.rel(f)) else: - ui.warn(_('not removing %s: file is untracked\n') + warnings.append(_('not removing %s: file is untracked\n') % m.rel(f)) # missing files will generate a warning elsewhere ret = 1 @@ -2459,16 +2466,16 @@ def remove(ui, repo, m, prefix, after, f elif after: list = deleted for f in modified + added + clean: - ui.warn(_('not removing %s: file still exists\n') % m.rel(f)) + warnings.append(_('not removing %s: file still exists\n') % m.rel(f)) ret = 1 else: list = deleted + clean for f in modified: - ui.warn(_('not removing %s: file is modified (use -f' + warnings.append(_('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' + warnings.append(_('not removing %s: file has been marked for add' ' (use forget to undo)\n') % m.rel(f)) ret = 1 @@ -2484,6 +2491,10 @@ def remove(ui, repo, m, prefix, after, f util.unlinkpath(repo.wjoin(f), ignoremissing=True) repo[None].forget(list) + if warn: + for warning in warnings: + ui.warn(warning) + return ret def cat(ui, repo, ctx, matcher, prefix, **opts): diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py --- a/mercurial/subrepo.py +++ b/mercurial/subrepo.py @@ -575,11 +575,13 @@ class abstractsubrepo(object): def forget(self, match, prefix): return ([], []) - def removefiles(self, matcher, prefix, after, force, subrepos): + def removefiles(self, matcher, prefix, after, force, subrepos, warnings): """remove the matched files from the subrepository and the filesystem, possibly by force and/or after the file has been removed from the filesystem. Return 0 on success, 1 on any warning. """ + warnings.append(_("warning: removefiles not implemented (%s)") + % self._path) return 1 def revert(self, substate, *pats, **opts): @@ -991,7 +993,7 @@ class hgsubrepo(abstractsubrepo): self.wvfs.reljoin(prefix, self._path), True) @annotatesubrepoerror - def removefiles(self, matcher, prefix, after, force, subrepos): + def removefiles(self, matcher, prefix, after, force, subrepos, warnings): return cmdutil.remove(self.ui, self._repo, matcher, self.wvfs.reljoin(prefix, self._path), after, force, subrepos) diff --git a/tests/test-remove.t b/tests/test-remove.t --- a/tests/test-remove.t +++ b/tests/test-remove.t @@ -277,8 +277,8 @@ dir, options -A $ rm test/bar $ remove -A test + removing test/bar (glob) not removing test/foo: file still exists (glob) - removing test/bar (glob) exit code: 1 R test/bar ./foo