[PATCH 1 of 2] obsolete: introduce a format.use-obsolete option

pierre-yves.david at logilab.fr pierre-yves.david at logilab.fr
Wed Jul 4 17:02:02 UTC 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1341363499 -7200
# Node ID 48e69d968ff26f56eb544ca7c86c19f5fef095de
# Parent  77f9e2b534da9f3eead2fbc5446fab938518fe83
obsolete: introduce a format.use-obsolete option

Obsolete markers are still a very experimental feature and won't be fully ready
for the next release. User who want to explicitly experiment with it should
explicitly enable it. Most obsolete related feature  will be disabled until
`format.use-obsolete` option is set to `true`.

A warning is issued if obsolete marker exist in a repo even if the option is
still to false.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -192,12 +192,19 @@ class localrepository(repo.repository):
         return phases.phasecache(self, self._phasedefaults)
 
     @storecache('obsstore')
     def obsstore(self):
         store = obsolete.obsstore(self.sopener)
+        if store and not self._useobsolete():
+            self.ui.warn(_('repo has obsolete markers but '
+                           'format.use-obsolete=false in config!\n'))
         return store
 
+    def _useobsolete(self):
+        """obsolete feature have been explicitly enabled on this repo?"""
+        return self.ui.configbool('format', 'use-obsolete', False)
+
     @storecache('00changelog.i')
     def changelog(self):
         c = changelog.changelog(self.sopener)
         if 'HG_PENDING' in os.environ:
             p = os.environ['HG_PENDING']
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -1,6 +1,8 @@
 
+  $ echo '[format]' >> $HGRCPATH
+  $ echo 'use-obsolete=true' >> $HGRCPATH
   $ mkcommit() {
   >    echo "$1" > "$1"
   >    hg add "$1"
   >    hg ci -m "add $1"
   > }
@@ -77,10 +79,24 @@ Rollback//Transaction support
   245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'}
   cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
   ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
   1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'}
 
+Warning when feature not enable but markers exists
+
+  $ echo '[format]' >> .hg/hgrc
+  $ echo 'use-obsolete=false' >> .hg/hgrc
+  $ hg debugobsolete
+  repo has obsolete markers but format.use-obsolete=false in config!
+  245bde4270cd1072a27757984f9cda8ba26f08ca cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'}
+  cdbce2fbb16313928851e97e0d85413f3f7eb77f ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
+  ca819180edb99ed25ceafb3e9584ac287e240b00 1337133713371337133713371337133713371337 0 {'date': '1338 0', 'user': 'test'}
+  1337133713371337133713371337133713371337 5601fb93a350734d935195fee37f4054c529ff39 0 {'date': '1339 0', 'user': 'test'}
+  $ rm .hg/hgrc
+  $ echo '[format]' > .hg/hgrc
+  $ echo 'use-obsolete=true' >> .hg/hgrc
+
   $ cd ..
 
 Exchange Test
 ============================
 


More information about the Mercurial-devel mailing list