workingctx: use member variables to store ignored and clean
authorSteve Borho <steve@borho.org>
Tue, 04 May 2010 15:02:55 -0500
changeset 11099 a68bd3b7c040
parent 11098 380ab78dbd69
child 11100 83968ae4aaf2
workingctx: use member variables to store ignored and clean If some code tries to query ignored or clean files without first calling the explicit status() method to query them, it will raise an exception (indicating a software bug).
mercurial/context.py
--- a/mercurial/context.py	Tue May 04 14:52:25 2010 -0500
+++ b/mercurial/context.py	Tue May 04 15:02:55 2010 -0500
@@ -564,7 +564,12 @@
         if user:
             self._user = user
         if changes:
-            self._status = list(changes)
+            self._status = list(changes[:5])
+            self._ignored = changes[5]
+            self._clean = changes[6]
+        else:
+            self._ignored = None
+            self._clean = None
 
         self._extra = {}
         if extra:
@@ -624,7 +629,7 @@
 
     @propertycache
     def _status(self):
-        return self._repo.status(unknown=True)
+        return self._repo.status(unknown=True)[:5]
 
     @propertycache
     def _user(self):
@@ -647,8 +652,10 @@
         Unless this method is used to query the working copy status, the
         _status property will implicitly read the status using its default
         arguments."""
-        self._status = self._repo.status(ignored=ignored, clean=clean,
-                                         unknown=unknown)
+        stat = self._repo.status(ignored=ignored, clean=clean, unknown=unknown)
+        self._ignored = ignored and stat[5] or None
+        self._clean = clean and stat[6] or None
+        self._status = stat[:5]
         return self._status
 
     def manifest(self):
@@ -673,9 +680,13 @@
     def unknown(self):
         return self._status[4]
     def ignored(self):
-        return self._status[5]
+        if self._ignored is None:
+            raise util.Abort(_("Ignored files requested without prior query\n"))
+        return self._ignored
     def clean(self):
-        return self._status[6]
+        if self._clean is None:
+            raise util.Abort(_("Clean files requested without prior query\n"))
+        return self._clean
     def branch(self):
         return self._extra['branch']
     def extra(self):