# HG changeset patch # User Martin von Zweigbergk # Date 2014-10-12 07:00:13 # Node ID 39eb9f78f968d1ca9720ee215fae8bfb776587fe # Parent 98f41a2f8fba80ea84891570c0486c1e5c6d25d9 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. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -99,9 +99,6 @@ class basectx(object): For example, this allows other contexts, such as workingctx, to query the dirstate before comparing the manifests. """ - # load earliest manifest first for caching reasons - if self.rev() < other.rev(): - self.manifest() return s def _poststatus(self, other, s, match, listignored, listclean, listunknown): @@ -115,6 +112,9 @@ class basectx(object): def _buildstatus(self, other, s, match, listignored, listclean, listunknown): """build a status with respect to another context""" + # load earliest manifest first for caching reasons + if self.rev() is not None and self.rev() < other.rev(): + self.manifest() mf1 = other._manifestmatches(match, s) mf2 = self._manifestmatches(match, s) @@ -1416,9 +1416,7 @@ class workingctx(committablectx): We use this _prestatus hook to populate the status with information from the dirstate. """ - # doesn't need to call super; if that changes, be aware that super - # calls self.manifest which would slow down the common case of calling - # status against a workingctx's parent + # doesn't need to call super return self._dirstatestatus(match, listignored, listclean, listunknown) def _poststatus(self, other, s, match, listignored, listclean, listunknown):