##// END OF EJS Templates
blackbox: add configitem for format of log timestamps...
Matt DeVore -
r40466:25f1c7bd default
parent child Browse files
Show More
@@ -1,257 +1,266 b''
1 # blackbox.py - log repository events to a file for post-mortem debugging
1 # blackbox.py - log repository events to a file for post-mortem debugging
2 #
2 #
3 # Copyright 2010 Nicolas Dumazet
3 # Copyright 2010 Nicolas Dumazet
4 # Copyright 2013 Facebook, Inc.
4 # Copyright 2013 Facebook, Inc.
5 #
5 #
6 # This software may be used and distributed according to the terms of the
6 # This software may be used and distributed according to the terms of the
7 # GNU General Public License version 2 or any later version.
7 # GNU General Public License version 2 or any later version.
8
8
9 """log repository events to a blackbox for debugging
9 """log repository events to a blackbox for debugging
10
10
11 Logs event information to .hg/blackbox.log to help debug and diagnose problems.
11 Logs event information to .hg/blackbox.log to help debug and diagnose problems.
12 The events that get logged can be configured via the blackbox.track config key.
12 The events that get logged can be configured via the blackbox.track config key.
13
13
14 Examples::
14 Examples::
15
15
16 [blackbox]
16 [blackbox]
17 track = *
17 track = *
18 # dirty is *EXPENSIVE* (slow);
18 # dirty is *EXPENSIVE* (slow);
19 # each log entry indicates `+` if the repository is dirty, like :hg:`id`.
19 # each log entry indicates `+` if the repository is dirty, like :hg:`id`.
20 dirty = True
20 dirty = True
21 # record the source of log messages
21 # record the source of log messages
22 logsource = True
22 logsource = True
23
23
24 [blackbox]
24 [blackbox]
25 track = command, commandfinish, commandexception, exthook, pythonhook
25 track = command, commandfinish, commandexception, exthook, pythonhook
26
26
27 [blackbox]
27 [blackbox]
28 track = incoming
28 track = incoming
29
29
30 [blackbox]
30 [blackbox]
31 # limit the size of a log file
31 # limit the size of a log file
32 maxsize = 1.5 MB
32 maxsize = 1.5 MB
33 # rotate up to N log files when the current one gets too big
33 # rotate up to N log files when the current one gets too big
34 maxfiles = 3
34 maxfiles = 3
35
35
36 [blackbox]
37 # Include nanoseconds in log entries with %f (see Python function
38 # datetime.datetime.strftime)
39 date-format = '%Y-%m-%d @ %H:%M:%S.%f'
40
36 """
41 """
37
42
38 from __future__ import absolute_import
43 from __future__ import absolute_import
39
44
40 import errno
45 import errno
41 import re
46 import re
42
47
43 from mercurial.i18n import _
48 from mercurial.i18n import _
44 from mercurial.node import hex
49 from mercurial.node import hex
45
50
46 from mercurial import (
51 from mercurial import (
47 encoding,
52 encoding,
48 pycompat,
53 pycompat,
49 registrar,
54 registrar,
50 ui as uimod,
55 ui as uimod,
51 util,
56 util,
52 )
57 )
53 from mercurial.utils import (
58 from mercurial.utils import (
54 dateutil,
59 dateutil,
55 procutil,
60 procutil,
56 )
61 )
57
62
58 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
63 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
59 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
64 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
60 # be specifying the version(s) of Mercurial they are tested with, or
65 # be specifying the version(s) of Mercurial they are tested with, or
61 # leave the attribute unspecified.
66 # leave the attribute unspecified.
62 testedwith = 'ships-with-hg-core'
67 testedwith = 'ships-with-hg-core'
63
68
64 cmdtable = {}
69 cmdtable = {}
65 command = registrar.command(cmdtable)
70 command = registrar.command(cmdtable)
66
71
67 configtable = {}
72 configtable = {}
68 configitem = registrar.configitem(configtable)
73 configitem = registrar.configitem(configtable)
69
74
70 configitem('blackbox', 'dirty',
75 configitem('blackbox', 'dirty',
71 default=False,
76 default=False,
72 )
77 )
73 configitem('blackbox', 'maxsize',
78 configitem('blackbox', 'maxsize',
74 default='1 MB',
79 default='1 MB',
75 )
80 )
76 configitem('blackbox', 'logsource',
81 configitem('blackbox', 'logsource',
77 default=False,
82 default=False,
78 )
83 )
79 configitem('blackbox', 'maxfiles',
84 configitem('blackbox', 'maxfiles',
80 default=7,
85 default=7,
81 )
86 )
82 configitem('blackbox', 'track',
87 configitem('blackbox', 'track',
83 default=lambda: ['*'],
88 default=lambda: ['*'],
84 )
89 )
90 configitem('blackbox', 'date-format',
91 default='%Y/%m/%d %H:%M:%S',
92 )
85
93
86 lastui = None
94 lastui = None
87
95
88 def _openlogfile(ui, vfs):
96 def _openlogfile(ui, vfs):
89 def rotate(oldpath, newpath):
97 def rotate(oldpath, newpath):
90 try:
98 try:
91 vfs.unlink(newpath)
99 vfs.unlink(newpath)
92 except OSError as err:
100 except OSError as err:
93 if err.errno != errno.ENOENT:
101 if err.errno != errno.ENOENT:
94 ui.debug("warning: cannot remove '%s': %s\n" %
102 ui.debug("warning: cannot remove '%s': %s\n" %
95 (newpath, err.strerror))
103 (newpath, err.strerror))
96 try:
104 try:
97 if newpath:
105 if newpath:
98 vfs.rename(oldpath, newpath)
106 vfs.rename(oldpath, newpath)
99 except OSError as err:
107 except OSError as err:
100 if err.errno != errno.ENOENT:
108 if err.errno != errno.ENOENT:
101 ui.debug("warning: cannot rename '%s' to '%s': %s\n" %
109 ui.debug("warning: cannot rename '%s' to '%s': %s\n" %
102 (newpath, oldpath, err.strerror))
110 (newpath, oldpath, err.strerror))
103
111
104 maxsize = ui.configbytes('blackbox', 'maxsize')
112 maxsize = ui.configbytes('blackbox', 'maxsize')
105 name = 'blackbox.log'
113 name = 'blackbox.log'
106 if maxsize > 0:
114 if maxsize > 0:
107 try:
115 try:
108 st = vfs.stat(name)
116 st = vfs.stat(name)
109 except OSError:
117 except OSError:
110 pass
118 pass
111 else:
119 else:
112 if st.st_size >= maxsize:
120 if st.st_size >= maxsize:
113 path = vfs.join(name)
121 path = vfs.join(name)
114 maxfiles = ui.configint('blackbox', 'maxfiles')
122 maxfiles = ui.configint('blackbox', 'maxfiles')
115 for i in pycompat.xrange(maxfiles - 1, 1, -1):
123 for i in pycompat.xrange(maxfiles - 1, 1, -1):
116 rotate(oldpath='%s.%d' % (path, i - 1),
124 rotate(oldpath='%s.%d' % (path, i - 1),
117 newpath='%s.%d' % (path, i))
125 newpath='%s.%d' % (path, i))
118 rotate(oldpath=path,
126 rotate(oldpath=path,
119 newpath=maxfiles > 0 and path + '.1')
127 newpath=maxfiles > 0 and path + '.1')
120 return vfs(name, 'a')
128 return vfs(name, 'a')
121
129
122 def wrapui(ui):
130 def wrapui(ui):
123 class blackboxui(ui.__class__):
131 class blackboxui(ui.__class__):
124 @property
132 @property
125 def _bbvfs(self):
133 def _bbvfs(self):
126 vfs = None
134 vfs = None
127 repo = getattr(self, '_bbrepo', None)
135 repo = getattr(self, '_bbrepo', None)
128 if repo:
136 if repo:
129 vfs = repo.vfs
137 vfs = repo.vfs
130 if not vfs.isdir('.'):
138 if not vfs.isdir('.'):
131 vfs = None
139 vfs = None
132 return vfs
140 return vfs
133
141
134 @util.propertycache
142 @util.propertycache
135 def track(self):
143 def track(self):
136 return self.configlist('blackbox', 'track')
144 return self.configlist('blackbox', 'track')
137
145
138 def debug(self, *msg, **opts):
146 def debug(self, *msg, **opts):
139 super(blackboxui, self).debug(*msg, **opts)
147 super(blackboxui, self).debug(*msg, **opts)
140 if self.debugflag:
148 if self.debugflag:
141 self.log('debug', '%s', ''.join(msg))
149 self.log('debug', '%s', ''.join(msg))
142
150
143 def log(self, event, *msg, **opts):
151 def log(self, event, *msg, **opts):
144 global lastui
152 global lastui
145 super(blackboxui, self).log(event, *msg, **opts)
153 super(blackboxui, self).log(event, *msg, **opts)
146
154
147 if not '*' in self.track and not event in self.track:
155 if not '*' in self.track and not event in self.track:
148 return
156 return
149
157
150 if self._bbvfs:
158 if self._bbvfs:
151 ui = self
159 ui = self
152 else:
160 else:
153 # certain ui instances exist outside the context of
161 # certain ui instances exist outside the context of
154 # a repo, so just default to the last blackbox that
162 # a repo, so just default to the last blackbox that
155 # was seen.
163 # was seen.
156 ui = lastui
164 ui = lastui
157
165
158 if not ui:
166 if not ui:
159 return
167 return
160 vfs = ui._bbvfs
168 vfs = ui._bbvfs
161 if not vfs:
169 if not vfs:
162 return
170 return
163
171
164 repo = getattr(ui, '_bbrepo', None)
172 repo = getattr(ui, '_bbrepo', None)
165 if not lastui or repo:
173 if not lastui or repo:
166 lastui = ui
174 lastui = ui
167 if getattr(ui, '_bbinlog', False):
175 if getattr(ui, '_bbinlog', False):
168 # recursion and failure guard
176 # recursion and failure guard
169 return
177 return
170 ui._bbinlog = True
178 ui._bbinlog = True
171 default = self.configdate('devel', 'default-date')
179 default = self.configdate('devel', 'default-date')
172 date = dateutil.datestr(default, '%Y/%m/%d %H:%M:%S')
180 date = dateutil.datestr(default,
181 ui.config('blackbox', 'date-format'))
173 user = procutil.getuser()
182 user = procutil.getuser()
174 pid = '%d' % procutil.getpid()
183 pid = '%d' % procutil.getpid()
175 formattedmsg = msg[0] % msg[1:]
184 formattedmsg = msg[0] % msg[1:]
176 rev = '(unknown)'
185 rev = '(unknown)'
177 changed = ''
186 changed = ''
178 if repo:
187 if repo:
179 ctx = repo[None]
188 ctx = repo[None]
180 parents = ctx.parents()
189 parents = ctx.parents()
181 rev = ('+'.join([hex(p.node()) for p in parents]))
190 rev = ('+'.join([hex(p.node()) for p in parents]))
182 if (ui.configbool('blackbox', 'dirty') and
191 if (ui.configbool('blackbox', 'dirty') and
183 ctx.dirty(missing=True, merge=False, branch=False)):
192 ctx.dirty(missing=True, merge=False, branch=False)):
184 changed = '+'
193 changed = '+'
185 if ui.configbool('blackbox', 'logsource'):
194 if ui.configbool('blackbox', 'logsource'):
186 src = ' [%s]' % event
195 src = ' [%s]' % event
187 else:
196 else:
188 src = ''
197 src = ''
189 try:
198 try:
190 fmt = '%s %s @%s%s (%s)%s> %s'
199 fmt = '%s %s @%s%s (%s)%s> %s'
191 args = (date, user, rev, changed, pid, src, formattedmsg)
200 args = (date, user, rev, changed, pid, src, formattedmsg)
192 with _openlogfile(ui, vfs) as fp:
201 with _openlogfile(ui, vfs) as fp:
193 fp.write(fmt % args)
202 fp.write(fmt % args)
194 except (IOError, OSError) as err:
203 except (IOError, OSError) as err:
195 self.debug('warning: cannot write to blackbox.log: %s\n' %
204 self.debug('warning: cannot write to blackbox.log: %s\n' %
196 encoding.strtolocal(err.strerror))
205 encoding.strtolocal(err.strerror))
197 # do not restore _bbinlog intentionally to avoid failed
206 # do not restore _bbinlog intentionally to avoid failed
198 # logging again
207 # logging again
199 else:
208 else:
200 ui._bbinlog = False
209 ui._bbinlog = False
201
210
202 def setrepo(self, repo):
211 def setrepo(self, repo):
203 self._bbrepo = repo
212 self._bbrepo = repo
204
213
205 ui.__class__ = blackboxui
214 ui.__class__ = blackboxui
206 uimod.ui = blackboxui
215 uimod.ui = blackboxui
207
216
208 def uisetup(ui):
217 def uisetup(ui):
209 wrapui(ui)
218 wrapui(ui)
210
219
211 def reposetup(ui, repo):
220 def reposetup(ui, repo):
212 # During 'hg pull' a httppeer repo is created to represent the remote repo.
221 # During 'hg pull' a httppeer repo is created to represent the remote repo.
213 # It doesn't have a .hg directory to put a blackbox in, so we don't do
222 # It doesn't have a .hg directory to put a blackbox in, so we don't do
214 # the blackbox setup for it.
223 # the blackbox setup for it.
215 if not repo.local():
224 if not repo.local():
216 return
225 return
217
226
218 if util.safehasattr(ui, 'setrepo'):
227 if util.safehasattr(ui, 'setrepo'):
219 ui.setrepo(repo)
228 ui.setrepo(repo)
220
229
221 # Set lastui even if ui.log is not called. This gives blackbox a
230 # Set lastui even if ui.log is not called. This gives blackbox a
222 # fallback place to log.
231 # fallback place to log.
223 global lastui
232 global lastui
224 if lastui is None:
233 if lastui is None:
225 lastui = ui
234 lastui = ui
226
235
227 repo._wlockfreeprefix.add('blackbox.log')
236 repo._wlockfreeprefix.add('blackbox.log')
228
237
229 @command('blackbox',
238 @command('blackbox',
230 [('l', 'limit', 10, _('the number of events to show')),
239 [('l', 'limit', 10, _('the number of events to show')),
231 ],
240 ],
232 _('hg blackbox [OPTION]...'),
241 _('hg blackbox [OPTION]...'),
233 helpcategory=command.CATEGORY_MAINTENANCE,
242 helpcategory=command.CATEGORY_MAINTENANCE,
234 helpbasic=True)
243 helpbasic=True)
235 def blackbox(ui, repo, *revs, **opts):
244 def blackbox(ui, repo, *revs, **opts):
236 '''view the recent repository events
245 '''view the recent repository events
237 '''
246 '''
238
247
239 if not repo.vfs.exists('blackbox.log'):
248 if not repo.vfs.exists('blackbox.log'):
240 return
249 return
241
250
242 limit = opts.get(r'limit')
251 limit = opts.get(r'limit')
243 fp = repo.vfs('blackbox.log', 'r')
252 fp = repo.vfs('blackbox.log', 'r')
244 lines = fp.read().split('\n')
253 lines = fp.read().split('\n')
245
254
246 count = 0
255 count = 0
247 output = []
256 output = []
248 for line in reversed(lines):
257 for line in reversed(lines):
249 if count >= limit:
258 if count >= limit:
250 break
259 break
251
260
252 # count the commands by matching lines like: 2013/01/23 19:13:36 root>
261 # count the commands by matching lines like: 2013/01/23 19:13:36 root>
253 if re.match('^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} .*> .*', line):
262 if re.match('^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} .*> .*', line):
254 count += 1
263 count += 1
255 output.append(line)
264 output.append(line)
256
265
257 ui.status('\n'.join(reversed(output)))
266 ui.status('\n'.join(reversed(output)))
@@ -1,418 +1,428 b''
1 setup
1 setup
2
2
3 $ cat > myextension.py <<EOF
3 $ cat > myextension.py <<EOF
4 > from mercurial import error, registrar
4 > from mercurial import error, registrar
5 > cmdtable = {}
5 > cmdtable = {}
6 > command = registrar.command(cmdtable)
6 > command = registrar.command(cmdtable)
7 > @command(b'crash', [], b'hg crash')
7 > @command(b'crash', [], b'hg crash')
8 > def crash(ui, *args, **kwargs):
8 > def crash(ui, *args, **kwargs):
9 > raise Exception("oops")
9 > raise Exception("oops")
10 > @command(b'abort', [], b'hg abort')
10 > @command(b'abort', [], b'hg abort')
11 > def abort(ui, *args, **kwargs):
11 > def abort(ui, *args, **kwargs):
12 > raise error.Abort(b"oops")
12 > raise error.Abort(b"oops")
13 > EOF
13 > EOF
14 $ abspath=`pwd`/myextension.py
14 $ abspath=`pwd`/myextension.py
15
15
16 $ cat >> $HGRCPATH <<EOF
16 $ cat >> $HGRCPATH <<EOF
17 > [extensions]
17 > [extensions]
18 > blackbox=
18 > blackbox=
19 > mock=$TESTDIR/mockblackbox.py
19 > mock=$TESTDIR/mockblackbox.py
20 > mq=
20 > mq=
21 > myextension=$TESTTMP/myextension.py
21 > myextension=$TESTTMP/myextension.py
22 > [alias]
22 > [alias]
23 > confuse = log --limit 3
23 > confuse = log --limit 3
24 > so-confusing = confuse --style compact
24 > so-confusing = confuse --style compact
25 > EOF
25 > EOF
26
26
27 $ hg init blackboxtest
27 $ hg init blackboxtest
28 $ cd blackboxtest
28 $ cd blackboxtest
29
29
30 command, exit codes, and duration
30 command, exit codes, and duration
31
31
32 $ echo a > a
32 $ echo a > a
33 $ hg add a
33 $ hg add a
34 $ hg blackbox --config blackbox.dirty=True
34 $ hg blackbox --config blackbox.dirty=True
35 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> init blackboxtest exited 0 after * seconds (glob)
35 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> init blackboxtest exited 0 after * seconds (glob)
36 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a
36 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a
37 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob)
37 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob)
38 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox --config *blackbox.dirty=True* (glob)
38 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox --config *blackbox.dirty=True* (glob)
39
39
40 failure exit code
40 failure exit code
41 $ rm ./.hg/blackbox.log
41 $ rm ./.hg/blackbox.log
42 $ hg add non-existent
42 $ hg add non-existent
43 non-existent: $ENOENT$
43 non-existent: $ENOENT$
44 [1]
44 [1]
45 $ hg blackbox
45 $ hg blackbox
46 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add non-existent
46 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add non-existent
47 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add non-existent exited 1 after * seconds (glob)
47 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add non-existent exited 1 after * seconds (glob)
48 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
48 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
49
49
50 abort exit code
50 abort exit code
51 $ rm ./.hg/blackbox.log
51 $ rm ./.hg/blackbox.log
52 $ hg abort 2> /dev/null
52 $ hg abort 2> /dev/null
53 [255]
53 [255]
54 $ hg blackbox -l 2
54 $ hg blackbox -l 2
55 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> abort exited 255 after * seconds (glob)
55 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> abort exited 255 after * seconds (glob)
56 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox -l 2
56 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox -l 2
57
57
58 unhandled exception
58 unhandled exception
59 $ rm ./.hg/blackbox.log
59 $ rm ./.hg/blackbox.log
60 $ hg crash 2> /dev/null
60 $ hg crash 2> /dev/null
61 [1]
61 [1]
62 $ hg blackbox -l 2
62 $ hg blackbox -l 2
63 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> crash exited 1 after * seconds (glob)
63 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> crash exited 1 after * seconds (glob)
64 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox -l 2
64 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox -l 2
65
65
66 alias expansion is logged
66 alias expansion is logged
67 $ rm ./.hg/blackbox.log
67 $ rm ./.hg/blackbox.log
68 $ hg confuse
68 $ hg confuse
69 $ hg blackbox
69 $ hg blackbox
70 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse
70 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse
71 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3'
71 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3'
72 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse exited 0 after * seconds (glob)
72 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse exited 0 after * seconds (glob)
73 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
73 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
74
74
75 recursive aliases work correctly
75 recursive aliases work correctly
76 $ rm ./.hg/blackbox.log
76 $ rm ./.hg/blackbox.log
77 $ hg so-confusing
77 $ hg so-confusing
78 $ hg blackbox
78 $ hg blackbox
79 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> so-confusing
79 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> so-confusing
80 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'so-confusing' expands to 'confuse --style compact'
80 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'so-confusing' expands to 'confuse --style compact'
81 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3'
81 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3'
82 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> so-confusing exited 0 after * seconds (glob)
82 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> so-confusing exited 0 after * seconds (glob)
83 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
83 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
84
84
85 custom date format
86 $ rm ./.hg/blackbox.log
87 $ hg --config blackbox.date-format='%Y-%m-%d @ %H:%M:%S' \
88 > --config devel.default-date='1334347993 0' --traceback status
89 A a
90 $ hg blackbox
91 2012-04-13 @ 20:13:13 bob @0000000000000000000000000000000000000000 (5000)> --config 'blackbox.date-format=%Y-%m-%d @ %H:%M:%S' --config 'devel.default-date=1334347993 0' --traceback status
92 2012-04-13 @ 20:13:13 bob @0000000000000000000000000000000000000000 (5000)> --config 'blackbox.date-format=%Y-%m-%d @ %H:%M:%S' --config 'devel.default-date=1334347993 0' --traceback status exited 0 after * seconds (glob)
93 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
94
85 incoming change tracking
95 incoming change tracking
86
96
87 create two heads to verify that we only see one change in the log later
97 create two heads to verify that we only see one change in the log later
88 $ hg commit -ma
98 $ hg commit -ma
89 $ hg up null
99 $ hg up null
90 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
100 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
91 $ echo b > b
101 $ echo b > b
92 $ hg commit -Amb
102 $ hg commit -Amb
93 adding b
103 adding b
94 created new head
104 created new head
95
105
96 clone, commit, pull
106 clone, commit, pull
97 $ hg clone . ../blackboxtest2
107 $ hg clone . ../blackboxtest2
98 updating to branch default
108 updating to branch default
99 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
109 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
100 $ echo c > c
110 $ echo c > c
101 $ hg commit -Amc
111 $ hg commit -Amc
102 adding c
112 adding c
103 $ cd ../blackboxtest2
113 $ cd ../blackboxtest2
104 $ hg pull
114 $ hg pull
105 pulling from $TESTTMP/blackboxtest
115 pulling from $TESTTMP/blackboxtest
106 searching for changes
116 searching for changes
107 adding changesets
117 adding changesets
108 adding manifests
118 adding manifests
109 adding file changes
119 adding file changes
110 added 1 changesets with 1 changes to 1 files
120 added 1 changesets with 1 changes to 1 files
111 new changesets d02f48003e62
121 new changesets d02f48003e62
112 (run 'hg update' to get a working copy)
122 (run 'hg update' to get a working copy)
113 $ hg blackbox -l 6
123 $ hg blackbox -l 6
114 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull
124 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull
115 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated served branch cache in * seconds (glob)
125 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated served branch cache in * seconds (glob)
116 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote served branch cache with 1 labels and 2 nodes
126 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote served branch cache with 1 labels and 2 nodes
117 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> 1 incoming changes - new heads: d02f48003e62
127 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> 1 incoming changes - new heads: d02f48003e62
118 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull exited 0 after * seconds (glob)
128 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull exited 0 after * seconds (glob)
119 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
129 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
120
130
121 we must not cause a failure if we cannot write to the log
131 we must not cause a failure if we cannot write to the log
122
132
123 $ hg rollback
133 $ hg rollback
124 repository tip rolled back to revision 1 (undo pull)
134 repository tip rolled back to revision 1 (undo pull)
125
135
126 $ mv .hg/blackbox.log .hg/blackbox.log-
136 $ mv .hg/blackbox.log .hg/blackbox.log-
127 $ mkdir .hg/blackbox.log
137 $ mkdir .hg/blackbox.log
128 $ hg --debug incoming
138 $ hg --debug incoming
129 warning: cannot write to blackbox.log: * (glob)
139 warning: cannot write to blackbox.log: * (glob)
130 comparing with $TESTTMP/blackboxtest
140 comparing with $TESTTMP/blackboxtest
131 query 1; heads
141 query 1; heads
132 searching for changes
142 searching for changes
133 all local heads known remotely
143 all local heads known remotely
134 changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51
144 changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51
135 tag: tip
145 tag: tip
136 phase: draft
146 phase: draft
137 parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06
147 parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06
138 parent: -1:0000000000000000000000000000000000000000
148 parent: -1:0000000000000000000000000000000000000000
139 manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892
149 manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892
140 user: test
150 user: test
141 date: Thu Jan 01 00:00:00 1970 +0000
151 date: Thu Jan 01 00:00:00 1970 +0000
142 files+: c
152 files+: c
143 extra: branch=default
153 extra: branch=default
144 description:
154 description:
145 c
155 c
146
156
147
157
148 $ hg pull
158 $ hg pull
149 pulling from $TESTTMP/blackboxtest
159 pulling from $TESTTMP/blackboxtest
150 searching for changes
160 searching for changes
151 adding changesets
161 adding changesets
152 adding manifests
162 adding manifests
153 adding file changes
163 adding file changes
154 added 1 changesets with 1 changes to 1 files
164 added 1 changesets with 1 changes to 1 files
155 new changesets d02f48003e62
165 new changesets d02f48003e62
156 (run 'hg update' to get a working copy)
166 (run 'hg update' to get a working copy)
157
167
158 a failure reading from the log is fatal
168 a failure reading from the log is fatal
159
169
160 $ hg blackbox -l 3
170 $ hg blackbox -l 3
161 abort: *$TESTTMP/blackboxtest2/.hg/blackbox.log* (glob)
171 abort: *$TESTTMP/blackboxtest2/.hg/blackbox.log* (glob)
162 [255]
172 [255]
163
173
164 $ rmdir .hg/blackbox.log
174 $ rmdir .hg/blackbox.log
165 $ mv .hg/blackbox.log- .hg/blackbox.log
175 $ mv .hg/blackbox.log- .hg/blackbox.log
166
176
167 backup bundles get logged
177 backup bundles get logged
168
178
169 $ touch d
179 $ touch d
170 $ hg commit -Amd
180 $ hg commit -Amd
171 adding d
181 adding d
172 created new head
182 created new head
173 $ hg strip tip
183 $ hg strip tip
174 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
184 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
175 saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob)
185 saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob)
176 $ hg blackbox -l 6
186 $ hg blackbox -l 6
177 1970/01/01 00:00:00 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip
187 1970/01/01 00:00:00 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip
178 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg
188 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg
179 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated base branch cache in * seconds (glob)
189 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated base branch cache in * seconds (glob)
180 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote base branch cache with 1 labels and 2 nodes
190 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote base branch cache with 1 labels and 2 nodes
181 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> strip tip exited 0 after * seconds (glob)
191 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> strip tip exited 0 after * seconds (glob)
182 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
192 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
183
193
184 extension and python hooks - use the eol extension for a pythonhook
194 extension and python hooks - use the eol extension for a pythonhook
185
195
186 $ echo '[extensions]' >> .hg/hgrc
196 $ echo '[extensions]' >> .hg/hgrc
187 $ echo 'eol=' >> .hg/hgrc
197 $ echo 'eol=' >> .hg/hgrc
188 $ echo '[hooks]' >> .hg/hgrc
198 $ echo '[hooks]' >> .hg/hgrc
189 $ echo 'update = echo hooked' >> .hg/hgrc
199 $ echo 'update = echo hooked' >> .hg/hgrc
190 $ hg update
200 $ hg update
191 The fsmonitor extension is incompatible with the eol extension and has been disabled. (fsmonitor !)
201 The fsmonitor extension is incompatible with the eol extension and has been disabled. (fsmonitor !)
192 hooked
202 hooked
193 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
203 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
194 updated to "d02f48003e62: c"
204 updated to "d02f48003e62: c"
195 1 other heads for branch "default"
205 1 other heads for branch "default"
196 $ cat >> .hg/hgrc <<EOF
206 $ cat >> .hg/hgrc <<EOF
197 > [extensions]
207 > [extensions]
198 > # disable eol, because it is not needed for subsequent tests
208 > # disable eol, because it is not needed for subsequent tests
199 > # (in addition, keeping it requires extra care for fsmonitor)
209 > # (in addition, keeping it requires extra care for fsmonitor)
200 > eol=!
210 > eol=!
201 > EOF
211 > EOF
202 $ hg blackbox -l 5
212 $ hg blackbox -l 5
203 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> update (no-chg !)
213 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> update (no-chg !)
204 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob)
214 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob)
205 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> exthook-update: echo hooked finished in * seconds (glob)
215 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> exthook-update: echo hooked finished in * seconds (glob)
206 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> update exited 0 after * seconds (glob)
216 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> update exited 0 after * seconds (glob)
207 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> serve --cmdserver chgunix --address $TESTTMP.chgsock/server.* --daemon-postexec 'chdir:/' (glob) (chg !)
217 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> serve --cmdserver chgunix --address $TESTTMP.chgsock/server.* --daemon-postexec 'chdir:/' (glob) (chg !)
208 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> blackbox -l 5
218 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> blackbox -l 5
209
219
210 log rotation
220 log rotation
211
221
212 $ echo '[blackbox]' >> .hg/hgrc
222 $ echo '[blackbox]' >> .hg/hgrc
213 $ echo 'maxsize = 20 b' >> .hg/hgrc
223 $ echo 'maxsize = 20 b' >> .hg/hgrc
214 $ echo 'maxfiles = 3' >> .hg/hgrc
224 $ echo 'maxfiles = 3' >> .hg/hgrc
215 $ hg status
225 $ hg status
216 $ hg status
226 $ hg status
217 $ hg status
227 $ hg status
218 $ hg tip -q
228 $ hg tip -q
219 2:d02f48003e62
229 2:d02f48003e62
220 $ ls .hg/blackbox.log*
230 $ ls .hg/blackbox.log*
221 .hg/blackbox.log
231 .hg/blackbox.log
222 .hg/blackbox.log.1
232 .hg/blackbox.log.1
223 .hg/blackbox.log.2
233 .hg/blackbox.log.2
224 $ cd ..
234 $ cd ..
225
235
226 $ hg init blackboxtest3
236 $ hg init blackboxtest3
227 $ cd blackboxtest3
237 $ cd blackboxtest3
228 $ hg blackbox
238 $ hg blackbox
229 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> init blackboxtest3 exited 0 after * seconds (glob)
239 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> init blackboxtest3 exited 0 after * seconds (glob)
230 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
240 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
231 $ mv .hg/blackbox.log .hg/blackbox.log-
241 $ mv .hg/blackbox.log .hg/blackbox.log-
232 $ mkdir .hg/blackbox.log
242 $ mkdir .hg/blackbox.log
233 $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\
243 $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\
234 > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\
244 > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\
235 > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
245 > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
236 $ "$PYTHON" $TESTDIR/blackbox-readonly-dispatch.py
246 $ "$PYTHON" $TESTDIR/blackbox-readonly-dispatch.py
237 running: --debug add foo
247 running: --debug add foo
238 warning: cannot write to blackbox.log: Is a directory (no-windows !)
248 warning: cannot write to blackbox.log: Is a directory (no-windows !)
239 warning: cannot write to blackbox.log: $TESTTMP/blackboxtest3/.hg/blackbox.log: Access is denied (windows !)
249 warning: cannot write to blackbox.log: $TESTTMP/blackboxtest3/.hg/blackbox.log: Access is denied (windows !)
240 adding foo
250 adding foo
241 result: 0
251 result: 0
242 running: --debug commit -m commit1 -d 2000-01-01 foo
252 running: --debug commit -m commit1 -d 2000-01-01 foo
243 warning: cannot write to blackbox.log: Is a directory (no-windows !)
253 warning: cannot write to blackbox.log: Is a directory (no-windows !)
244 warning: cannot write to blackbox.log: $TESTTMP/blackboxtest3/.hg/blackbox.log: Access is denied (windows !)
254 warning: cannot write to blackbox.log: $TESTTMP/blackboxtest3/.hg/blackbox.log: Access is denied (windows !)
245 committing files:
255 committing files:
246 foo
256 foo
247 committing manifest
257 committing manifest
248 committing changelog
258 committing changelog
249 updating the branch cache
259 updating the branch cache
250 committed changeset 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
260 committed changeset 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
251 result: 0
261 result: 0
252 running: --debug commit -m commit2 -d 2000-01-02 foo
262 running: --debug commit -m commit2 -d 2000-01-02 foo
253 committing files:
263 committing files:
254 foo
264 foo
255 committing manifest
265 committing manifest
256 committing changelog
266 committing changelog
257 updating the branch cache
267 updating the branch cache
258 committed changeset 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7
268 committed changeset 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7
259 result: 0
269 result: 0
260 running: --debug log -r 0
270 running: --debug log -r 0
261 changeset: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
271 changeset: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
262 phase: draft
272 phase: draft
263 parent: -1:0000000000000000000000000000000000000000
273 parent: -1:0000000000000000000000000000000000000000
264 parent: -1:0000000000000000000000000000000000000000
274 parent: -1:0000000000000000000000000000000000000000
265 manifest: 0:9091aa5df980aea60860a2e39c95182e68d1ddec
275 manifest: 0:9091aa5df980aea60860a2e39c95182e68d1ddec
266 user: test
276 user: test
267 date: Sat Jan 01 00:00:00 2000 +0000
277 date: Sat Jan 01 00:00:00 2000 +0000
268 files+: foo
278 files+: foo
269 extra: branch=default
279 extra: branch=default
270 description:
280 description:
271 commit1
281 commit1
272
282
273
283
274 result: 0
284 result: 0
275 running: --debug log -r tip
285 running: --debug log -r tip
276 changeset: 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7
286 changeset: 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7
277 tag: tip
287 tag: tip
278 phase: draft
288 phase: draft
279 parent: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
289 parent: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
280 parent: -1:0000000000000000000000000000000000000000
290 parent: -1:0000000000000000000000000000000000000000
281 manifest: 1:895aa9b7886f89dd017a6d62524e1f9180b04df9
291 manifest: 1:895aa9b7886f89dd017a6d62524e1f9180b04df9
282 user: test
292 user: test
283 date: Sun Jan 02 00:00:00 2000 +0000
293 date: Sun Jan 02 00:00:00 2000 +0000
284 files: foo
294 files: foo
285 extra: branch=default
295 extra: branch=default
286 description:
296 description:
287 commit2
297 commit2
288
298
289
299
290 result: 0
300 result: 0
291 $ hg blackbox
301 $ hg blackbox
292 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updating the branch cache
302 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updating the branch cache
293 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updated served branch cache in * seconds (glob)
303 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updated served branch cache in * seconds (glob)
294 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> wrote served branch cache with 1 labels and 1 nodes
304 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> wrote served branch cache with 1 labels and 1 nodes
295 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug commit -m commit2 -d 2000-01-02 foo exited 0 after *.?? seconds (glob)
305 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug commit -m commit2 -d 2000-01-02 foo exited 0 after *.?? seconds (glob)
296 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r 0
306 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r 0
297 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> writing .hg/cache/tags2-visible with 0 tags
307 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> writing .hg/cache/tags2-visible with 0 tags
298 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r 0 exited 0 after *.?? seconds (glob)
308 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r 0 exited 0 after *.?? seconds (glob)
299 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r tip
309 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r tip
300 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r tip exited 0 after *.?? seconds (glob)
310 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r tip exited 0 after *.?? seconds (glob)
301 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox
311 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox
302
312
303 Test log recursion from dirty status check
313 Test log recursion from dirty status check
304
314
305 $ cat > ../r.py <<EOF
315 $ cat > ../r.py <<EOF
306 > from mercurial import context, error, extensions
316 > from mercurial import context, error, extensions
307 > x=[False]
317 > x=[False]
308 > def status(orig, *args, **opts):
318 > def status(orig, *args, **opts):
309 > args[0].repo().ui.log(b"broken", b"recursion?")
319 > args[0].repo().ui.log(b"broken", b"recursion?")
310 > return orig(*args, **opts)
320 > return orig(*args, **opts)
311 > def reposetup(ui, repo):
321 > def reposetup(ui, repo):
312 > extensions.wrapfunction(context.basectx, 'status', status)
322 > extensions.wrapfunction(context.basectx, 'status', status)
313 > EOF
323 > EOF
314 $ hg id --config extensions.x=../r.py --config blackbox.dirty=True
324 $ hg id --config extensions.x=../r.py --config blackbox.dirty=True
315 45589e459b2e tip
325 45589e459b2e tip
316
326
317 cleanup
327 cleanup
318 $ cd ..
328 $ cd ..
319
329
320 #if chg
330 #if chg
321
331
322 when using chg, blackbox.log should get rotated correctly
332 when using chg, blackbox.log should get rotated correctly
323
333
324 $ cat > $TESTTMP/noop.py << EOF
334 $ cat > $TESTTMP/noop.py << EOF
325 > from __future__ import absolute_import
335 > from __future__ import absolute_import
326 > import time
336 > import time
327 > from mercurial import registrar, scmutil
337 > from mercurial import registrar, scmutil
328 > cmdtable = {}
338 > cmdtable = {}
329 > command = registrar.command(cmdtable)
339 > command = registrar.command(cmdtable)
330 > @command('noop')
340 > @command('noop')
331 > def noop(ui, repo):
341 > def noop(ui, repo):
332 > pass
342 > pass
333 > EOF
343 > EOF
334
344
335 $ hg init blackbox-chg
345 $ hg init blackbox-chg
336 $ cd blackbox-chg
346 $ cd blackbox-chg
337
347
338 $ cat > .hg/hgrc << EOF
348 $ cat > .hg/hgrc << EOF
339 > [blackbox]
349 > [blackbox]
340 > maxsize = 500B
350 > maxsize = 500B
341 > [extensions]
351 > [extensions]
342 > # extension change forces chg to restart
352 > # extension change forces chg to restart
343 > noop=$TESTTMP/noop.py
353 > noop=$TESTTMP/noop.py
344 > EOF
354 > EOF
345
355
346 $ "$PYTHON" -c 'print("a" * 400)' > .hg/blackbox.log
356 $ "$PYTHON" -c 'print("a" * 400)' > .hg/blackbox.log
347 $ chg noop
357 $ chg noop
348 $ chg noop
358 $ chg noop
349 $ chg noop
359 $ chg noop
350 $ chg noop
360 $ chg noop
351 $ chg noop
361 $ chg noop
352
362
353 $ cat > showsize.py << 'EOF'
363 $ cat > showsize.py << 'EOF'
354 > import os
364 > import os
355 > import sys
365 > import sys
356 > limit = 500
366 > limit = 500
357 > for p in sys.argv[1:]:
367 > for p in sys.argv[1:]:
358 > size = os.stat(p).st_size
368 > size = os.stat(p).st_size
359 > if size >= limit:
369 > if size >= limit:
360 > desc = '>='
370 > desc = '>='
361 > else:
371 > else:
362 > desc = '<'
372 > desc = '<'
363 > print('%s: %s %d' % (p, desc, limit))
373 > print('%s: %s %d' % (p, desc, limit))
364 > EOF
374 > EOF
365
375
366 $ "$PYTHON" showsize.py .hg/blackbox*
376 $ "$PYTHON" showsize.py .hg/blackbox*
367 .hg/blackbox.log: < 500
377 .hg/blackbox.log: < 500
368 .hg/blackbox.log.1: >= 500
378 .hg/blackbox.log.1: >= 500
369 .hg/blackbox.log.2: >= 500
379 .hg/blackbox.log.2: >= 500
370
380
371 $ cd ..
381 $ cd ..
372
382
373 With chg, blackbox should not create the log file if the repo is gone
383 With chg, blackbox should not create the log file if the repo is gone
374
384
375 $ hg init repo1
385 $ hg init repo1
376 $ hg --config extensions.a=! -R repo1 log
386 $ hg --config extensions.a=! -R repo1 log
377 $ rm -rf $TESTTMP/repo1
387 $ rm -rf $TESTTMP/repo1
378 $ hg --config extensions.a=! init repo1
388 $ hg --config extensions.a=! init repo1
379
389
380 #endif
390 #endif
381
391
382 blackbox should work if repo.ui.log is not called (issue5518)
392 blackbox should work if repo.ui.log is not called (issue5518)
383
393
384 $ cat > $TESTTMP/raise.py << EOF
394 $ cat > $TESTTMP/raise.py << EOF
385 > from __future__ import absolute_import
395 > from __future__ import absolute_import
386 > from mercurial import registrar, scmutil
396 > from mercurial import registrar, scmutil
387 > cmdtable = {}
397 > cmdtable = {}
388 > command = registrar.command(cmdtable)
398 > command = registrar.command(cmdtable)
389 > @command(b'raise')
399 > @command(b'raise')
390 > def raisecmd(*args):
400 > def raisecmd(*args):
391 > raise RuntimeError('raise')
401 > raise RuntimeError('raise')
392 > EOF
402 > EOF
393
403
394 $ cat >> $HGRCPATH << EOF
404 $ cat >> $HGRCPATH << EOF
395 > [blackbox]
405 > [blackbox]
396 > track = commandexception
406 > track = commandexception
397 > [extensions]
407 > [extensions]
398 > raise=$TESTTMP/raise.py
408 > raise=$TESTTMP/raise.py
399 > EOF
409 > EOF
400
410
401 $ hg init $TESTTMP/blackbox-exception-only
411 $ hg init $TESTTMP/blackbox-exception-only
402 $ cd $TESTTMP/blackbox-exception-only
412 $ cd $TESTTMP/blackbox-exception-only
403
413
404 #if chg
414 #if chg
405 (chg exits 255 because it fails to receive an exit code)
415 (chg exits 255 because it fails to receive an exit code)
406 $ hg raise 2>/dev/null
416 $ hg raise 2>/dev/null
407 [255]
417 [255]
408 #else
418 #else
409 (hg exits 1 because Python default exit code for uncaught exception is 1)
419 (hg exits 1 because Python default exit code for uncaught exception is 1)
410 $ hg raise 2>/dev/null
420 $ hg raise 2>/dev/null
411 [1]
421 [1]
412 #endif
422 #endif
413
423
414 $ head -1 .hg/blackbox.log
424 $ head -1 .hg/blackbox.log
415 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> ** Unknown exception encountered with possibly-broken third-party extension mock
425 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> ** Unknown exception encountered with possibly-broken third-party extension mock
416 $ tail -2 .hg/blackbox.log
426 $ tail -2 .hg/blackbox.log
417 RuntimeError: raise
427 RuntimeError: raise
418
428
General Comments 0
You need to be logged in to leave comments. Login now