[PATCH 2 of 7] localrepo: rename in-memory tag cache instance attributes
Greg Ward
greg at gerg.ca
Fri Jul 3 09:48:26 CDT 2009
# HG changeset patch
# User Greg Ward <greg at gerg.ca>
# Date 1246632310 14400
# Node ID 1875f865e40bc73373a290aac1c6b284b9f0d132
# Parent bc27cc5162749383dbf6852aeb2d8b426e1bf6fd
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 on some head,
+ # 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,16 +239,16 @@
def tags(self):
'''return a mapping of tag to node'''
- if self.tagscache:
- return self.tagscache
+ if self._tags:
+ return self._tags
else:
return self._findtags()
def _findtags(self):
- '''do the hard work of finding tags and populating self.tagscache'''
+ '''do the hard work of finding tags and populating self._tags'''
# XXX bogus: this method has both side effect (update
- # self.tagscache) and return value (self.tagscache itself).
+ # self._tags) and return value (self._tags itself).
# Worse, tags() uses it for side effect, but mqrepo and
# bookmarkrepo both use it for its return value. Make up your
# mind: return value or side effect -- not both!
@@ -329,15 +335,15 @@
except IOError:
pass
- self.tagscache = {}
- self._tagstypecache = {}
+ self._tags = {}
+ self._tagtypes = {}
for k, nh in globaltags.iteritems():
n = nh[0]
if n != nullid:
- self.tagscache[k] = n
- self._tagstypecache[k] = tagtypes[k]
- self.tagscache['tip'] = self.changelog.tip()
- return self.tagscache
+ self._tags[k] = n
+ self._tagtypes[k] = tagtypes[k]
+ self._tags['tip'] = self.changelog.tip()
+ return self._tags
def tagtype(self, tagname):
'''
@@ -350,7 +356,7 @@
self.tags()
- return self._tagstypecache.get(tagname)
+ return self._tagtypes.get(tagname)
def tagslist(self):
'''return a list of tags ordered by revision'''
@@ -687,8 +693,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