comparison mercurial/debugcommands.py @ 47812:855463b5fe49 stable

debugcommands: add a `--paranoid` option to `debug-repair-issue-6528` See justification inline. Differential Revision: https://phab.mercurial-scm.org/D11263
author Rapha?l Gom?s <rgomes@octobus.net>
date Fri, 06 Aug 2021 12:10:36 +0200
parents b30a53ffbf9b
children 0fb328bb2459
comparison
equal deleted inserted replaced
47811:32e21ac3adb1 47812:855463b5fe49
1468 b'from-report', 1468 b'from-report',
1469 b'', 1469 b'',
1470 _(b'repair revisions listed in this report file'), 1470 _(b'repair revisions listed in this report file'),
1471 _(b'FILE'), 1471 _(b'FILE'),
1472 ), 1472 ),
1473 (
1474 b'',
1475 b'paranoid',
1476 False,
1477 _(b'check that both detection methods do the same thing'),
1478 ),
1473 ] 1479 ]
1474 + cmdutil.dryrunopts, 1480 + cmdutil.dryrunopts,
1475 ) 1481 )
1476 def debug_repair_issue6528(ui, repo, **opts): 1482 def debug_repair_issue6528(ui, repo, **opts):
1477 """find affected revisions and repair them. See issue6528 for more details. 1483 """find affected revisions and repair them. See issue6528 for more details.
1489 filename. 1495 filename.
1490 1496
1491 Note that this does *not* mean that this repairs future affected revisions, 1497 Note that this does *not* mean that this repairs future affected revisions,
1492 that needs a separate fix at the exchange level that hasn't been written yet 1498 that needs a separate fix at the exchange level that hasn't been written yet
1493 (as of 5.9rc0). 1499 (as of 5.9rc0).
1500
1501 There is a `--paranoid` flag to test that the fast implementation is correct
1502 by checking it against the slow implementation. Since this matter is quite
1503 urgent and testing every edge-case is probably quite costly, we use this
1504 method to test on large repositories as a fuzzing method of sorts.
1494 """ 1505 """
1495 cmdutil.check_incompatible_arguments( 1506 cmdutil.check_incompatible_arguments(
1496 opts, 'to_report', ['from_report', 'dry_run'] 1507 opts, 'to_report', ['from_report', 'dry_run']
1497 ) 1508 )
1498 dry_run = opts.get('dry_run') 1509 dry_run = opts.get('dry_run')
1499 to_report = opts.get('to_report') 1510 to_report = opts.get('to_report')
1500 from_report = opts.get('from_report') 1511 from_report = opts.get('from_report')
1512 paranoid = opts.get('paranoid')
1501 # TODO maybe add filelog pattern and revision pattern parameters to help 1513 # TODO maybe add filelog pattern and revision pattern parameters to help
1502 # narrow down the search for users that know what they're looking for? 1514 # narrow down the search for users that know what they're looking for?
1503 1515
1504 if requirements.REVLOGV1_REQUIREMENT not in repo.requirements: 1516 if requirements.REVLOGV1_REQUIREMENT not in repo.requirements:
1505 msg = b"can only repair revlogv1 repositories, v2 is not affected" 1517 msg = b"can only repair revlogv1 repositories, v2 is not affected"
1506 raise error.Abort(_(msg)) 1518 raise error.Abort(_(msg))
1507 1519
1508 rewrite.repair_issue6528( 1520 rewrite.repair_issue6528(
1509 ui, repo, dry_run=dry_run, to_report=to_report, from_report=from_report 1521 ui,
1522 repo,
1523 dry_run=dry_run,
1524 to_report=to_report,
1525 from_report=from_report,
1526 paranoid=paranoid,
1510 ) 1527 )
1511 1528
1512 1529
1513 @command(b'debugformat', [] + cmdutil.formatteropts) 1530 @command(b'debugformat', [] + cmdutil.formatteropts)
1514 def debugformat(ui, repo, **opts): 1531 def debugformat(ui, repo, **opts):