diff -r 06105aa8bc0e -r 233ee525dcef mercurial/pathutil.py --- a/mercurial/pathutil.py Mon May 25 17:32:25 2020 -0400 +++ b/mercurial/pathutil.py Mon May 25 17:39:23 2020 -0400 @@ -1,5 +1,6 @@ from __future__ import absolute_import +import contextlib import errno import os import posixpath @@ -148,6 +149,19 @@ except (OSError, error.Abort): return False + @contextlib.contextmanager + def cached(self): + if self._cached: + yield + else: + try: + self._cached = True + yield + finally: + self.audited.clear() + self.auditeddir.clear() + self._cached = False + def canonpath(root, cwd, myname, auditor=None): '''return the canonical path of myname, given cwd and root