phase-shelve: Implement a 'shelve.store' experimental config
authorJason R. Coombs <jaraco@jaraco.com>
Wed, 10 Aug 2022 14:39:28 -0400
changeset 49430 2064bbf7a1d5
parent 49429 fa00c407d61c
child 49431 ad1db3861a8b
phase-shelve: Implement a 'shelve.store' experimental config Accepts "internal" or "strip", indicating how the shelved changes are stored. Defaults to "internal", retaining compatibility for repos with "internal-phase" already enabled.
mercurial/configitems.py
mercurial/shelve.py
--- a/mercurial/configitems.py	Wed Aug 10 14:16:55 2022 -0400
+++ b/mercurial/configitems.py	Wed Aug 10 14:39:28 2022 -0400
@@ -1432,6 +1432,12 @@
     experimental=True,
 )
 coreconfigitem(
+    b'shelve',
+    b'store',
+    default='internal',
+    experimental=True,
+)
+coreconfigitem(
     b'fsmonitor',
     b'warn_when_unused',
     default=True,
--- a/mercurial/shelve.py	Wed Aug 10 14:16:55 2022 -0400
+++ b/mercurial/shelve.py	Wed Aug 10 14:39:28 2022 -0400
@@ -99,8 +99,15 @@
         return sorted(info, reverse=True)
 
 
+def _use_internal_phase(repo):
+    return (
+        phases.supportinternal(repo)
+        and repo.ui.config(b'shelve', b'store') == 'internal'
+    )
+
+
 def _target_phase(repo):
-    return phases.internal if phases.supportinternal(repo) else phases.secret
+    return phases.internal if _use_internal_phase(repo) else phases.secret
 
 
 class Shelf:
@@ -548,7 +555,7 @@
 
 
 def _finishshelve(repo, tr):
-    if phases.supportinternal(repo):
+    if _use_internal_phase(repo):
         tr.close()
     else:
         _aborttransaction(repo, tr)
@@ -789,7 +796,7 @@
             if state.activebookmark and state.activebookmark in repo._bookmarks:
                 bookmarks.activate(repo, state.activebookmark)
             mergefiles(ui, repo, state.wctx, state.pendingctx)
-            if not phases.supportinternal(repo):
+            if not _use_internal_phase(repo):
                 repair.strip(
                     ui, repo, state.nodestoremove, backup=False, topic=b'shelve'
                 )
@@ -876,7 +883,7 @@
         mergefiles(ui, repo, state.wctx, shelvectx)
         restorebranch(ui, repo, state.branchtorestore)
 
-        if not phases.supportinternal(repo):
+        if not _use_internal_phase(repo):
             repair.strip(
                 ui, repo, state.nodestoremove, backup=False, topic=b'shelve'
             )