##// END OF EJS Templates
blackbox: rename fp variable
timeless -
r28244:c17d7b1c default
parent child Browse files
Show More
@@ -47,7 +47,7 b' command = cmdutil.command(cmdtable)'
47 # be specifying the version(s) of Mercurial they are tested with, or
47 # be specifying the version(s) of Mercurial they are tested with, or
48 # leave the attribute unspecified.
48 # leave the attribute unspecified.
49 testedwith = 'internal'
49 testedwith = 'internal'
50 lastblackbox = None
50 lastfp = None
51
51
52 filehandles = {}
52 filehandles = {}
53
53
@@ -103,42 +103,42 b' def wrapui(ui):'
103 return fp
103 return fp
104
104
105 def log(self, event, *msg, **opts):
105 def log(self, event, *msg, **opts):
106 global lastblackbox
106 global lastfp
107 super(blackboxui, self).log(event, *msg, **opts)
107 super(blackboxui, self).log(event, *msg, **opts)
108
108
109 if not '*' in self.track and not event in self.track:
109 if not '*' in self.track and not event in self.track:
110 return
110 return
111
111
112 if util.safehasattr(self, '_blackbox'):
112 if util.safehasattr(self, '_blackbox'):
113 blackbox = self._blackbox
113 fp = self._blackbox
114 elif util.safehasattr(self, '_bbvfs'):
114 elif util.safehasattr(self, '_bbvfs'):
115 try:
115 try:
116 self._blackbox = self._openlogfile()
116 self._bbfp = self._openlogfile()
117 except (IOError, OSError) as err:
117 except (IOError, OSError) as err:
118 self.debug('warning: cannot write to blackbox.log: %s\n' %
118 self.debug('warning: cannot write to blackbox.log: %s\n' %
119 err.strerror)
119 err.strerror)
120 del self._bbvfs
120 del self._bbvfs
121 self._blackbox = None
121 self._bbfp = None
122 blackbox = self._blackbox
122 fp = self._bbfp
123 else:
123 else:
124 # certain ui instances exist outside the context of
124 # certain ui instances exist outside the context of
125 # a repo, so just default to the last blackbox that
125 # a repo, so just default to the last blackbox that
126 # was seen.
126 # was seen.
127 blackbox = lastblackbox
127 fp = lastfp
128
128
129 if blackbox:
129 if fp:
130 date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
130 date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
131 user = util.getuser()
131 user = util.getuser()
132 pid = str(util.getpid())
132 pid = str(util.getpid())
133 formattedmsg = msg[0] % msg[1:]
133 formattedmsg = msg[0] % msg[1:]
134 try:
134 try:
135 blackbox.write('%s %s (%s)> %s' %
135 fp.write('%s %s (%s)> %s' %
136 (date, user, pid, formattedmsg))
136 (date, user, pid, formattedmsg))
137 blackbox.flush()
137 fp.flush()
138 except IOError as err:
138 except IOError as err:
139 self.debug('warning: cannot write to blackbox.log: %s\n' %
139 self.debug('warning: cannot write to blackbox.log: %s\n' %
140 err.strerror)
140 err.strerror)
141 lastblackbox = blackbox
141 lastfp = fp
142
142
143 def setrepo(self, repo):
143 def setrepo(self, repo):
144 self._bbvfs = repo.vfs
144 self._bbvfs = repo.vfs
@@ -170,8 +170,8 b' def blackbox(ui, repo, *revs, **opts):'
170 return
170 return
171
171
172 limit = opts.get('limit')
172 limit = opts.get('limit')
173 blackbox = repo.vfs('blackbox.log', 'r')
173 fp = repo.vfs('blackbox.log', 'r')
174 lines = blackbox.read().split('\n')
174 lines = fp.read().split('\n')
175
175
176 count = 0
176 count = 0
177 output = []
177 output = []
General Comments 0
You need to be logged in to leave comments. Login now