changeset 17207:62c56c94c77e

hidden: move hiddenrevs set on the repository This set is always accessed through the repo for now. Having this set carried by the changelog make it complicated to: - initialize it, computing hidden set may involve revset call - lazy compute it, (1) only the changelog can detect someone access it, (2) only the repo have enought knowledge to compute it. In later version I expect he changelog to apply filtering itself and the set to be carried by changelog again.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 16 Jul 2012 17:44:46 +0200
parents 70ebb4bd8083
children 8018f2340807
files mercurial/changelog.py mercurial/cmdutil.py mercurial/context.py mercurial/localrepo.py tests/test-glog.t tests/test-log.t
diffstat 6 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changelog.py	Fri Jul 13 14:38:49 2012 +0200
+++ b/mercurial/changelog.py	Mon Jul 16 17:44:46 2012 +0200
@@ -120,8 +120,6 @@
         self._realopener = opener
         self._delayed = False
         self._divert = False
-        # hiddenrevs: revs that should be hidden by command and tools
-        self.hiddenrevs = set()
 
     def delayupdate(self):
         "delay visibility of index updates to other readers"
--- a/mercurial/cmdutil.py	Fri Jul 13 14:38:49 2012 +0200
+++ b/mercurial/cmdutil.py	Mon Jul 16 17:44:46 2012 +0200
@@ -1396,7 +1396,7 @@
     if not opts.get('hidden'):
         # --hidden is still experimental and not worth a dedicated revset
         # yet. Fortunately, filtering revision number is fast.
-        revs = (r for r in revs if r not in repo.changelog.hiddenrevs)
+        revs = (r for r in revs if r not in repo.hiddenrevs)
     else:
         revs = iter(revs)
     return revs, expr, filematcher
--- a/mercurial/context.py	Fri Jul 13 14:38:49 2012 +0200
+++ b/mercurial/context.py	Mon Jul 16 17:44:46 2012 +0200
@@ -203,7 +203,7 @@
     def mutable(self):
         return self.phase() > phases.public
     def hidden(self):
-        return self._rev in self._repo.changelog.hiddenrevs
+        return self._rev in self._repo.hiddenrevs
 
     def parents(self):
         """return contexts for each parent changeset"""
--- a/mercurial/localrepo.py	Fri Jul 13 14:38:49 2012 +0200
+++ b/mercurial/localrepo.py	Mon Jul 16 17:44:46 2012 +0200
@@ -131,7 +131,12 @@
         # Callback are in the form: func(repo, roots) --> processed root.
         # This list it to be filled by extension during repo setup
         self._phasedefaults = []
-
+        # hiddenrevs: revs that should be hidden by command and tools
+        #
+        # This set is carried on the repo to ease initialisation and lazy
+        # loading it'll probably move back to changelog for efficienty and
+        # consistency reason
+        self.hiddenrevs = set()
         try:
             self.ui.readconfig(self.join("hgrc"), self.root)
             extensions.loadall(self.ui)
--- a/tests/test-glog.t	Fri Jul 13 14:38:49 2012 +0200
+++ b/tests/test-glog.t	Mon Jul 16 17:44:46 2012 +0200
@@ -2047,7 +2047,7 @@
   > def reposetup(ui, repo):
   >     for line in repo.opener('hidden'):
   >         ctx = repo[line.strip()]
-  >         repo.changelog.hiddenrevs.add(ctx.rev())
+  >         repo.hiddenrevs.add(ctx.rev())
   > EOF
   $ echo '[extensions]' >> .hg/hgrc
   $ echo "hidden=$HGTMP/testhidden.py" >> .hg/hgrc
--- a/tests/test-log.t	Fri Jul 13 14:38:49 2012 +0200
+++ b/tests/test-log.t	Mon Jul 16 17:44:46 2012 +0200
@@ -1146,7 +1146,7 @@
   > def reposetup(ui, repo):
   >     for line in repo.opener('hidden'):
   >         ctx = repo[line.strip()]
-  >         repo.changelog.hiddenrevs.add(ctx.rev())
+  >         repo.hiddenrevs.add(ctx.rev())
   > EOF
   $ echo '[extensions]' >> $HGRCPATH
   $ echo "hidden=$HGTMP/testhidden.py" >> $HGRCPATH