Mercurial > hg
changeset 49352:0cc5f74ff7f0 stable 6.1.4
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.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 14 Jun 2022 11:26:18 +0200 |
parents | 6cd249556e20 |
children | d4db76996492 |
files | mercurial/merge.py tests/test-purge.t |
diffstat | 2 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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):