diff -r 237855525f64 -r 4ff4e23de7df mercurial/util.py --- a/mercurial/util.py Mon May 02 16:27:14 2022 +0400 +++ b/mercurial/util.py Tue May 10 20:30:26 2022 +0100 @@ -2592,6 +2592,14 @@ self.close() +def tryrmdir(f): + try: + removedirs(f) + except OSError as e: + if e.errno != errno.ENOENT and e.errno != errno.ENOTEMPTY: + raise + + def unlinkpath(f, ignoremissing=False, rmdir=True): # type: (bytes, bool, bool) -> None """unlink and remove the directory if it is empty"""