[PATCH] mq: use util.propertycache, introduce method invalidate for mq and repo
Simon Heimberg
simohe at besonet.ch
Fri May 1 15:56:13 CDT 2009
# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1241209449 -7200
# Node ID ff1d180722e90fb6908b6cb29c067ea1889793cc
# Parent cc8cecb78ddab5a5cd06df68a2e8e334a0100ddd
mq: use util.propertycache, introduce method invalidate for mq and repo
diff -r cc8cecb78dda -r ff1d180722e9 hgext/mq.py
--- a/hgext/mq.py Die Apr 28 09:04:26 2009 +0200
+++ b/hgext/mq.py Fre Mai 01 22:24:09 2009 +0200
@@ -123,8 +123,6 @@
self.path = patchdir or os.path.join(path, "patches")
self.opener = util.opener(self.path)
self.ui = ui
- self.applied = []
- self.full_series = []
self.applied_dirty = 0
self.series_dirty = 0
self.series_path = "series"
@@ -134,13 +132,33 @@
self.guards_dirty = False
self._diffopts = None
- if os.path.exists(self.join(self.series_path)):
- self.full_series = self.opener(self.series_path).read().splitlines()
- self.parse_series()
+ def invalidate(self):
+ for a in 'applied full_series series series_guards':
+ if a in self.__dict__:
+ del self.__dict__[a]
+ @util.propertycache
+ def applied(self):
if os.path.exists(self.join(self.status_path)):
lines = self.opener(self.status_path).read().splitlines()
- self.applied = [statusentry(l) for l in lines]
+ return [statusentry(l) for l in lines]
+ return []
+
+ @util.propertycache
+ def full_series(self):
+ if os.path.exists(self.join(self.series_path)):
+ return self.opener(self.series_path).read().splitlines()
+ return []
+
+ @util.propertycache
+ def series(self):
+ self.parse_series()
+ return self.series
+
+ @util.propertycache
+ def series_guards(self):
+ self.parse_series()
+ return self.series_guards
def diffopts(self):
if self._diffopts is None:
@@ -1622,6 +1640,7 @@
if qrepo:
qrepo.add(added)
+
def delete(ui, repo, *patches, **opts):
"""remove patches from queue
@@ -2462,6 +2481,10 @@
return partial
+ def invalidate(self):
+ tagscache = super(mqrepo, self).invalidate()
+ self.mq.invalidate()
+
if repo.local():
repo.__class__ = mqrepo
repo.mq = queue(ui, repo.join(""))
More information about the Mercurial-devel
mailing list