# HG changeset patch # User Pierre-Yves David # Date 2014-12-04 13:43:15 # Node ID ee5a4ed4c8b1a1236c75ab699e1e34f86d4fe7c3 # Parent b25f07cb5399e2fa919c81d7425d656df3953051 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. diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -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 @@ class dirstate(object): # 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