[PATCH 4 of 7 V6] dirstate: attach the nonnormalset to a propertycache

Laurent Charignon lcharignon at fb.com
Tue Dec 22 13:09:33 CST 2015


On Dec 22, 2015, at 8:23 AM, Martin von Zweigbergk <martinvonz at google.com<mailto:martinvonz at google.com>> wrote:

On Mon, Dec 21, 2015 at 4:36 PM Laurent Charignon <lcharignon at fb.com<mailto:lcharignon at fb.com>> wrote:
# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com<mailto:lcharignon at fb.com>>
# Date 1450743882 28800
#      Mon Dec 21 16:24:42 2015 -0800
# Node ID d3209dc5c211a7c937b68a4712dd77bc3ec978e1
# Parent  1be21e4798cd66383e8f63eafe84a3e32ef4b8d9
dirstate: attach the nonnormalset to a propertycache

This patch attaches the nonnormalset to a property cache so that we build it
only when needed.

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -124,6 +124,11 @@ class dirstate(object):
         return self._copymap

     @propertycache
+    def _nonnormalset(self):
+        self._read()
+        return self._nonnormalset

I would have expected "return self.nonnomalentries(self._dmap)".

Calling self._read() assigns self._nonnormalset from the dmap already

@propertycache makes the first access to dirstate._nonnormalset call this function, then it replaces the function by the returned value, so future calls will just access the value. You can (and should) probably also remove the assignment of self._nonnormalset in the initializer.

What are you referring to?
self._nonnormalset is not assigned in the initializer, it is assigned in two places _writedirstate, clear and _read the same places that self._map is assigned.

I don't know Python well enough to say for sure, but I'd guess that replaces the self._nonnormalset object created by @propertycache.


+
+    @propertycache
     def _filefoldmap(self):
         try:
             makefilefoldmap = parsers.make_file_foldmap
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel at selenic.com<mailto:Mercurial-devel at selenic.com>
https://selenic.com/mailman/listinfo/mercurial-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20151222/fb8b777b/attachment.html>


More information about the Mercurial-devel mailing list