diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1982,9 +1982,9 @@ def add(ui, repo, match, dryrun, listsub abort, warn = scmutil.checkportabilityalert(ui) if abort or warn: cca = scmutil.casecollisionauditor(ui, abort, repo.dirstate) - for f in repo.walk(match): + for f in wctx.walk(match): exact = match.exact(f) - if exact or not explicitonly and f not in repo.dirstate: + if exact or not explicitonly and f not in wctx: if cca: cca(f) names.append(f) diff --git a/tests/test-add.t b/tests/test-add.t --- a/tests/test-add.t +++ b/tests/test-add.t @@ -126,6 +126,19 @@ Issue683: peculiarity with hg revert of M a ? a.orig +Forgotten file can be added back (as either clean or modified) + + $ hg forget b + $ hg add b + $ hg st -A b + C b + $ hg forget b + $ echo modified > b + $ hg add b + $ hg st -A b + M b + $ hg revert -qC b + $ hg add c && echo "unexpected addition of missing file" c: * (glob) [1]