comparison mercurial/merge.py @ 48894: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 d4486810a179
children 288de6f5d724
comparison
equal deleted inserted replaced
48893:6cd249556e20 48894:0cc5f74ff7f0
2440 matcher.traversedir = directories.append 2440 matcher.traversedir = directories.append
2441 2441
2442 status = repo.status(match=matcher, ignored=ignored, unknown=unknown) 2442 status = repo.status(match=matcher, ignored=ignored, unknown=unknown)
2443 2443
2444 if confirm: 2444 if confirm:
2445 msg = None
2445 nb_ignored = len(status.ignored) 2446 nb_ignored = len(status.ignored)
2446 nb_unknown = len(status.unknown) 2447 nb_unknown = len(status.unknown)
2447 if nb_unknown and nb_ignored: 2448 if nb_unknown and nb_ignored:
2448 msg = _(b"permanently delete %d unknown and %d ignored files?") 2449 msg = _(b"permanently delete %d unknown and %d ignored files?")
2449 msg %= (nb_unknown, nb_ignored) 2450 msg %= (nb_unknown, nb_ignored)
2461 if dir_count: 2462 if dir_count:
2462 msg = _( 2463 msg = _(
2463 b"permanently delete at least %d empty directories?" 2464 b"permanently delete at least %d empty directories?"
2464 ) 2465 )
2465 msg %= dir_count 2466 msg %= dir_count
2466 else: 2467 if msg is None:
2467 # XXX we might be missing directory there 2468 return res
2468 return res 2469 else:
2469 msg += b" (yN)$$ &Yes $$ &No" 2470 msg += b" (yN)$$ &Yes $$ &No"
2470 if repo.ui.promptchoice(msg, default=1) == 1: 2471 if repo.ui.promptchoice(msg, default=1) == 1:
2471 raise error.CanceledError(_(b'removal cancelled')) 2472 raise error.CanceledError(_(b'removal cancelled'))
2472 2473
2473 if removefiles: 2474 if removefiles:
2474 for f in sorted(status.unknown + status.ignored): 2475 for f in sorted(status.unknown + status.ignored):
2475 if not noop: 2476 if not noop:
2476 repo.ui.note(_(b'removing file %s\n') % f) 2477 repo.ui.note(_(b'removing file %s\n') % f)