[PATCH 2 of 8] localrepo: rename in-memory tag cache instance attributes

Greg Ward greg-hg at gerg.ca
Sun Jul 12 20:02:05 CDT 2009


# HG changeset patch
# User Greg Ward <greg-hg at gerg.ca>
# Date 1247446898 14400
# Node ID 54e77819251ed3c67118a90c51f0136226249e20
# Parent  16c5fc82c5b79dda2ef60e2db21f92aefe003321
localrepo: rename in-memory tag cache instance attributes.

- self.tagscache to self._tags
- self._tagstypecache to self._tagtypes
- this is for consistency, readability, privacy, and to subtly hint
  that "caching" is something else

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -51,7 +51,7 @@
     def t():
         repo.changelog = mercurial.changelog.changelog(repo.sopener)
         repo.manifest = mercurial.manifest.manifest(repo.sopener)
-        repo.tagscache = None
+        repo._tags = None
         return len(repo.tags())
     timer(t)
 
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -89,8 +89,14 @@
         self.sjoin = self.store.join
         self.opener.createmode = self.store.createmode
 
-        self.tagscache = None
-        self._tagstypecache = None
+        # These two define the set of tags for this repository.  _tags
+        # maps tag name to node; _tagtypes maps tag name to 'global' or
+        # 'local'.  (Global tags are defined by .hgtags across all
+        # heads, and local tags are defined in .hg/localtags.)  They
+        # constitute the in-memory cache of tags.
+        self._tags = None
+        self._tagtypes = None
+
         self.branchcache = None
         self._ubranchcache = None  # UTF-8 version of branchcache
         self._branchcachetip = None
@@ -160,8 +166,8 @@
                 fp.write('\n')
             for name in names:
                 m = munge and munge(name) or name
-                if self._tagstypecache and name in self._tagstypecache:
-                    old = self.tagscache.get(name, nullid)
+                if self._tagtypes and name in self._tagtypes:
+                    old = self._tags.get(name, nullid)
                     fp.write('%s %s\n' % (hex(old), m))
                 fp.write('%s %s\n' % (hex(node), m))
             fp.close()
@@ -233,10 +239,10 @@
 
     def tags(self):
         '''return a mapping of tag to node'''
-        if self.tagscache is None:
-            (self.tagscache, self._tagstypecache) = self._findtags()
+        if self._tags is None:
+            (self._tags, self._tagtypes) = self._findtags()
 
-        return self.tagscache
+        return self._tags
 
     def _findtags(self):
         '''Do the hard work of finding tags.  Return a pair of dicts
@@ -353,7 +359,7 @@
 
         self.tags()
 
-        return self._tagstypecache.get(tagname)
+        return self._tagtypes.get(tagname)
 
     def tagslist(self):
         '''return a list of tags ordered by revision'''
@@ -692,8 +698,8 @@
         for a in "changelog manifest".split():
             if a in self.__dict__:
                 delattr(self, a)
-        self.tagscache = None
-        self._tagstypecache = None
+        self._tags = None
+        self._tagtypes = None
         self.nodetagscache = None
         self.branchcache = None
         self._ubranchcache = None
diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py
+++ b/mercurial/statichttprepo.py
@@ -114,7 +114,7 @@
 
         self.manifest = manifest.manifest(self.sopener)
         self.changelog = changelog.changelog(self.sopener)
-        self.tagscache = None
+        self._tags = None
         self.nodetagscache = None
         self.encodepats = None
         self.decodepats = None


More information about the Mercurial-devel mailing list