Show More
@@ -44,6 +44,7 b' from mercurial.node import hex' | |||
|
44 | 44 | |
|
45 | 45 | from mercurial import ( |
|
46 | 46 | cmdutil, |
|
47 | ui as uimod, | |
|
47 | 48 | util, |
|
48 | 49 | ) |
|
49 | 50 | |
@@ -79,6 +80,26 b' def hexfn(node):' | |||
|
79 | 80 | |
|
80 | 81 | def wrapui(ui): |
|
81 | 82 | class blackboxui(ui.__class__): |
|
83 | def __init__(self, src=None): | |
|
84 | super(blackboxui, self).__init__(src) | |
|
85 | if src is None: | |
|
86 | self._partialinit() | |
|
87 | else: | |
|
88 | self._bbfp = src._bbfp | |
|
89 | self._bbrepo = src._bbrepo | |
|
90 | self._bbvfs = src._bbvfs | |
|
91 | ||
|
92 | def _partialinit(self): | |
|
93 | if util.safehasattr(self, '_bbvfs'): | |
|
94 | return | |
|
95 | self._bbfp = None | |
|
96 | self._bbrepo = None | |
|
97 | self._bbvfs = None | |
|
98 | ||
|
99 | def copy(self): | |
|
100 | self._partialinit() | |
|
101 | return self.__class__(self) | |
|
102 | ||
|
82 | 103 | @util.propertycache |
|
83 | 104 | def track(self): |
|
84 | 105 | return self.configlist('blackbox', 'track', ['*']) |
@@ -122,13 +143,14 b' def wrapui(ui):' | |||
|
122 | 143 | def log(self, event, *msg, **opts): |
|
123 | 144 | global lastui |
|
124 | 145 | super(blackboxui, self).log(event, *msg, **opts) |
|
146 | self._partialinit() | |
|
125 | 147 | |
|
126 | 148 | if not '*' in self.track and not event in self.track: |
|
127 | 149 | return |
|
128 | 150 | |
|
129 |
if |
|
|
151 | if self._bbfp: | |
|
130 | 152 | ui = self |
|
131 |
elif |
|
|
153 | elif self._bbvfs: | |
|
132 | 154 | try: |
|
133 | 155 | self._bbfp = self._openlogfile() |
|
134 | 156 | except (IOError, OSError) as err: |
@@ -143,15 +165,14 b' def wrapui(ui):' | |||
|
143 | 165 | # was seen. |
|
144 | 166 | ui = lastui |
|
145 | 167 | |
|
146 | if (util.safehasattr(ui, '_bbfp') and | |
|
147 | ui._bbfp is not None): | |
|
168 | if ui and ui._bbfp: | |
|
148 | 169 | date = util.datestr(None, '%Y/%m/%d %H:%M:%S') |
|
149 | 170 | user = util.getuser() |
|
150 | 171 | pid = str(util.getpid()) |
|
151 | 172 | formattedmsg = msg[0] % msg[1:] |
|
152 | 173 | rev = '(unknown)' |
|
153 | 174 | changed = '' |
|
154 |
if u |
|
|
175 | if ui._bbrepo: | |
|
155 | 176 | ctx = ui._bbrepo[None] |
|
156 | 177 | if ctx.rev() is not None: |
|
157 | 178 | rev = hexfn(ctx.node()) |
@@ -169,14 +190,16 b' def wrapui(ui):' | |||
|
169 | 190 | except IOError as err: |
|
170 | 191 | self.debug('warning: cannot write to blackbox.log: %s\n' % |
|
171 | 192 | err.strerror) |
|
172 |
if not lastui or u |
|
|
193 | if not lastui or ui._bbrepo: | |
|
173 | 194 | lastui = ui |
|
174 | 195 | |
|
175 | 196 | def setrepo(self, repo): |
|
197 | self._bbfp = None | |
|
198 | self._bbrepo = repo | |
|
176 | 199 | self._bbvfs = repo.vfs |
|
177 | self._bbrepo = repo | |
|
178 | 200 | |
|
179 | 201 | ui.__class__ = blackboxui |
|
202 | uimod.ui = blackboxui | |
|
180 | 203 | |
|
181 | 204 | def uisetup(ui): |
|
182 | 205 | wrapui(ui) |
@@ -178,8 +178,15 b' log rotation' | |||
|
178 | 178 | |
|
179 | 179 | result: None |
|
180 | 180 | $ hg blackbox |
|
181 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox | |
|
182 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox exited 0 after * seconds (glob) | |
|
181 | 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> commit -m commit2 -d 2000-01-02 foo | |
|
182 | 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> updated served branch cache in * seconds (glob) | |
|
183 | 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> wrote served branch cache with 1 labels and 1 nodes | |
|
184 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> commit -m commit2 -d 2000-01-02 foo exited 0 after * seconds (glob) | |
|
185 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0 | |
|
186 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> writing .hg/cache/tags2-visible with 0 tags | |
|
187 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0 exited 0 after * seconds (glob) | |
|
188 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip | |
|
189 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip exited 0 after * seconds (glob) | |
|
183 | 190 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox |
|
184 | 191 | |
|
185 | 192 | cleanup |
General Comments 0
You need to be logged in to leave comments.
Login now