comparison mercurial/context.py @ 23238:39eb9f78f968

context.status: move manifest caching trick to _buildstatus() In basectx._buildstatus(), we read the manifests for the two revisions being compared. For "caching reasons" unknown to me, it is better to read the earlier manifest first, which basectx._prestatus() takes care of. However, if the 'self' context is a committablectx and the 'other' context is the parent of the working directory (as in the very common case of plain "hg status"), there is no need to read any manifests at all -- all that's needed is the dirstate status. To avoid reading the manifests, _prestatus() is overridden in committablectx and avoids calling its super method, and _buildstatus() calls its super method only if the 'other' context is not the parent of the working directory. It seems easier to follow what's happening if we move the pre-fetching to _buildstatus() just before the place where the manifests are fetched. We just need to add an extra check that the revision is not None to handle the case that was previously handled by subclass overriding. That also makes it safe for committablectx._prestatus() to call its parent, although the latter now becomes empty, so we won't bother.
author Martin von Zweigbergk <martinvonz@gmail.com>
date Sun, 12 Oct 2014 00:00:13 -0700
parents 98f41a2f8fba
children 9fbb50444d55
comparison
equal deleted inserted replaced
23237:98f41a2f8fba 23238:39eb9f78f968
97 """provide a hook to allow child objects to preprocess status results 97 """provide a hook to allow child objects to preprocess status results
98 98
99 For example, this allows other contexts, such as workingctx, to query 99 For example, this allows other contexts, such as workingctx, to query
100 the dirstate before comparing the manifests. 100 the dirstate before comparing the manifests.
101 """ 101 """
102 # load earliest manifest first for caching reasons
103 if self.rev() < other.rev():
104 self.manifest()
105 return s 102 return s
106 103
107 def _poststatus(self, other, s, match, listignored, listclean, listunknown): 104 def _poststatus(self, other, s, match, listignored, listclean, listunknown):
108 """provide a hook to allow child objects to postprocess status results 105 """provide a hook to allow child objects to postprocess status results
109 106
113 return s 110 return s
114 111
115 def _buildstatus(self, other, s, match, listignored, listclean, 112 def _buildstatus(self, other, s, match, listignored, listclean,
116 listunknown): 113 listunknown):
117 """build a status with respect to another context""" 114 """build a status with respect to another context"""
115 # load earliest manifest first for caching reasons
116 if self.rev() is not None and self.rev() < other.rev():
117 self.manifest()
118 mf1 = other._manifestmatches(match, s) 118 mf1 = other._manifestmatches(match, s)
119 mf2 = self._manifestmatches(match, s) 119 mf2 = self._manifestmatches(match, s)
120 120
121 modified, added, clean = [], [], [] 121 modified, added, clean = [], [], []
122 deleted, unknown, ignored = s[3], s[4], s[5] 122 deleted, unknown, ignored = s[3], s[4], s[5]
1414 """override the parent hook with a dirstate query 1414 """override the parent hook with a dirstate query
1415 1415
1416 We use this _prestatus hook to populate the status with information from 1416 We use this _prestatus hook to populate the status with information from
1417 the dirstate. 1417 the dirstate.
1418 """ 1418 """
1419 # doesn't need to call super; if that changes, be aware that super 1419 # doesn't need to call super
1420 # calls self.manifest which would slow down the common case of calling
1421 # status against a workingctx's parent
1422 return self._dirstatestatus(match, listignored, listclean, listunknown) 1420 return self._dirstatestatus(match, listignored, listclean, listunknown)
1423 1421
1424 def _poststatus(self, other, s, match, listignored, listclean, listunknown): 1422 def _poststatus(self, other, s, match, listignored, listclean, listunknown):
1425 """override the parent hook with a filter for suspect symlinks 1423 """override the parent hook with a filter for suspect symlinks
1426 1424