diff mercurial/merge.py @ 46367:57370e7deb7b

purge: also deal with directory with --confirm Getting the exact number is simple (you have to project the result of previous deletion to detect super-directory with only about-to-be-deleted content). So we use a vaguer message. Differential Revision: https://phab.mercurial-scm.org/D9819
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 18 Jan 2021 10:24:11 +0100
parents 135056e8b5a8
children dc00324e80f4
line wrap: on
line diff
--- a/mercurial/merge.py	Mon Jan 18 10:24:03 2021 +0100
+++ b/mercurial/merge.py	Mon Jan 18 10:24:11 2021 +0100
@@ -2386,9 +2386,19 @@
             elif nb_ignored:
                 msg = _(b"permanently delete %d ignored files?")
                 msg %= nb_ignored
-            else:
-                # XXX we might be missing directory there
-                return res
+            elif removeemptydirs:
+                dir_count = 0
+                for f in directories:
+                    if matcher(f) and not repo.wvfs.listdir(f):
+                        dir_count += 1
+                if dir_count:
+                    msg = _(
+                        b"permanently delete at least %d empty directories?"
+                    )
+                    msg %= dir_count
+                else:
+                    # XXX we might be missing directory there
+                    return res
             msg += b" (yN)$$ &Yes $$ &No"
             if repo.ui.promptchoice(msg, default=1) == 1:
                 raise error.CanceledError(_(b'removal cancelled'))