# HG changeset patch # User Pierre-Yves David # Date 1655198778 -7200 # Node ID 0cc5f74ff7f0f4ac2427096bddbe102dbc2453ae # Parent 6cd249556e207d96949c5ddb304f3bda276e6540 purge: prevent a silly crash with --confirm --files if --files is passed, there was no directory to checks and `msg` was undefined. This is now fixed and tested. diff -r 6cd249556e20 -r 0cc5f74ff7f0 mercurial/merge.py --- a/mercurial/merge.py Wed Jun 08 19:15:58 2022 +0200 +++ b/mercurial/merge.py Tue Jun 14 11:26:18 2022 +0200 @@ -2442,6 +2442,7 @@ status = repo.status(match=matcher, ignored=ignored, unknown=unknown) if confirm: + msg = None nb_ignored = len(status.ignored) nb_unknown = len(status.unknown) if nb_unknown and nb_ignored: @@ -2463,12 +2464,12 @@ 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')) + if msg is None: + return res + else: + msg += b" (yN)$$ &Yes $$ &No" + if repo.ui.promptchoice(msg, default=1) == 1: + raise error.CanceledError(_(b'removal cancelled')) if removefiles: for f in sorted(status.unknown + status.ignored): diff -r 6cd249556e20 -r 0cc5f74ff7f0 tests/test-purge.t --- a/tests/test-purge.t Wed Jun 08 19:15:58 2022 +0200 +++ b/tests/test-purge.t Tue Jun 14 11:26:18 2022 +0200 @@ -350,4 +350,9 @@ .hg .hgignore +Test some --confirm case that ended crashing + + $ hg purge --confirm + $ hg purge --confirm --all --files + $ cd ..