# HG changeset patch # User Martin von Zweigbergk # Date 1701275544 28800 # Node ID b8f9911c8dcae586f09df5894a5397125d5281ce # Parent b0a6084f9cd68e1d219b792497996dd76ae03d09 add: don't attempt to add back removed files unless explicitly listed This fixes the bug demonstrated by the previous patch. diff -r b0a6084f9cd6 -r b8f9911c8dca mercurial/cmdutil.py --- a/mercurial/cmdutil.py Tue Nov 28 22:44:04 2023 -0800 +++ b/mercurial/cmdutil.py Wed Nov 29 08:32:24 2023 -0800 @@ -2381,8 +2381,19 @@ full=False, ) ): + entry = dirstate.get_entry(f) + # We don't want to even attmpt to add back files that have been removed + # It would lead to a misleading message saying we're adding the path, + # and can also lead to file/dir conflicts when attempting to add it. + removed = entry and entry.removed exact = match.exact(f) - if exact or not explicitonly and f not in wctx and repo.wvfs.lexists(f): + if ( + exact + or not explicitonly + and f not in wctx + and repo.wvfs.lexists(f) + and not removed + ): if cca: cca(f) names.append(f) diff -r b0a6084f9cd6 -r b8f9911c8dca tests/test-symlinks.t --- a/tests/test-symlinks.t Tue Nov 28 22:44:04 2023 -0800 +++ b/tests/test-symlinks.t Wed Nov 29 08:32:24 2023 -0800 @@ -210,14 +210,10 @@ $ hg add -I foo adding foo - adding foo/a (known-bad-output !) - abort: file 'foo' in dirstate clashes with 'foo/a' (known-bad-output !) - [255] $ hg status A bar/a - A foo (missing-correct-output !) + A foo R foo/a - ? foo (known-bad-output !) $ cd ..