##// 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 self._partialinit()
81 self._partialinit()
82 else:
82 else:
83 self._bbfp = src._bbfp
83 self._bbfp = src._bbfp
84 self._bbinlog = False
84 self._bbrepo = src._bbrepo
85 self._bbrepo = src._bbrepo
85 self._bbvfs = src._bbvfs
86 self._bbvfs = src._bbvfs
86
87
@@ -88,6 +89,7 b' def wrapui(ui):'
88 if util.safehasattr(self, '_bbvfs'):
89 if util.safehasattr(self, '_bbvfs'):
89 return
90 return
90 self._bbfp = None
91 self._bbfp = None
92 self._bbinlog = False
91 self._bbrepo = None
93 self._bbrepo = None
92 self._bbvfs = None
94 self._bbvfs = None
93
95
@@ -160,7 +162,15 b' def wrapui(ui):'
160 # was seen.
162 # was seen.
161 ui = lastui
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 date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
174 date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
165 user = util.getuser()
175 user = util.getuser()
166 pid = str(util.getpid())
176 pid = str(util.getpid())
@@ -186,11 +196,12 b' def wrapui(ui):'
186 except IOError as err:
196 except IOError as err:
187 self.debug('warning: cannot write to blackbox.log: %s\n' %
197 self.debug('warning: cannot write to blackbox.log: %s\n' %
188 err.strerror)
198 err.strerror)
189 if not lastui or ui._bbrepo:
199 finally:
190 lastui = ui
200 ui._bbinlog = False
191
201
192 def setrepo(self, repo):
202 def setrepo(self, repo):
193 self._bbfp = None
203 self._bbfp = None
204 self._bbinlog = False
194 self._bbrepo = repo
205 self._bbrepo = repo
195 self._bbvfs = repo.vfs
206 self._bbvfs = repo.vfs
196
207
@@ -191,5 +191,19 b' log rotation'
191 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip exited 0 after * seconds (glob)
191 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip exited 0 after * seconds (glob)
192 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox
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 cleanup
208 cleanup
195 $ cd ..
209 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now