# HG changeset patch # User Pierre-Yves David # Date 1417700595 28800 # 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 -r b25f07cb5399 -r ee5a4ed4c8b1 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