dirstate: use the 'nogc' decorator
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 04 Dec 2014 05:43:15 -0800
changeset 23496 ee5a4ed4c8b1
parent 23495 b25f07cb5399
child 23497 5817f71c2336
dirstate: use the 'nogc' decorator Now that we have a generic way to disable the gc, we use it. however, we have too use it in a baroque way. See inline comment for details.
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Thu Dec 04 05:43:40 2014 -0800
+++ b/mercurial/dirstate.py	Thu Dec 04 05:43:15 2014 -0800
@@ -8,7 +8,7 @@
 from node import nullid
 from i18n import _
 import scmutil, util, ignore, osutil, parsers, encoding, pathutil
-import os, stat, errno, gc
+import os, stat, errno
 
 propertycache = util.propertycache
 filecache = scmutil.filecache
@@ -317,13 +317,10 @@
         # Depending on when in the process's lifetime the dirstate is parsed,
         # this can get very expensive. As a workaround, disable GC while
         # parsing the dirstate.
-        gcenabled = gc.isenabled()
-        gc.disable()
-        try:
-            p = parsers.parse_dirstate(self._map, self._copymap, st)
-        finally:
-            if gcenabled:
-                gc.enable()
+        #
+        # (we cannot decorate the function directly since it is in a C module)
+        parse_dirstate = util.nogc(parsers.parse_dirstate)
+        p = parse_dirstate(self._map, self._copymap, st)
         if not self._dirtypl:
             self._pl = p