Patchwork D6886: sidedata: introduce a new requirement to protect the feature

login
register
mail settings
Submitter phabricator
Date Oct. 1, 2019, 4:08 p.m.
Message ID <d4b274c540fee85b8f6800416ea1de7b@localhost.localdomain>
Download mbox | patch
Permalink /patch/41893/
State Not Applicable
Headers show

Comments

phabricator - Oct. 1, 2019, 4:08 p.m.
marmoute updated this revision to Diff 16735.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6886?vs=16644&id=16735

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6886/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6886

AFFECTED FILES
  mercurial/configitems.py
  mercurial/localrepo.py
  mercurial/revlog.py

CHANGE DETAILS




To: marmoute, durin42, indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -391,6 +391,7 @@ 
             self._maxdeltachainspan = opts['maxdeltachainspan']
         if self._mmaplargeindex and 'mmapindexthreshold' in opts:
             mmapindexthreshold = opts['mmapindexthreshold']
+        self.hassidedata = bool(opts.get('side-data', False))
         self._sparserevlog = bool(opts.get('sparse-revlog', False))
         withsparseread = bool(opts.get('with-sparse-read', False))
         # sparse-revlog forces sparse-read
@@ -1852,6 +1853,10 @@ 
 
         if sidedata is None:
             sidedata = {}
+        elif not self.hassidedata:
+            raise error.ProgrammingError(
+                _("trying to add sidedata to a revlog who don't support them")
+                )
 
         if flags:
             node = node or self.hash(text, p1, p2)
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -394,6 +394,10 @@ 
 # This is why once a repository has enabled sparse-read, it becomes required.
 SPARSEREVLOG_REQUIREMENT = 'sparserevlog'
 
+# A repository with the sidedataflag requirement will allow to store extra
+# information for revision without altering their original hashes.
+SIDEDATA_REQUIREMENT = 'exp-sidedata-flag'
+
 # Functions receiving (ui, features) that extensions can register to impact
 # the ability to load repositories with custom requirements. Only
 # functions defined in loaded extensions are called.
@@ -807,6 +811,9 @@ 
     if sparserevlog:
         options[b'generaldelta'] = True
 
+    sidedata = SIDEDATA_REQUIREMENT in requirements
+    options[b'side-data'] = sidedata
+
     maxchainlen = None
     if sparserevlog:
         maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH
@@ -910,6 +917,7 @@ 
         'generaldelta',
         'treemanifest',
         REVLOGV2_REQUIREMENT,
+        SIDEDATA_REQUIREMENT,
         SPARSEREVLOG_REQUIREMENT,
         bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT,
     }
@@ -3146,6 +3154,10 @@ 
         requirements.add('generaldelta')
         if ui.configbool('format', 'sparse-revlog'):
             requirements.add(SPARSEREVLOG_REQUIREMENT)
+
+    # experimental config: format.use-side-data
+    if ui.configbool('format', 'use-side-data'):
+        requirements.add(SIDEDATA_REQUIREMENT)
     if ui.configbool('experimental', 'treemanifest'):
         requirements.add('treemanifest')
 
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -733,6 +733,10 @@ 
 coreconfigitem('format', 'usestore',
     default=True,
 )
+coreconfigitem('format', 'use-side-data',
+    default=False,
+    experimental=True,
+)
 coreconfigitem('format', 'internal-phase',
     default=False,
     experimental=True,