Mercurial > hg
changeset 28407:63da8bd0c65e
blackbox: guard against recursion from dirty check
author | timeless <timeless@mozdev.org> |
---|---|
date | Tue, 08 Mar 2016 20:34:59 +0000 |
parents | 0767c2f624c6 |
children | 4ac63ed377ba |
files | hgext/blackbox.py tests/test-blackbox.t |
diffstat | 2 files changed, 28 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/blackbox.py Tue Mar 08 20:52:57 2016 +0000 +++ b/hgext/blackbox.py Tue Mar 08 20:34:59 2016 +0000 @@ -81,6 +81,7 @@ self._partialinit() else: self._bbfp = src._bbfp + self._bbinlog = False self._bbrepo = src._bbrepo self._bbvfs = src._bbvfs @@ -88,6 +89,7 @@ if util.safehasattr(self, '_bbvfs'): return self._bbfp = None + self._bbinlog = False self._bbrepo = None self._bbvfs = None @@ -160,7 +162,15 @@ # was seen. ui = lastui - if ui and ui._bbfp: + if not ui or not ui._bbfp: + return + if not lastui or ui._bbrepo: + lastui = ui + if ui._bbinlog: + # recursion guard + return + try: + ui._bbinlog = True date = util.datestr(None, '%Y/%m/%d %H:%M:%S') user = util.getuser() pid = str(util.getpid()) @@ -186,11 +196,12 @@ except IOError as err: self.debug('warning: cannot write to blackbox.log: %s\n' % err.strerror) - if not lastui or ui._bbrepo: - lastui = ui + finally: + ui._bbinlog = False def setrepo(self, repo): self._bbfp = None + self._bbinlog = False self._bbrepo = repo self._bbvfs = repo.vfs
--- a/tests/test-blackbox.t Tue Mar 08 20:52:57 2016 +0000 +++ b/tests/test-blackbox.t Tue Mar 08 20:34:59 2016 +0000 @@ -191,5 +191,19 @@ 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip exited 0 after * seconds (glob) 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox +Test log recursion from dirty status check + + $ cat > ../r.py <<EOF + > from mercurial import context, error, extensions + > x=[False] + > def status(orig, *args, **opts): + > args[0].repo().ui.log("broken", "recursion?") + > return orig(*args, **opts) + > def reposetup(ui, repo): + > extensions.wrapfunction(context.basectx, 'status', status) + > EOF + $ hg id --config extensions.x=../r.py --config blackbox.dirty=True + 45589e459b2e tip + cleanup $ cd ..