obsolete: add a "format.obsstore-version" config option
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 16 Sep 2014 17:52:40 -0700
changeset 22852 e994b034e91e
parent 22851 974389427e5f
child 22853 9a7d0f7e0561
obsolete: add a "format.obsstore-version" config option This option controls what version of the binary format to use when creating a new obsstore file. Default is still the old format. No safeguards are currently placed around the option value, but no clueless users are in danger of harm since it is undocumented.
mercurial/localrepo.py
mercurial/obsolete.py
--- a/mercurial/localrepo.py	Thu Oct 09 00:10:10 2014 -0700
+++ b/mercurial/localrepo.py	Tue Sep 16 17:52:40 2014 -0700
@@ -400,7 +400,13 @@
 
     @storecache('obsstore')
     def obsstore(self):
-        store = obsolete.obsstore(self.sopener)
+        # read default format for new obsstore.
+        defaultformat = self.ui.configint('format', 'obsstore-version', None)
+        # rely on obsstore class default when possible.
+        kwargs = {}
+        if defaultformat is not None:
+            defaultformat['defaultformat'] = defaultformat
+        store = obsolete.obsstore(self.sopener, **kwargs)
         if store and not obsolete._enabled:
             # message is rare enough to not be translated
             msg = 'obsolete feature not enabled but %i markers found!\n'
--- a/mercurial/obsolete.py	Thu Oct 09 00:10:10 2014 -0700
+++ b/mercurial/obsolete.py	Tue Sep 16 17:52:40 2014 -0700
@@ -450,7 +450,7 @@
     # parents: (tuple of nodeid) or None, parents of precursors
     #          None is used when no data has been recorded
 
-    def __init__(self, sopener):
+    def __init__(self, sopener, defaultformat=_fm0version):
         # caches for various obsolescence related cache
         self.caches = {}
         self._all = []
@@ -459,7 +459,7 @@
         self.children = {}
         self.sopener = sopener
         data = sopener.tryread('obsstore')
-        self._version = _fm0version
+        self._version = defaultformat
         if data:
             self._version, markers = _readmarkers(data)
             self._load(markers)