Show More
@@ -80,7 +80,6 b' def wrapui(ui):' | |||||
80 | if src is None: |
|
80 | if src is None: | |
81 | self._partialinit() |
|
81 | self._partialinit() | |
82 | else: |
|
82 | else: | |
83 | self._bbfp = getattr(src, '_bbfp', None) |
|
|||
84 | self._bbinlog = False |
|
83 | self._bbinlog = False | |
85 | self._bbrepo = getattr(src, '_bbrepo', None) |
|
84 | self._bbrepo = getattr(src, '_bbrepo', None) | |
86 | self._bbvfs = getattr(src, '_bbvfs', None) |
|
85 | self._bbvfs = getattr(src, '_bbvfs', None) | |
@@ -88,7 +87,6 b' def wrapui(ui):' | |||||
88 | def _partialinit(self): |
|
87 | def _partialinit(self): | |
89 | if util.safehasattr(self, '_bbvfs'): |
|
88 | if util.safehasattr(self, '_bbvfs'): | |
90 | return |
|
89 | return | |
91 | self._bbfp = None |
|
|||
92 | self._bbinlog = False |
|
90 | self._bbinlog = False | |
93 | self._bbrepo = None |
|
91 | self._bbrepo = None | |
94 | self._bbvfs = None |
|
92 | self._bbvfs = None | |
@@ -143,16 +141,7 b' def wrapui(ui):' | |||||
143 | if not '*' in self.track and not event in self.track: |
|
141 | if not '*' in self.track and not event in self.track: | |
144 | return |
|
142 | return | |
145 |
|
143 | |||
146 |
if self._bb |
|
144 | if self._bbvfs: | |
147 | ui = self |
|
|||
148 | elif self._bbvfs: |
|
|||
149 | try: |
|
|||
150 | self._bbfp = self._openlogfile() |
|
|||
151 | except (IOError, OSError) as err: |
|
|||
152 | self.debug('warning: cannot write to blackbox.log: %s\n' % |
|
|||
153 | err.strerror) |
|
|||
154 | del self._bbvfs |
|
|||
155 | self._bbfp = None |
|
|||
156 | ui = self |
|
145 | ui = self | |
157 | else: |
|
146 | else: | |
158 | # certain ui instances exist outside the context of |
|
147 | # certain ui instances exist outside the context of | |
@@ -160,12 +149,12 b' def wrapui(ui):' | |||||
160 | # was seen. |
|
149 | # was seen. | |
161 | ui = lastui |
|
150 | ui = lastui | |
162 |
|
151 | |||
163 |
if not ui |
|
152 | if not ui: | |
164 | return |
|
153 | return | |
165 | if not lastui or ui._bbrepo: |
|
154 | if not lastui or ui._bbrepo: | |
166 | lastui = ui |
|
155 | lastui = ui | |
167 | if ui._bbinlog: |
|
156 | if ui._bbinlog: | |
168 | # recursion guard |
|
157 | # recursion and failure guard | |
169 | return |
|
158 | return | |
170 | try: |
|
159 | try: | |
171 | ui._bbinlog = True |
|
160 | ui._bbinlog = True | |
@@ -188,19 +177,21 b' def wrapui(ui):' | |||||
188 | else: |
|
177 | else: | |
189 | src = '' |
|
178 | src = '' | |
190 | try: |
|
179 | try: | |
191 | fp = ui._bbfp |
|
|||
192 | fmt = '%s %s @%s%s (%s)%s> %s' |
|
180 | fmt = '%s %s @%s%s (%s)%s> %s' | |
193 | args = (date, user, rev, changed, pid, src, formattedmsg) |
|
181 | args = (date, user, rev, changed, pid, src, formattedmsg) | |
|
182 | with ui._openlogfile() as fp: | |||
194 | fp.write(fmt % args) |
|
183 | fp.write(fmt % args) | |
195 | fp.flush() |
|
184 | except (IOError, OSError) as err: | |
196 | except IOError as err: |
|
|||
197 | self.debug('warning: cannot write to blackbox.log: %s\n' % |
|
185 | self.debug('warning: cannot write to blackbox.log: %s\n' % | |
198 | err.strerror) |
|
186 | err.strerror) | |
|
187 | # do not restore _bbinlog intentionally to avoid failed | |||
|
188 | # logging again | |||
|
189 | else: | |||
|
190 | ui._bbinlog = False | |||
199 | finally: |
|
191 | finally: | |
200 |
|
|
192 | pass | |
201 |
|
193 | |||
202 | def setrepo(self, repo): |
|
194 | def setrepo(self, repo): | |
203 | self._bbfp = None |
|
|||
204 | self._bbinlog = False |
|
195 | self._bbinlog = False | |
205 | self._bbrepo = repo |
|
196 | self._bbrepo = repo | |
206 | self._bbvfs = repo.vfs |
|
197 | self._bbvfs = repo.vfs |
General Comments 0
You need to be logged in to leave comments.
Login now