[PATCH 1 of 3] mq: only read files when needed
Simon Heimberg
simohe at besonet.ch
Tue May 5 06:12:27 CDT 2009
# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1241400942 -7200
# Node ID 92db83e3ef34c0f88b81d8b9bf1215a3fc63329c
# Parent da8bb0eb1d2eaacd838399d98d4e6bc764571685
mq: only read files when needed
use util.propertycache as in dirstate
diff -r da8bb0eb1d2e -r 92db83e3ef34 hgext/mq.py
--- a/hgext/mq.py Die Apr 28 18:42:51 2009 +0200
+++ b/hgext/mq.py Mon Mai 04 03:35:42 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,28 @@
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()
-
+ @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:
@@ -2383,6 +2396,10 @@
def reposetup(ui, repo):
class mqrepo(repo.__class__):
+ @util.propertycache
+ def mq(self):
+ return queue(self.ui, self.join(""))
+
def abort_if_wdir_patched(self, errmsg, force=False):
if self.mq.applied and not force:
parent = hex(self.dirstate.parents()[0])
@@ -2464,7 +2481,6 @@
if repo.local():
repo.__class__ = mqrepo
- repo.mq = queue(ui, repo.join(""))
def mqimport(orig, ui, repo, *args, **kwargs):
if hasattr(repo, 'abort_if_wdir_patched'):
More information about the Mercurial-devel
mailing list