Show More
@@ -51,23 +51,23 b' def wrapui(ui):' | |||||
51 | def _openlogfile(self): |
|
51 | def _openlogfile(self): | |
52 | def rotate(oldpath, newpath): |
|
52 | def rotate(oldpath, newpath): | |
53 | try: |
|
53 | try: | |
54 |
|
|
54 | self._bbvfs.unlink(newpath) | |
55 | except OSError as err: |
|
55 | except OSError as err: | |
56 | if err.errno != errno.ENOENT: |
|
56 | if err.errno != errno.ENOENT: | |
57 | self.debug("warning: cannot remove '%s': %s\n" % |
|
57 | self.debug("warning: cannot remove '%s': %s\n" % | |
58 | (newpath, err.strerror)) |
|
58 | (newpath, err.strerror)) | |
59 | try: |
|
59 | try: | |
60 | if newpath: |
|
60 | if newpath: | |
61 |
|
|
61 | self._bbvfs.rename(oldpath, newpath) | |
62 | except OSError as err: |
|
62 | except OSError as err: | |
63 | if err.errno != errno.ENOENT: |
|
63 | if err.errno != errno.ENOENT: | |
64 | self.debug("warning: cannot rename '%s' to '%s': %s\n" % |
|
64 | self.debug("warning: cannot rename '%s' to '%s': %s\n" % | |
65 | (newpath, oldpath, err.strerror)) |
|
65 | (newpath, oldpath, err.strerror)) | |
66 |
|
66 | |||
67 |
fp = self._bb |
|
67 | fp = self._bbvfs('blackbox.log', 'a') | |
68 | maxsize = self.configbytes('blackbox', 'maxsize', 1048576) |
|
68 | maxsize = self.configbytes('blackbox', 'maxsize', 1048576) | |
69 | if maxsize > 0: |
|
69 | if maxsize > 0: | |
70 |
st = |
|
70 | st = self._bbvfs.fstat(fp) | |
71 | if st.st_size >= maxsize: |
|
71 | if st.st_size >= maxsize: | |
72 | path = fp.name |
|
72 | path = fp.name | |
73 | fp.close() |
|
73 | fp.close() | |
@@ -77,7 +77,7 b' def wrapui(ui):' | |||||
77 | newpath='%s.%d' % (path, i)) |
|
77 | newpath='%s.%d' % (path, i)) | |
78 | rotate(oldpath=path, |
|
78 | rotate(oldpath=path, | |
79 | newpath=maxfiles > 0 and path + '.1') |
|
79 | newpath=maxfiles > 0 and path + '.1') | |
80 |
fp = self._bb |
|
80 | fp = self._bbvfs('blackbox.log', 'a') | |
81 | return fp |
|
81 | return fp | |
82 |
|
82 | |||
83 | def log(self, event, *msg, **opts): |
|
83 | def log(self, event, *msg, **opts): | |
@@ -89,13 +89,13 b' def wrapui(ui):' | |||||
89 |
|
89 | |||
90 | if util.safehasattr(self, '_blackbox'): |
|
90 | if util.safehasattr(self, '_blackbox'): | |
91 | blackbox = self._blackbox |
|
91 | blackbox = self._blackbox | |
92 |
elif util.safehasattr(self, '_bb |
|
92 | elif util.safehasattr(self, '_bbvfs'): | |
93 | try: |
|
93 | try: | |
94 | self._blackbox = self._openlogfile() |
|
94 | self._blackbox = self._openlogfile() | |
95 | except (IOError, OSError) as err: |
|
95 | except (IOError, OSError) as err: | |
96 | self.debug('warning: cannot write to blackbox.log: %s\n' % |
|
96 | self.debug('warning: cannot write to blackbox.log: %s\n' % | |
97 | err.strerror) |
|
97 | err.strerror) | |
98 |
del self._bb |
|
98 | del self._bbvfs | |
99 | self._blackbox = None |
|
99 | self._blackbox = None | |
100 | blackbox = self._blackbox |
|
100 | blackbox = self._blackbox | |
101 | else: |
|
101 | else: | |
@@ -119,7 +119,7 b' def wrapui(ui):' | |||||
119 | lastblackbox = blackbox |
|
119 | lastblackbox = blackbox | |
120 |
|
120 | |||
121 | def setrepo(self, repo): |
|
121 | def setrepo(self, repo): | |
122 |
self._bb |
|
122 | self._bbvfs = repo.vfs | |
123 |
|
123 | |||
124 | ui.__class__ = blackboxui |
|
124 | ui.__class__ = blackboxui | |
125 |
|
125 | |||
@@ -144,7 +144,7 b' def blackbox(ui, repo, *revs, **opts):' | |||||
144 | '''view the recent repository events |
|
144 | '''view the recent repository events | |
145 | ''' |
|
145 | ''' | |
146 |
|
146 | |||
147 |
if not o |
|
147 | if not repo.vfs.exists('blackbox.log'): | |
148 | return |
|
148 | return | |
149 |
|
149 | |||
150 | limit = opts.get('limit') |
|
150 | limit = opts.get('limit') |
General Comments 0
You need to be logged in to leave comments.
Login now