Mercurial > hg
comparison hgext/blackbox.py @ 40633:4a38a67d0e96
blackbox: inline temporary variables which are referenced only once
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 11 Nov 2018 16:44:30 +0900 |
parents | da3bc2f54b02 |
children | c9876c00d292 |
comparison
equal
deleted
inserted
replaced
40632:da3bc2f54b02 | 40633:4a38a67d0e96 |
---|---|
163 # was seen. | 163 # was seen. |
164 ui = lastui | 164 ui = lastui |
165 else: | 165 else: |
166 return | 166 return |
167 | 167 |
168 vfs = ui._bbvfs | |
169 repo = ui._bbrepo | |
170 | |
171 if getattr(ui, '_bbinlog', False): | 168 if getattr(ui, '_bbinlog', False): |
172 # recursion and failure guard | 169 # recursion and failure guard |
173 return | 170 return |
174 ui._bbinlog = True | 171 ui._bbinlog = True |
175 default = self.configdate('devel', 'default-date') | 172 default = self.configdate('devel', 'default-date') |
178 user = procutil.getuser() | 175 user = procutil.getuser() |
179 pid = '%d' % procutil.getpid() | 176 pid = '%d' % procutil.getpid() |
180 formattedmsg = msg[0] % msg[1:] | 177 formattedmsg = msg[0] % msg[1:] |
181 rev = '(unknown)' | 178 rev = '(unknown)' |
182 changed = '' | 179 changed = '' |
183 ctx = repo[None] | 180 ctx = ui._bbrepo[None] |
184 parents = ctx.parents() | 181 parents = ctx.parents() |
185 rev = ('+'.join([hex(p.node()) for p in parents])) | 182 rev = ('+'.join([hex(p.node()) for p in parents])) |
186 if (ui.configbool('blackbox', 'dirty') and | 183 if (ui.configbool('blackbox', 'dirty') and |
187 ctx.dirty(missing=True, merge=False, branch=False)): | 184 ctx.dirty(missing=True, merge=False, branch=False)): |
188 changed = '+' | 185 changed = '+' |
191 else: | 188 else: |
192 src = '' | 189 src = '' |
193 try: | 190 try: |
194 fmt = '%s %s @%s%s (%s)%s> %s' | 191 fmt = '%s %s @%s%s (%s)%s> %s' |
195 args = (date, user, rev, changed, pid, src, formattedmsg) | 192 args = (date, user, rev, changed, pid, src, formattedmsg) |
196 with _openlogfile(ui, vfs) as fp: | 193 with _openlogfile(ui, ui._bbvfs) as fp: |
197 fp.write(fmt % args) | 194 fp.write(fmt % args) |
198 except (IOError, OSError) as err: | 195 except (IOError, OSError) as err: |
199 self.debug('warning: cannot write to blackbox.log: %s\n' % | 196 self.debug('warning: cannot write to blackbox.log: %s\n' % |
200 encoding.strtolocal(err.strerror)) | 197 encoding.strtolocal(err.strerror)) |
201 # do not restore _bbinlog intentionally to avoid failed | 198 # do not restore _bbinlog intentionally to avoid failed |