68 def _closelog(vfs): |
68 def _closelog(vfs): |
69 path = vfs.join('blackbox.log') |
69 path = vfs.join('blackbox.log') |
70 fp = filehandles[path] |
70 fp = filehandles[path] |
71 del filehandles[path] |
71 del filehandles[path] |
72 fp.close() |
72 fp.close() |
73 |
|
74 def hexfn(node): |
|
75 if node is None: |
|
76 return None |
|
77 else: |
|
78 return hex(node) |
|
79 |
73 |
80 def wrapui(ui): |
74 def wrapui(ui): |
81 class blackboxui(ui.__class__): |
75 class blackboxui(ui.__class__): |
82 def __init__(self, src=None): |
76 def __init__(self, src=None): |
83 super(blackboxui, self).__init__(src) |
77 super(blackboxui, self).__init__(src) |
171 formattedmsg = msg[0] % msg[1:] |
165 formattedmsg = msg[0] % msg[1:] |
172 rev = '(unknown)' |
166 rev = '(unknown)' |
173 changed = '' |
167 changed = '' |
174 if ui._bbrepo: |
168 if ui._bbrepo: |
175 ctx = ui._bbrepo[None] |
169 ctx = ui._bbrepo[None] |
176 if ctx.rev() is not None: |
170 parents = ctx.parents() |
177 rev = hexfn(ctx.node()) |
171 rev = ('+'.join([hex(p.node()) for p in parents])) |
178 else: |
172 if (ui.configbool('blackbox', 'dirty', False) and ( |
179 parents = ctx.parents() |
173 any(ui._bbrepo.status()) or |
180 rev = ('+'.join([hexfn(p.node()) for p in parents])) |
174 any(ctx.sub(s).dirty() for s in ctx.substate) |
181 if (ui.configbool('blackbox', 'dirty', False) and ( |
175 )): |
182 any(ui._bbrepo.status()) or |
176 changed = '+' |
183 any(ctx.sub(s).dirty() for s in ctx.substate) |
|
184 )): |
|
185 changed = '+' |
|
186 try: |
177 try: |
187 ui._bbwrite('%s %s @%s%s (%s)> %s', |
178 ui._bbwrite('%s %s @%s%s (%s)> %s', |
188 date, user, rev, changed, pid, formattedmsg) |
179 date, user, rev, changed, pid, formattedmsg) |
189 except IOError as err: |
180 except IOError as err: |
190 self.debug('warning: cannot write to blackbox.log: %s\n' % |
181 self.debug('warning: cannot write to blackbox.log: %s\n' % |