Mercurial > hg
comparison hgext/blackbox.py @ 40646:179c02baaa8c
blackbox: initialize repo attribute properly
And ditch the "bb" prefix as it's no longer a ui extension class.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 11 Nov 2018 17:24:28 +0900 |
parents | fff3e213ace9 |
children | 6d9a87fb8c89 |
comparison
equal
deleted
inserted
replaced
40645:fff3e213ace9 | 40646:179c02baaa8c |
---|---|
127 newpath=maxfiles > 0 and path + '.1') | 127 newpath=maxfiles > 0 and path + '.1') |
128 return vfs(name, 'a') | 128 return vfs(name, 'a') |
129 | 129 |
130 class blackboxlogger(object): | 130 class blackboxlogger(object): |
131 def __init__(self, ui): | 131 def __init__(self, ui): |
132 self._repo = None | |
132 self.track = ui.configlist('blackbox', 'track') | 133 self.track = ui.configlist('blackbox', 'track') |
133 | 134 |
134 @property | 135 @property |
135 def _bbvfs(self): | 136 def _bbvfs(self): |
136 vfs = None | 137 vfs = None |
137 repo = getattr(self, '_bbrepo', None) | 138 if self._repo: |
138 if repo: | 139 vfs = self._repo.vfs |
139 vfs = repo.vfs | |
140 if not vfs.isdir('.'): | 140 if not vfs.isdir('.'): |
141 vfs = None | 141 vfs = None |
142 return vfs | 142 return vfs |
143 | 143 |
144 def log(self, ui, event, msg, opts): | 144 def log(self, ui, event, msg, opts): |
167 user = procutil.getuser() | 167 user = procutil.getuser() |
168 pid = '%d' % procutil.getpid() | 168 pid = '%d' % procutil.getpid() |
169 formattedmsg = msg[0] % msg[1:] | 169 formattedmsg = msg[0] % msg[1:] |
170 rev = '(unknown)' | 170 rev = '(unknown)' |
171 changed = '' | 171 changed = '' |
172 ctx = self._bbrepo[None] | 172 ctx = self._repo[None] |
173 parents = ctx.parents() | 173 parents = ctx.parents() |
174 rev = ('+'.join([hex(p.node()) for p in parents])) | 174 rev = ('+'.join([hex(p.node()) for p in parents])) |
175 if (ui.configbool('blackbox', 'dirty') and | 175 if (ui.configbool('blackbox', 'dirty') and |
176 ctx.dirty(missing=True, merge=False, branch=False)): | 176 ctx.dirty(missing=True, merge=False, branch=False)): |
177 changed = '+' | 177 changed = '+' |
191 # logging again | 191 # logging again |
192 else: | 192 else: |
193 self._bbinlog = False | 193 self._bbinlog = False |
194 | 194 |
195 def setrepo(self, repo): | 195 def setrepo(self, repo): |
196 self._bbrepo = repo | 196 self._repo = repo |
197 | 197 |
198 def wrapui(ui): | 198 def wrapui(ui): |
199 class blackboxui(ui.__class__): | 199 class blackboxui(ui.__class__): |
200 def __init__(self, src=None): | 200 def __init__(self, src=None): |
201 super(blackboxui, self).__init__(src) | 201 super(blackboxui, self).__init__(src) |