comparison mercurial/upgrade_utils/engine.py @ 48793:6e559391f96e

tracked-key: remove the dual write and rename to tracked-hint The dual-write approach was mostly useless. As explained in the previous version of the help, the key had to be read twice before we could cache a value. However this "read twice" limitation actually also apply to any usage of the key. If some operation wants to rely of the "same value == same tracked set" property it would need to read the value before, and after running that operation (or at least, after, in all cases). So it cannot be sure the operation it did is "valid" until checking the key after the operation. As a resultat such operation can only be read-only or rollbackable. This reduce the utility of the "same value == same tracked set" a lot. So it seems simpler to drop the double write and to update the documentation to highlight that this file does not garantee race-free operation. As a result the "key" is demoted to a "hint". Documentation is updated accordingly. Differential Revision: https://phab.mercurial-scm.org/D12201
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 17 Feb 2022 07:34:49 +0100
parents 5ba24e886cec
children 6000f5b25c9b
comparison
equal deleted inserted replaced
48792:8bbb1abb9d19 48793:6e559391f96e
485 ui.status(_(b'downgrading from dirstate-v2 to v1\n')) 485 ui.status(_(b'downgrading from dirstate-v2 to v1\n'))
486 upgrade_dirstate(ui, srcrepo, upgrade_op, b'v2', b'v1') 486 upgrade_dirstate(ui, srcrepo, upgrade_op, b'v2', b'v1')
487 upgrade_op.removed_actions.remove(upgrade_actions.dirstatev2) 487 upgrade_op.removed_actions.remove(upgrade_actions.dirstatev2)
488 488
489 if upgrade_actions.dirstatetrackedkey in upgrade_op.upgrade_actions: 489 if upgrade_actions.dirstatetrackedkey in upgrade_op.upgrade_actions:
490 ui.status(_(b'create dirstate-tracked-key file\n')) 490 ui.status(_(b'create dirstate-tracked-hint file\n'))
491 upgrade_tracked_key(ui, srcrepo, upgrade_op, add=True) 491 upgrade_tracked_hint(ui, srcrepo, upgrade_op, add=True)
492 upgrade_op.upgrade_actions.remove(upgrade_actions.dirstatetrackedkey) 492 upgrade_op.upgrade_actions.remove(upgrade_actions.dirstatetrackedkey)
493 elif upgrade_actions.dirstatetrackedkey in upgrade_op.removed_actions: 493 elif upgrade_actions.dirstatetrackedkey in upgrade_op.removed_actions:
494 ui.status(_(b'remove dirstate-tracked-key file\n')) 494 ui.status(_(b'remove dirstate-tracked-hint file\n'))
495 upgrade_tracked_key(ui, srcrepo, upgrade_op, add=False) 495 upgrade_tracked_hint(ui, srcrepo, upgrade_op, add=False)
496 upgrade_op.removed_actions.remove(upgrade_actions.dirstatetrackedkey) 496 upgrade_op.removed_actions.remove(upgrade_actions.dirstatetrackedkey)
497 497
498 if not (upgrade_op.upgrade_actions or upgrade_op.removed_actions): 498 if not (upgrade_op.upgrade_actions or upgrade_op.removed_actions):
499 return 499 return
500 500
669 srcrepo.dirstate.write(None) 669 srcrepo.dirstate.write(None)
670 670
671 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements) 671 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements)
672 672
673 673
674 def upgrade_tracked_key(ui, srcrepo, upgrade_op, add): 674 def upgrade_tracked_hint(ui, srcrepo, upgrade_op, add):
675 if add: 675 if add:
676 srcrepo.dirstate._use_tracked_key = True 676 srcrepo.dirstate._use_tracked_hint = True
677 srcrepo.dirstate._dirty = True 677 srcrepo.dirstate._dirty = True
678 srcrepo.dirstate._dirty_tracked_set = True 678 srcrepo.dirstate._dirty_tracked_set = True
679 srcrepo.dirstate.write(None) 679 srcrepo.dirstate.write(None)
680 if not add: 680 if not add:
681 srcrepo.dirstate.delete_tracked_key() 681 srcrepo.dirstate.delete_tracked_hint()
682 682
683 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements) 683 scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements)