[Updated] D12198: tracked-key: make it possible to upgrade to and downgrade from the feature
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Fri Feb 18 10:30:33 UTC 2022
Closed by commit rHG5ba24e886cec: tracked-key: make it possible to upgrade to and downgrade from the feature (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
CHANGED PRIOR TO COMMIT
https://phab.mercurial-scm.org/D12198?vs=32255&id=32262#toc
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D12198?vs=32255&id=32262
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D12198/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D12198
AFFECTED FILES
mercurial/dirstate.py
mercurial/upgrade_utils/actions.py
mercurial/upgrade_utils/engine.py
tests/test-persistent-nodemap.t
tests/test-status-tracked-key.t
tests/test-upgrade-repo.t
CHANGE DETAILS
diff --git a/tests/test-upgrade-repo.t b/tests/test-upgrade-repo.t
--- a/tests/test-upgrade-repo.t
+++ b/tests/test-upgrade-repo.t
@@ -214,6 +214,7 @@
format-variant repo
fncache: yes
dirstate-v2: no
+ tracked-key: no
dotencode: yes
generaldelta: yes
share-safe: yes
@@ -230,6 +231,7 @@
format-variant repo config default
fncache: yes yes yes
dirstate-v2: no no no
+ tracked-key: no no no
dotencode: yes yes yes
generaldelta: yes yes yes
share-safe: yes yes yes
@@ -247,6 +249,7 @@
format-variant repo config default
fncache: yes no yes
dirstate-v2: no no no
+ tracked-key: no no no
dotencode: yes no yes
generaldelta: yes yes yes
share-safe: yes yes yes
@@ -264,6 +267,7 @@
format-variant repo config default
[formatvariant.name.mismatchconfig|fncache: ][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special| no][formatvariant.default| yes]
[formatvariant.name.uptodate|dirstate-v2: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
+ [formatvariant.name.uptodate|tracked-key: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
[formatvariant.name.mismatchconfig|dotencode: ][formatvariant.repo.mismatchconfig| yes][formatvariant.config.special| no][formatvariant.default| yes]
[formatvariant.name.uptodate|generaldelta: ][formatvariant.repo.uptodate| yes][formatvariant.config.default| yes][formatvariant.default| yes]
[formatvariant.name.uptodate|share-safe: ][formatvariant.repo.uptodate| yes][formatvariant.config.default| yes][formatvariant.default| yes]
@@ -292,6 +296,12 @@
"repo": false
},
{
+ "config": false,
+ "default": false,
+ "name": "tracked-key",
+ "repo": false
+ },
+ {
"config": true,
"default": true,
"name": "dotencode",
@@ -488,6 +498,7 @@
format-variant repo
fncache: no
dirstate-v2: no
+ tracked-key: no
dotencode: no
generaldelta: no
share-safe: no
@@ -503,6 +514,7 @@
format-variant repo config default
fncache: no yes yes
dirstate-v2: no no no
+ tracked-key: no no no
dotencode: no yes yes
generaldelta: no yes yes
share-safe: no yes yes
@@ -520,6 +532,7 @@
format-variant repo config default
fncache: no yes yes
dirstate-v2: no no no
+ tracked-key: no no no
dotencode: no yes yes
generaldelta: no no yes
share-safe: no yes yes
@@ -537,6 +550,7 @@
format-variant repo config default
[formatvariant.name.mismatchconfig|fncache: ][formatvariant.repo.mismatchconfig| no][formatvariant.config.default| yes][formatvariant.default| yes]
[formatvariant.name.uptodate|dirstate-v2: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
+ [formatvariant.name.uptodate|tracked-key: ][formatvariant.repo.uptodate| no][formatvariant.config.default| no][formatvariant.default| no]
[formatvariant.name.mismatchconfig|dotencode: ][formatvariant.repo.mismatchconfig| no][formatvariant.config.default| yes][formatvariant.default| yes]
[formatvariant.name.mismatchdefault|generaldelta: ][formatvariant.repo.mismatchdefault| no][formatvariant.config.special| no][formatvariant.default| yes]
[formatvariant.name.mismatchconfig|share-safe: ][formatvariant.repo.mismatchconfig| no][formatvariant.config.default| yes][formatvariant.default| yes]
@@ -1588,6 +1602,7 @@
format-variant repo config default
fncache: yes yes yes
dirstate-v2: no no no
+ tracked-key: no no no
dotencode: yes yes yes
generaldelta: yes yes yes
share-safe: yes yes yes
@@ -1631,6 +1646,7 @@
format-variant repo config default
fncache: yes yes yes
dirstate-v2: no no no
+ tracked-key: no no no
dotencode: yes yes yes
generaldelta: yes yes yes
share-safe: yes yes yes
@@ -1677,6 +1693,7 @@
format-variant repo config default
fncache: yes yes yes
dirstate-v2: no no no
+ tracked-key: no no no
dotencode: yes yes yes
generaldelta: yes yes yes
share-safe: yes yes yes
@@ -1729,6 +1746,7 @@
format-variant repo config default
fncache: yes yes yes
dirstate-v2: no no no
+ tracked-key: no no no
dotencode: yes yes yes
generaldelta: yes yes yes
share-safe: yes yes yes
@@ -1778,6 +1796,7 @@
format-variant repo config default
fncache: yes yes yes
dirstate-v2: no no no
+ tracked-key: no no no
dotencode: yes yes yes
generaldelta: yes yes yes
share-safe: yes yes yes
@@ -1828,6 +1847,7 @@
format-variant repo config default
fncache: yes yes yes
dirstate-v2: no no no
+ tracked-key: no no no
dotencode: yes yes yes
generaldelta: yes yes yes
share-safe: yes yes yes
diff --git a/tests/test-status-tracked-key.t b/tests/test-status-tracked-key.t
--- a/tests/test-status-tracked-key.t
+++ b/tests/test-status-tracked-key.t
@@ -161,3 +161,44 @@
$ hg up '.#generations[-1]'
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ diff --brief .hg/dirstate-tracked-key ../key-bck
+
+Test upgrade and downgrade
+==========================
+
+ $ ls .hg/dirstate-tracked-key
+ .hg/dirstate-tracked-key
+ $ hg debugrequires | grep 'tracked'
+ exp-dirstate-tracked-key-v1
+
+downgrade
+
+ $ hg debugupgraderepo --config format.dirstate-tracked-key=no --run --quiet
+ upgrade will perform the following actions:
+
+ requirements
+ preserved: * (glob)
+ removed: exp-dirstate-tracked-key-v1
+
+ no revlogs to process
+
+ $ ls -1 .hg/dirstate-tracked-key
+ ls: cannot access '.hg/dirstate-tracked-key': $ENOENT$
+ [2]
+ $ hg debugrequires | grep 'tracked'
+ [1]
+
+upgrade
+
+ $ hg debugupgraderepo --config format.dirstate-tracked-key=yes --run --quiet
+ upgrade will perform the following actions:
+
+ requirements
+ preserved: * (glob)
+ added: exp-dirstate-tracked-key-v1
+
+ no revlogs to process
+
+ $ ls -1 .hg/dirstate-tracked-key
+ .hg/dirstate-tracked-key
+ $ hg debugrequires | grep 'tracked'
+ exp-dirstate-tracked-key-v1
diff --git a/tests/test-persistent-nodemap.t b/tests/test-persistent-nodemap.t
--- a/tests/test-persistent-nodemap.t
+++ b/tests/test-persistent-nodemap.t
@@ -65,6 +65,7 @@
format-variant repo
fncache: yes
dirstate-v2: no
+ tracked-key: no
dotencode: yes
generaldelta: yes
share-safe: yes
@@ -782,6 +783,7 @@
format-variant repo config default
fncache: yes yes yes
dirstate-v2: no no no
+ tracked-key: no no no
dotencode: yes yes yes
generaldelta: yes yes yes
share-safe: yes yes yes
@@ -824,6 +826,7 @@
format-variant repo config default
fncache: yes yes yes
dirstate-v2: no no no
+ tracked-key: no no no
dotencode: yes yes yes
generaldelta: yes yes yes
share-safe: yes yes yes
diff --git a/mercurial/upgrade_utils/engine.py b/mercurial/upgrade_utils/engine.py
--- a/mercurial/upgrade_utils/engine.py
+++ b/mercurial/upgrade_utils/engine.py
@@ -486,6 +486,15 @@
upgrade_dirstate(ui, srcrepo, upgrade_op, b'v2', b'v1')
upgrade_op.removed_actions.remove(upgrade_actions.dirstatev2)
+ if upgrade_actions.dirstatetrackedkey in upgrade_op.upgrade_actions:
+ ui.status(_(b'create dirstate-tracked-key file\n'))
+ upgrade_tracked_key(ui, srcrepo, upgrade_op, add=True)
+ upgrade_op.upgrade_actions.remove(upgrade_actions.dirstatetrackedkey)
+ elif upgrade_actions.dirstatetrackedkey in upgrade_op.removed_actions:
+ ui.status(_(b'remove dirstate-tracked-key file\n'))
+ upgrade_tracked_key(ui, srcrepo, upgrade_op, add=False)
+ upgrade_op.removed_actions.remove(upgrade_actions.dirstatetrackedkey)
+
if not (upgrade_op.upgrade_actions or upgrade_op.removed_actions):
return
@@ -660,3 +669,15 @@
srcrepo.dirstate.write(None)
scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements)
+
+
+def upgrade_tracked_key(ui, srcrepo, upgrade_op, add):
+ if add:
+ srcrepo.dirstate._use_tracked_key = True
+ srcrepo.dirstate._dirty = True
+ srcrepo.dirstate._dirty_tracked_set = True
+ srcrepo.dirstate.write(None)
+ if not add:
+ srcrepo.dirstate.delete_tracked_key()
+
+ scmutil.writereporequirements(srcrepo, upgrade_op.new_requirements)
diff --git a/mercurial/upgrade_utils/actions.py b/mercurial/upgrade_utils/actions.py
--- a/mercurial/upgrade_utils/actions.py
+++ b/mercurial/upgrade_utils/actions.py
@@ -200,6 +200,29 @@
@registerformatvariant
+class dirstatetrackedkey(requirementformatvariant):
+ name = b'tracked-key'
+ _requirement = requirements.DIRSTATE_TRACKED_KEY_V1
+
+ default = False
+
+ description = _(
+ b'Add a small file to help external tooling that watch the tracked set'
+ )
+
+ upgrademessage = _(
+ b'external tools will be informated of potential change in the tracked set'
+ )
+
+ touches_filelogs = False
+ touches_manifests = False
+ touches_changelog = False
+ touches_requirements = True
+ touches_dirstate = True
+ compatible_with_share = True
+
+
+ at registerformatvariant
class dotencode(requirementformatvariant):
name = b'dotencode'
@@ -967,6 +990,7 @@
requirements.REVLOGV2_REQUIREMENT,
requirements.CHANGELOGV2_REQUIREMENT,
requirements.REVLOGV1_REQUIREMENT,
+ requirements.DIRSTATE_TRACKED_KEY_V1,
requirements.DIRSTATE_V2_REQUIREMENT,
}
for name in compression.compengines:
@@ -989,6 +1013,7 @@
supported = {
requirements.CHANGELOGV2_REQUIREMENT,
requirements.COPIESSDC_REQUIREMENT,
+ requirements.DIRSTATE_TRACKED_KEY_V1,
requirements.DIRSTATE_V2_REQUIREMENT,
requirements.DOTENCODE_REQUIREMENT,
requirements.FNCACHE_REQUIREMENT,
@@ -1031,6 +1056,7 @@
requirements.REVLOGV1_REQUIREMENT,
requirements.REVLOGV2_REQUIREMENT,
requirements.CHANGELOGV2_REQUIREMENT,
+ requirements.DIRSTATE_TRACKED_KEY_V1,
requirements.DIRSTATE_V2_REQUIREMENT,
}
for name in compression.compengines:
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -763,6 +763,13 @@
with file(self._filename_tk) as f:
self._write_tracked_key(tr, f)
+ def delete_tracked_key(self):
+ """remove the tracked_key file
+
+ To be used by format downgrades operation"""
+ self._opener.unlink(self._filename_tk)
+ self._use_tracked_key = False
+
def addparentchangecallback(self, category, callback):
"""add a callback to be called when the wd parents are changed
To: marmoute, #hg-reviewers, Alphare
Cc: Alphare, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220218/5b06cfd0/attachment-0002.html>
More information about the Mercurial-patches
mailing list