##// END OF EJS Templates
blackbox: guard against recursion from dirty check
timeless -
r28407:63da8bd0 default
parent child Browse files
Show More
@@ -81,6 +81,7 b' def wrapui(ui):'
81 81 self._partialinit()
82 82 else:
83 83 self._bbfp = src._bbfp
84 self._bbinlog = False
84 85 self._bbrepo = src._bbrepo
85 86 self._bbvfs = src._bbvfs
86 87
@@ -88,6 +89,7 b' def wrapui(ui):'
88 89 if util.safehasattr(self, '_bbvfs'):
89 90 return
90 91 self._bbfp = None
92 self._bbinlog = False
91 93 self._bbrepo = None
92 94 self._bbvfs = None
93 95
@@ -160,7 +162,15 b' def wrapui(ui):'
160 162 # was seen.
161 163 ui = lastui
162 164
163 if ui and ui._bbfp:
165 if not ui or not ui._bbfp:
166 return
167 if not lastui or ui._bbrepo:
168 lastui = ui
169 if ui._bbinlog:
170 # recursion guard
171 return
172 try:
173 ui._bbinlog = True
164 174 date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
165 175 user = util.getuser()
166 176 pid = str(util.getpid())
@@ -186,11 +196,12 b' def wrapui(ui):'
186 196 except IOError as err:
187 197 self.debug('warning: cannot write to blackbox.log: %s\n' %
188 198 err.strerror)
189 if not lastui or ui._bbrepo:
190 lastui = ui
199 finally:
200 ui._bbinlog = False
191 201
192 202 def setrepo(self, repo):
193 203 self._bbfp = None
204 self._bbinlog = False
194 205 self._bbrepo = repo
195 206 self._bbvfs = repo.vfs
196 207
@@ -191,5 +191,19 b' log rotation'
191 191 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip exited 0 after * seconds (glob)
192 192 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox
193 193
194 Test log recursion from dirty status check
195
196 $ cat > ../r.py <<EOF
197 > from mercurial import context, error, extensions
198 > x=[False]
199 > def status(orig, *args, **opts):
200 > args[0].repo().ui.log("broken", "recursion?")
201 > return orig(*args, **opts)
202 > def reposetup(ui, repo):
203 > extensions.wrapfunction(context.basectx, 'status', status)
204 > EOF
205 $ hg id --config extensions.x=../r.py --config blackbox.dirty=True
206 45589e459b2e tip
207
194 208 cleanup
195 209 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now