diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1224,8 +1224,8 @@ def forget(ui, repo, match, prefix, expl ui.status(_("skipping missing subrepository: %s\n") % join(subpath)) - for f in match.files(): - if match.exact(f) or not explicitonly: + if not explicitonly: + for f in match.files(): if f not in repo.dirstate and not os.path.isdir(match.rel(join(f))): if f not in forgot: if os.path.exists(match.rel(join(f))): diff --git a/tests/test-subrepo-recursion.t b/tests/test-subrepo-recursion.t --- a/tests/test-subrepo-recursion.t +++ b/tests/test-subrepo-recursion.t @@ -195,10 +195,14 @@ Test explicit path commands within subre $ hg add foo/bar/z2.txt $ hg status -S A foo/bar/z2.txt -This is expected to forget the file, but is currently broken $ hg forget foo/bar/z2.txt $ hg status -S ? foo/bar/z2.txt + $ hg forget foo/bar/z2.txt + not removing foo/bar/z2.txt: file is already untracked + [1] + $ hg status -S + ? foo/bar/z2.txt $ rm foo/bar/z2.txt Log with the relationships between repo and its subrepo: