comparison tests/test-revset2.t @ 35501:12a46ad67a3c

smartset: split generatorset classes to avoid cycle I uncovered a cycle manifesting in a memory leak by running `hgperfrevset '::tip'`. The cycle was due to generatorset.__init__ assigning a bound method to self.__contains__. Internet sleuthing revealed that assigning a bound method to an instance attribute always creates a cycle. This commit creates two new variants of generatorset for the special cases of ascending and descending generators. The special implementations of __contains__ have been extracted to these classes where they are defined as __contains__. generatorset now implements __new__ and changes the spawned type to one of the new classes if needed. Differential Revision: https://phab.mercurial-scm.org/D1780
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 27 Dec 2017 11:08:32 -0700
parents 1644623ab096
children 1a09dad8b85a
comparison
equal deleted inserted replaced
35500:87918218da70 35501:12a46ad67a3c
150 (symbol 'ancestors') 150 (symbol 'ancestors')
151 (symbol '4')))) 151 (symbol '4'))))
152 * set: 152 * set:
153 <addset 153 <addset
154 <baseset- [1, 3, 5]>, 154 <baseset- [1, 3, 5]>,
155 <generatorset+>> 155 <generatorsetdesc+>>
156 5 156 5
157 3 157 3
158 1 158 1
159 0 159 0
160 2 160 2
172 (dagrange 172 (dagrange
173 (symbol '1') 173 (symbol '1')
174 (symbol '5')))))) 174 (symbol '5'))))))
175 * set: 175 * set:
176 <addset+ 176 <addset+
177 <generatorset+>, 177 <generatorsetdesc+>,
178 <baseset- [1, 3, 5]>> 178 <baseset- [1, 3, 5]>>
179 0 179 0
180 1 180 1
181 2 181 2
182 3 182 3
925 (symbol 'descendants') 925 (symbol 'descendants')
926 (func 926 (func
927 (symbol 'merge') 927 (symbol 'merge')
928 None)) 928 None))
929 * set: 929 * set:
930 <generatorset+> 930 <generatorsetasc+>
931 6 931 6
932 7 932 7
933 933
934 test infinite recursion 934 test infinite recursion
935 935