##// END OF EJS Templates
blackbox: disable extremely verbose logging (issue6110)...
Valentin Gatien-Baron -
r42834:56132ebd default
parent child Browse files
Show More
@@ -1,197 +1,205 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 and
13 blackbox.ignore config keys.
13
14
14 Examples::
15 Examples::
15
16
16 [blackbox]
17 [blackbox]
17 track = *
18 track = *
19 ignore = pythonhook
18 # dirty is *EXPENSIVE* (slow);
20 # dirty is *EXPENSIVE* (slow);
19 # each log entry indicates `+` if the repository is dirty, like :hg:`id`.
21 # each log entry indicates `+` if the repository is dirty, like :hg:`id`.
20 dirty = True
22 dirty = True
21 # record the source of log messages
23 # record the source of log messages
22 logsource = True
24 logsource = True
23
25
24 [blackbox]
26 [blackbox]
25 track = command, commandfinish, commandexception, exthook, pythonhook
27 track = command, commandfinish, commandexception, exthook, pythonhook
26
28
27 [blackbox]
29 [blackbox]
28 track = incoming
30 track = incoming
29
31
30 [blackbox]
32 [blackbox]
31 # limit the size of a log file
33 # limit the size of a log file
32 maxsize = 1.5 MB
34 maxsize = 1.5 MB
33 # rotate up to N log files when the current one gets too big
35 # rotate up to N log files when the current one gets too big
34 maxfiles = 3
36 maxfiles = 3
35
37
36 [blackbox]
38 [blackbox]
37 # Include nanoseconds in log entries with %f (see Python function
39 # Include nanoseconds in log entries with %f (see Python function
38 # datetime.datetime.strftime)
40 # datetime.datetime.strftime)
39 date-format = '%Y-%m-%d @ %H:%M:%S.%f'
41 date-format = '%Y-%m-%d @ %H:%M:%S.%f'
40
42
41 """
43 """
42
44
43 from __future__ import absolute_import
45 from __future__ import absolute_import
44
46
45 import re
47 import re
46
48
47 from mercurial.i18n import _
49 from mercurial.i18n import _
48 from mercurial.node import hex
50 from mercurial.node import hex
49
51
50 from mercurial import (
52 from mercurial import (
51 encoding,
53 encoding,
52 loggingutil,
54 loggingutil,
53 registrar,
55 registrar,
54 )
56 )
55 from mercurial.utils import (
57 from mercurial.utils import (
56 dateutil,
58 dateutil,
57 procutil,
59 procutil,
58 )
60 )
59
61
60 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
62 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
61 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
63 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
62 # be specifying the version(s) of Mercurial they are tested with, or
64 # be specifying the version(s) of Mercurial they are tested with, or
63 # leave the attribute unspecified.
65 # leave the attribute unspecified.
64 testedwith = 'ships-with-hg-core'
66 testedwith = 'ships-with-hg-core'
65
67
66 cmdtable = {}
68 cmdtable = {}
67 command = registrar.command(cmdtable)
69 command = registrar.command(cmdtable)
68
70
69 configtable = {}
71 configtable = {}
70 configitem = registrar.configitem(configtable)
72 configitem = registrar.configitem(configtable)
71
73
72 configitem('blackbox', 'dirty',
74 configitem('blackbox', 'dirty',
73 default=False,
75 default=False,
74 )
76 )
75 configitem('blackbox', 'maxsize',
77 configitem('blackbox', 'maxsize',
76 default='1 MB',
78 default='1 MB',
77 )
79 )
78 configitem('blackbox', 'logsource',
80 configitem('blackbox', 'logsource',
79 default=False,
81 default=False,
80 )
82 )
81 configitem('blackbox', 'maxfiles',
83 configitem('blackbox', 'maxfiles',
82 default=7,
84 default=7,
83 )
85 )
84 configitem('blackbox', 'track',
86 configitem('blackbox', 'track',
85 default=lambda: ['*'],
87 default=lambda: ['*'],
86 )
88 )
89 configitem('blackbox', 'ignore',
90 default=lambda: ['chgserver', 'cmdserver', 'extension'],
91 )
87 configitem('blackbox', 'date-format',
92 configitem('blackbox', 'date-format',
88 default='%Y/%m/%d %H:%M:%S',
93 default='%Y/%m/%d %H:%M:%S',
89 )
94 )
90
95
91 _lastlogger = loggingutil.proxylogger()
96 _lastlogger = loggingutil.proxylogger()
92
97
93 class blackboxlogger(object):
98 class blackboxlogger(object):
94 def __init__(self, ui, repo):
99 def __init__(self, ui, repo):
95 self._repo = repo
100 self._repo = repo
96 self._trackedevents = set(ui.configlist('blackbox', 'track'))
101 self._trackedevents = set(ui.configlist('blackbox', 'track'))
102 self._ignoredevents = set(ui.configlist('blackbox', 'ignore'))
97 self._maxfiles = ui.configint('blackbox', 'maxfiles')
103 self._maxfiles = ui.configint('blackbox', 'maxfiles')
98 self._maxsize = ui.configbytes('blackbox', 'maxsize')
104 self._maxsize = ui.configbytes('blackbox', 'maxsize')
99 self._inlog = False
105 self._inlog = False
100
106
101 def tracked(self, event):
107 def tracked(self, event):
102 return b'*' in self._trackedevents or event in self._trackedevents
108 return ((b'*' in self._trackedevents
109 and event not in self._ignoredevents)
110 or event in self._trackedevents)
103
111
104 def log(self, ui, event, msg, opts):
112 def log(self, ui, event, msg, opts):
105 # self._log() -> ctx.dirty() may create new subrepo instance, which
113 # self._log() -> ctx.dirty() may create new subrepo instance, which
106 # ui is derived from baseui. So the recursion guard in ui.log()
114 # ui is derived from baseui. So the recursion guard in ui.log()
107 # doesn't work as it's local to the ui instance.
115 # doesn't work as it's local to the ui instance.
108 if self._inlog:
116 if self._inlog:
109 return
117 return
110 self._inlog = True
118 self._inlog = True
111 try:
119 try:
112 self._log(ui, event, msg, opts)
120 self._log(ui, event, msg, opts)
113 finally:
121 finally:
114 self._inlog = False
122 self._inlog = False
115
123
116 def _log(self, ui, event, msg, opts):
124 def _log(self, ui, event, msg, opts):
117 default = ui.configdate('devel', 'default-date')
125 default = ui.configdate('devel', 'default-date')
118 date = dateutil.datestr(default, ui.config('blackbox', 'date-format'))
126 date = dateutil.datestr(default, ui.config('blackbox', 'date-format'))
119 user = procutil.getuser()
127 user = procutil.getuser()
120 pid = '%d' % procutil.getpid()
128 pid = '%d' % procutil.getpid()
121 changed = ''
129 changed = ''
122 ctx = self._repo[None]
130 ctx = self._repo[None]
123 parents = ctx.parents()
131 parents = ctx.parents()
124 rev = ('+'.join([hex(p.node()) for p in parents]))
132 rev = ('+'.join([hex(p.node()) for p in parents]))
125 if (ui.configbool('blackbox', 'dirty') and
133 if (ui.configbool('blackbox', 'dirty') and
126 ctx.dirty(missing=True, merge=False, branch=False)):
134 ctx.dirty(missing=True, merge=False, branch=False)):
127 changed = '+'
135 changed = '+'
128 if ui.configbool('blackbox', 'logsource'):
136 if ui.configbool('blackbox', 'logsource'):
129 src = ' [%s]' % event
137 src = ' [%s]' % event
130 else:
138 else:
131 src = ''
139 src = ''
132 try:
140 try:
133 fmt = '%s %s @%s%s (%s)%s> %s'
141 fmt = '%s %s @%s%s (%s)%s> %s'
134 args = (date, user, rev, changed, pid, src, msg)
142 args = (date, user, rev, changed, pid, src, msg)
135 with loggingutil.openlogfile(
143 with loggingutil.openlogfile(
136 ui, self._repo.vfs, name='blackbox.log',
144 ui, self._repo.vfs, name='blackbox.log',
137 maxfiles=self._maxfiles, maxsize=self._maxsize) as fp:
145 maxfiles=self._maxfiles, maxsize=self._maxsize) as fp:
138 fp.write(fmt % args)
146 fp.write(fmt % args)
139 except (IOError, OSError) as err:
147 except (IOError, OSError) as err:
140 # deactivate this to avoid failed logging again
148 # deactivate this to avoid failed logging again
141 self._trackedevents.clear()
149 self._trackedevents.clear()
142 ui.debug('warning: cannot write to blackbox.log: %s\n' %
150 ui.debug('warning: cannot write to blackbox.log: %s\n' %
143 encoding.strtolocal(err.strerror))
151 encoding.strtolocal(err.strerror))
144 return
152 return
145 _lastlogger.logger = self
153 _lastlogger.logger = self
146
154
147 def uipopulate(ui):
155 def uipopulate(ui):
148 ui.setlogger(b'blackbox', _lastlogger)
156 ui.setlogger(b'blackbox', _lastlogger)
149
157
150 def reposetup(ui, repo):
158 def reposetup(ui, repo):
151 # During 'hg pull' a httppeer repo is created to represent the remote repo.
159 # During 'hg pull' a httppeer repo is created to represent the remote repo.
152 # It doesn't have a .hg directory to put a blackbox in, so we don't do
160 # It doesn't have a .hg directory to put a blackbox in, so we don't do
153 # the blackbox setup for it.
161 # the blackbox setup for it.
154 if not repo.local():
162 if not repo.local():
155 return
163 return
156
164
157 # Since blackbox.log is stored in the repo directory, the logger should be
165 # Since blackbox.log is stored in the repo directory, the logger should be
158 # instantiated per repository.
166 # instantiated per repository.
159 logger = blackboxlogger(ui, repo)
167 logger = blackboxlogger(ui, repo)
160 ui.setlogger(b'blackbox', logger)
168 ui.setlogger(b'blackbox', logger)
161
169
162 # Set _lastlogger even if ui.log is not called. This gives blackbox a
170 # Set _lastlogger even if ui.log is not called. This gives blackbox a
163 # fallback place to log
171 # fallback place to log
164 if _lastlogger.logger is None:
172 if _lastlogger.logger is None:
165 _lastlogger.logger = logger
173 _lastlogger.logger = logger
166
174
167 repo._wlockfreeprefix.add('blackbox.log')
175 repo._wlockfreeprefix.add('blackbox.log')
168
176
169 @command('blackbox',
177 @command('blackbox',
170 [('l', 'limit', 10, _('the number of events to show')),
178 [('l', 'limit', 10, _('the number of events to show')),
171 ],
179 ],
172 _('hg blackbox [OPTION]...'),
180 _('hg blackbox [OPTION]...'),
173 helpcategory=command.CATEGORY_MAINTENANCE,
181 helpcategory=command.CATEGORY_MAINTENANCE,
174 helpbasic=True)
182 helpbasic=True)
175 def blackbox(ui, repo, *revs, **opts):
183 def blackbox(ui, repo, *revs, **opts):
176 '''view the recent repository events
184 '''view the recent repository events
177 '''
185 '''
178
186
179 if not repo.vfs.exists('blackbox.log'):
187 if not repo.vfs.exists('blackbox.log'):
180 return
188 return
181
189
182 limit = opts.get(r'limit')
190 limit = opts.get(r'limit')
183 fp = repo.vfs('blackbox.log', 'r')
191 fp = repo.vfs('blackbox.log', 'r')
184 lines = fp.read().split('\n')
192 lines = fp.read().split('\n')
185
193
186 count = 0
194 count = 0
187 output = []
195 output = []
188 for line in reversed(lines):
196 for line in reversed(lines):
189 if count >= limit:
197 if count >= limit:
190 break
198 break
191
199
192 # count the commands by matching lines like: 2013/01/23 19:13:36 root>
200 # count the commands by matching lines like: 2013/01/23 19:13:36 root>
193 if re.match(br'^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} .*> .*', line):
201 if re.match(br'^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} .*> .*', line):
194 count += 1
202 count += 1
195 output.append(line)
203 output.append(line)
196
204
197 ui.status('\n'.join(reversed(output)))
205 ui.status('\n'.join(reversed(output)))
@@ -1,484 +1,481 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'abortcmd', [], b'hg abortcmd')
10 > @command(b'abortcmd', [], b'hg abortcmd')
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 > [blackbox]
26 > track = backupbundle, branchcache, command, commandalias, commandexception,
27 > commandfinish, debug, exthook, incoming, pythonhook, tagscache
28 > EOF
25 > EOF
29
26
30 $ hg init blackboxtest
27 $ hg init blackboxtest
31 $ cd blackboxtest
28 $ cd blackboxtest
32
29
33 command, exit codes, and duration
30 command, exit codes, and duration
34
31
35 $ echo a > a
32 $ echo a > a
36 $ hg add a
33 $ hg add a
37 $ hg blackbox --config blackbox.dirty=True
34 $ hg blackbox --config blackbox.dirty=True
38 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)
39 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a
36 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a
40 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)
41 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)
42
39
43 failure exit code
40 failure exit code
44 $ rm ./.hg/blackbox.log
41 $ rm ./.hg/blackbox.log
45 $ hg add non-existent
42 $ hg add non-existent
46 non-existent: $ENOENT$
43 non-existent: $ENOENT$
47 [1]
44 [1]
48 $ hg blackbox
45 $ hg blackbox
49 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
50 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)
51 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
48 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
52
49
53 abort exit code
50 abort exit code
54 $ rm ./.hg/blackbox.log
51 $ rm ./.hg/blackbox.log
55 $ hg abortcmd 2> /dev/null
52 $ hg abortcmd 2> /dev/null
56 [255]
53 [255]
57 $ hg blackbox -l 2
54 $ hg blackbox -l 2
58 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> abortcmd exited 255 after * seconds (glob)
55 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> abortcmd exited 255 after * seconds (glob)
59 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
60
57
61 unhandled exception
58 unhandled exception
62 $ rm ./.hg/blackbox.log
59 $ rm ./.hg/blackbox.log
63 $ hg crash 2> /dev/null
60 $ hg crash 2> /dev/null
64 [1]
61 [1]
65 $ hg blackbox -l 2
62 $ hg blackbox -l 2
66 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)
67 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
68
65
69 alias expansion is logged
66 alias expansion is logged
70 $ rm ./.hg/blackbox.log
67 $ rm ./.hg/blackbox.log
71 $ hg confuse
68 $ hg confuse
72 $ hg blackbox
69 $ hg blackbox
73 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse
70 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse
74 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'
75 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)
76 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
73 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
77
74
78 recursive aliases work correctly
75 recursive aliases work correctly
79 $ rm ./.hg/blackbox.log
76 $ rm ./.hg/blackbox.log
80 $ hg so-confusing
77 $ hg so-confusing
81 $ hg blackbox
78 $ hg blackbox
82 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> so-confusing
79 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> so-confusing
83 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'
84 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'
85 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)
86 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
83 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
87
84
88 custom date format
85 custom date format
89 $ rm ./.hg/blackbox.log
86 $ rm ./.hg/blackbox.log
90 $ hg --config blackbox.date-format='%Y-%m-%d @ %H:%M:%S' \
87 $ hg --config blackbox.date-format='%Y-%m-%d @ %H:%M:%S' \
91 > --config devel.default-date='1334347993 0' --traceback status
88 > --config devel.default-date='1334347993 0' --traceback status
92 A a
89 A a
93 $ hg blackbox
90 $ hg blackbox
94 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 (glob)
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 (glob)
95 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)
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)
96 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
93 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
97
94
98 incoming change tracking
95 incoming change tracking
99
96
100 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
101 $ hg commit -ma
98 $ hg commit -ma
102 $ hg up null
99 $ hg up null
103 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
104 $ echo b > b
101 $ echo b > b
105 $ hg commit -Amb
102 $ hg commit -Amb
106 adding b
103 adding b
107 created new head
104 created new head
108
105
109 clone, commit, pull
106 clone, commit, pull
110 $ hg clone . ../blackboxtest2
107 $ hg clone . ../blackboxtest2
111 updating to branch default
108 updating to branch default
112 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
113 $ echo c > c
110 $ echo c > c
114 $ hg commit -Amc
111 $ hg commit -Amc
115 adding c
112 adding c
116 $ cd ../blackboxtest2
113 $ cd ../blackboxtest2
117 $ hg pull
114 $ hg pull
118 pulling from $TESTTMP/blackboxtest
115 pulling from $TESTTMP/blackboxtest
119 searching for changes
116 searching for changes
120 adding changesets
117 adding changesets
121 adding manifests
118 adding manifests
122 adding file changes
119 adding file changes
123 added 1 changesets with 1 changes to 1 files
120 added 1 changesets with 1 changes to 1 files
124 new changesets d02f48003e62
121 new changesets d02f48003e62
125 (run 'hg update' to get a working copy)
122 (run 'hg update' to get a working copy)
126 $ hg blackbox -l 6
123 $ hg blackbox -l 6
127 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull
124 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull
128 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated branch cache (served) in * seconds (glob)
125 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated branch cache (served) in * seconds (glob)
129 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote branch cache (served) with 1 labels and 2 nodes
126 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote branch cache (served) with 1 labels and 2 nodes
130 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
131 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)
132 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
133
130
134 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
135
132
136 $ hg rollback
133 $ hg rollback
137 repository tip rolled back to revision 1 (undo pull)
134 repository tip rolled back to revision 1 (undo pull)
138
135
139 $ mv .hg/blackbox.log .hg/blackbox.log-
136 $ mv .hg/blackbox.log .hg/blackbox.log-
140 $ mkdir .hg/blackbox.log
137 $ mkdir .hg/blackbox.log
141 $ hg --debug incoming
138 $ hg --debug incoming
142 warning: cannot write to blackbox.log: * (glob)
139 warning: cannot write to blackbox.log: * (glob)
143 comparing with $TESTTMP/blackboxtest
140 comparing with $TESTTMP/blackboxtest
144 query 1; heads
141 query 1; heads
145 searching for changes
142 searching for changes
146 all local heads known remotely
143 all local heads known remotely
147 changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51
144 changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51
148 tag: tip
145 tag: tip
149 phase: draft
146 phase: draft
150 parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06
147 parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06
151 parent: -1:0000000000000000000000000000000000000000
148 parent: -1:0000000000000000000000000000000000000000
152 manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892
149 manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892
153 user: test
150 user: test
154 date: Thu Jan 01 00:00:00 1970 +0000
151 date: Thu Jan 01 00:00:00 1970 +0000
155 files+: c
152 files+: c
156 extra: branch=default
153 extra: branch=default
157 description:
154 description:
158 c
155 c
159
156
160
157
161 $ hg pull
158 $ hg pull
162 pulling from $TESTTMP/blackboxtest
159 pulling from $TESTTMP/blackboxtest
163 searching for changes
160 searching for changes
164 adding changesets
161 adding changesets
165 adding manifests
162 adding manifests
166 adding file changes
163 adding file changes
167 added 1 changesets with 1 changes to 1 files
164 added 1 changesets with 1 changes to 1 files
168 new changesets d02f48003e62
165 new changesets d02f48003e62
169 (run 'hg update' to get a working copy)
166 (run 'hg update' to get a working copy)
170
167
171 a failure reading from the log is fatal
168 a failure reading from the log is fatal
172
169
173 $ hg blackbox -l 3
170 $ hg blackbox -l 3
174 abort: *$TESTTMP/blackboxtest2/.hg/blackbox.log* (glob)
171 abort: *$TESTTMP/blackboxtest2/.hg/blackbox.log* (glob)
175 [255]
172 [255]
176
173
177 $ rmdir .hg/blackbox.log
174 $ rmdir .hg/blackbox.log
178 $ mv .hg/blackbox.log- .hg/blackbox.log
175 $ mv .hg/blackbox.log- .hg/blackbox.log
179
176
180 backup bundles get logged
177 backup bundles get logged
181
178
182 $ touch d
179 $ touch d
183 $ hg commit -Amd
180 $ hg commit -Amd
184 adding d
181 adding d
185 created new head
182 created new head
186 $ hg strip tip
183 $ hg strip tip
187 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
188 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)
189 $ hg blackbox -l 6
186 $ hg blackbox -l 6
190 1970/01/01 00:00:00 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip
187 1970/01/01 00:00:00 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip
191 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
192 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated branch cache (base) in * seconds (glob)
189 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated branch cache (base) in * seconds (glob)
193 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote branch cache (base) with 1 labels and 2 nodes
190 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote branch cache (base) with 1 labels and 2 nodes
194 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)
195 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
196
193
197 extension and python hooks - use the eol extension for a pythonhook
194 extension and python hooks - use the eol extension for a pythonhook
198
195
199 $ echo '[extensions]' >> .hg/hgrc
196 $ echo '[extensions]' >> .hg/hgrc
200 $ echo 'eol=' >> .hg/hgrc
197 $ echo 'eol=' >> .hg/hgrc
201 $ echo '[hooks]' >> .hg/hgrc
198 $ echo '[hooks]' >> .hg/hgrc
202 $ echo 'update = echo hooked' >> .hg/hgrc
199 $ echo 'update = echo hooked' >> .hg/hgrc
203 $ hg update
200 $ hg update
204 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 !)
205 hooked
202 hooked
206 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
207 updated to "d02f48003e62: c"
204 updated to "d02f48003e62: c"
208 1 other heads for branch "default"
205 1 other heads for branch "default"
209 $ cat >> .hg/hgrc <<EOF
206 $ cat >> .hg/hgrc <<EOF
210 > [extensions]
207 > [extensions]
211 > # disable eol, because it is not needed for subsequent tests
208 > # disable eol, because it is not needed for subsequent tests
212 > # (in addition, keeping it requires extra care for fsmonitor)
209 > # (in addition, keeping it requires extra care for fsmonitor)
213 > eol=!
210 > eol=!
214 > EOF
211 > EOF
215 $ hg blackbox -l 5
212 $ hg blackbox -l 5
216 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 !)
217 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)
218 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)
219 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)
220 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 !)
221 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
222
219
223 log rotation
220 log rotation
224
221
225 $ echo '[blackbox]' >> .hg/hgrc
222 $ echo '[blackbox]' >> .hg/hgrc
226 $ echo 'maxsize = 20 b' >> .hg/hgrc
223 $ echo 'maxsize = 20 b' >> .hg/hgrc
227 $ echo 'maxfiles = 3' >> .hg/hgrc
224 $ echo 'maxfiles = 3' >> .hg/hgrc
228 $ hg status
225 $ hg status
229 $ hg status
226 $ hg status
230 $ hg status
227 $ hg status
231 $ hg tip -q
228 $ hg tip -q
232 2:d02f48003e62
229 2:d02f48003e62
233 $ ls .hg/blackbox.log*
230 $ ls .hg/blackbox.log*
234 .hg/blackbox.log
231 .hg/blackbox.log
235 .hg/blackbox.log.1
232 .hg/blackbox.log.1
236 .hg/blackbox.log.2
233 .hg/blackbox.log.2
237 $ cd ..
234 $ cd ..
238
235
239 $ hg init blackboxtest3
236 $ hg init blackboxtest3
240 $ cd blackboxtest3
237 $ cd blackboxtest3
241 $ hg blackbox
238 $ hg blackbox
242 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)
243 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
240 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
244 $ mv .hg/blackbox.log .hg/blackbox.log-
241 $ mv .hg/blackbox.log .hg/blackbox.log-
245 $ mkdir .hg/blackbox.log
242 $ mkdir .hg/blackbox.log
246 $ 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")\
247 > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\
244 > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\
248 > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
245 > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py
249 $ "$PYTHON" $TESTDIR/blackbox-readonly-dispatch.py
246 $ "$PYTHON" $TESTDIR/blackbox-readonly-dispatch.py
250 running: --debug add foo
247 running: --debug add foo
251 warning: cannot write to blackbox.log: Is a directory (no-windows !)
248 warning: cannot write to blackbox.log: Is a directory (no-windows !)
252 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 !)
253 adding foo
250 adding foo
254 result: 0
251 result: 0
255 running: --debug commit -m commit1 -d 2000-01-01 foo
252 running: --debug commit -m commit1 -d 2000-01-01 foo
256 warning: cannot write to blackbox.log: Is a directory (no-windows !)
253 warning: cannot write to blackbox.log: Is a directory (no-windows !)
257 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 !)
258 committing files:
255 committing files:
259 foo
256 foo
260 committing manifest
257 committing manifest
261 committing changelog
258 committing changelog
262 updating the branch cache
259 updating the branch cache
263 committed changeset 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
260 committed changeset 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
264 result: 0
261 result: 0
265 running: --debug commit -m commit2 -d 2000-01-02 foo
262 running: --debug commit -m commit2 -d 2000-01-02 foo
266 committing files:
263 committing files:
267 foo
264 foo
268 committing manifest
265 committing manifest
269 committing changelog
266 committing changelog
270 updating the branch cache
267 updating the branch cache
271 committed changeset 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7
268 committed changeset 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7
272 result: 0
269 result: 0
273 running: --debug log -r 0
270 running: --debug log -r 0
274 changeset: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
271 changeset: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
275 phase: draft
272 phase: draft
276 parent: -1:0000000000000000000000000000000000000000
273 parent: -1:0000000000000000000000000000000000000000
277 parent: -1:0000000000000000000000000000000000000000
274 parent: -1:0000000000000000000000000000000000000000
278 manifest: 0:9091aa5df980aea60860a2e39c95182e68d1ddec
275 manifest: 0:9091aa5df980aea60860a2e39c95182e68d1ddec
279 user: test
276 user: test
280 date: Sat Jan 01 00:00:00 2000 +0000
277 date: Sat Jan 01 00:00:00 2000 +0000
281 files+: foo
278 files+: foo
282 extra: branch=default
279 extra: branch=default
283 description:
280 description:
284 commit1
281 commit1
285
282
286
283
287 result: 0
284 result: 0
288 running: --debug log -r tip
285 running: --debug log -r tip
289 changeset: 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7
286 changeset: 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7
290 tag: tip
287 tag: tip
291 phase: draft
288 phase: draft
292 parent: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
289 parent: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2
293 parent: -1:0000000000000000000000000000000000000000
290 parent: -1:0000000000000000000000000000000000000000
294 manifest: 1:895aa9b7886f89dd017a6d62524e1f9180b04df9
291 manifest: 1:895aa9b7886f89dd017a6d62524e1f9180b04df9
295 user: test
292 user: test
296 date: Sun Jan 02 00:00:00 2000 +0000
293 date: Sun Jan 02 00:00:00 2000 +0000
297 files: foo
294 files: foo
298 extra: branch=default
295 extra: branch=default
299 description:
296 description:
300 commit2
297 commit2
301
298
302
299
303 result: 0
300 result: 0
304 $ hg blackbox
301 $ hg blackbox
305 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
306 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updated branch cache (served) in * seconds (glob)
303 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updated branch cache (served) in * seconds (glob)
307 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> wrote branch cache (served) with 1 labels and 1 nodes
304 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> wrote branch cache (served) with 1 labels and 1 nodes
308 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)
309 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
310 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
311 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)
312 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
313 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)
314 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox
311 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox
315
312
316 Test log recursion from dirty status check
313 Test log recursion from dirty status check
317
314
318 $ cat > ../r.py <<EOF
315 $ cat > ../r.py <<EOF
319 > from mercurial import context, error, extensions
316 > from mercurial import context, error, extensions
320 > x=[False]
317 > x=[False]
321 > def status(orig, *args, **opts):
318 > def status(orig, *args, **opts):
322 > args[0].repo().ui.log(b"broken", b"recursion?")
319 > args[0].repo().ui.log(b"broken", b"recursion?")
323 > return orig(*args, **opts)
320 > return orig(*args, **opts)
324 > def reposetup(ui, repo):
321 > def reposetup(ui, repo):
325 > extensions.wrapfunction(context.basectx, 'status', status)
322 > extensions.wrapfunction(context.basectx, 'status', status)
326 > EOF
323 > EOF
327 $ hg id --config extensions.x=../r.py --config blackbox.dirty=True
324 $ hg id --config extensions.x=../r.py --config blackbox.dirty=True
328 45589e459b2e tip
325 45589e459b2e tip
329
326
330 cleanup
327 cleanup
331 $ cd ..
328 $ cd ..
332
329
333 Test missing log directory, which shouldn't be created automatically
330 Test missing log directory, which shouldn't be created automatically
334
331
335 $ cat <<'EOF' > closeremove.py
332 $ cat <<'EOF' > closeremove.py
336 > def reposetup(ui, repo):
333 > def reposetup(ui, repo):
337 > class rmrepo(repo.__class__):
334 > class rmrepo(repo.__class__):
338 > def close(self):
335 > def close(self):
339 > super(rmrepo, self).close()
336 > super(rmrepo, self).close()
340 > self.ui.debug(b'removing %s\n' % self.vfs.base)
337 > self.ui.debug(b'removing %s\n' % self.vfs.base)
341 > self.vfs.rmtree()
338 > self.vfs.rmtree()
342 > repo.__class__ = rmrepo
339 > repo.__class__ = rmrepo
343 > EOF
340 > EOF
344
341
345 $ hg init gone
342 $ hg init gone
346 $ cd gone
343 $ cd gone
347 $ cat <<'EOF' > .hg/hgrc
344 $ cat <<'EOF' > .hg/hgrc
348 > [extensions]
345 > [extensions]
349 > closeremove = ../closeremove.py
346 > closeremove = ../closeremove.py
350 > EOF
347 > EOF
351 $ hg log --debug
348 $ hg log --debug
352 removing $TESTTMP/gone/.hg
349 removing $TESTTMP/gone/.hg
353 warning: cannot write to blackbox.log: $ENOENT$ (no-windows !)
350 warning: cannot write to blackbox.log: $ENOENT$ (no-windows !)
354 warning: cannot write to blackbox.log: $TESTTMP/gone/.hg/blackbox.log: $ENOTDIR$ (windows !)
351 warning: cannot write to blackbox.log: $TESTTMP/gone/.hg/blackbox.log: $ENOTDIR$ (windows !)
355 $ cd ..
352 $ cd ..
356
353
357 blackbox should disable itself if track is empty
354 blackbox should disable itself if track is empty
358
355
359 $ hg --config blackbox.track= init nothing_tracked
356 $ hg --config blackbox.track= init nothing_tracked
360 $ cd nothing_tracked
357 $ cd nothing_tracked
361 $ cat >> .hg/hgrc << EOF
358 $ cat >> .hg/hgrc << EOF
362 > [blackbox]
359 > [blackbox]
363 > track =
360 > track =
364 > EOF
361 > EOF
365 $ hg blackbox
362 $ hg blackbox
366 $ cd $TESTTMP
363 $ cd $TESTTMP
367
364
368 a '*' entry in blackbox.track is interpreted as log everything
365 a '*' entry in blackbox.track is interpreted as log everything
369
366
370 $ hg --config blackbox.track='*' \
367 $ hg --config blackbox.track='*' \
371 > --config blackbox.logsource=True \
368 > --config blackbox.logsource=True \
372 > init track_star
369 > init track_star
373 $ cd track_star
370 $ cd track_star
374 $ cat >> .hg/hgrc << EOF
371 $ cat >> .hg/hgrc << EOF
375 > [blackbox]
372 > [blackbox]
376 > logsource = True
373 > logsource = True
377 > track = *
374 > track = *
378 > EOF
375 > EOF
379 (only look for entries with specific logged sources, otherwise this test is
376 (only look for entries with specific logged sources, otherwise this test is
380 pretty brittle)
377 pretty brittle)
381 $ hg blackbox | egrep '\[command(finish)?\]'
378 $ hg blackbox | egrep '\[command(finish)?\]'
382 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000) [commandfinish]> --config *blackbox.track=* --config *blackbox.logsource=True* init track_star exited 0 after * seconds (glob)
379 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000) [commandfinish]> --config *blackbox.track=* --config *blackbox.logsource=True* init track_star exited 0 after * seconds (glob)
383 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000) [command]> blackbox
380 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000) [command]> blackbox
384 $ cd $TESTTMP
381 $ cd $TESTTMP
385
382
386 #if chg
383 #if chg
387
384
388 when using chg, blackbox.log should get rotated correctly
385 when using chg, blackbox.log should get rotated correctly
389
386
390 $ cat > $TESTTMP/noop.py << EOF
387 $ cat > $TESTTMP/noop.py << EOF
391 > from __future__ import absolute_import
388 > from __future__ import absolute_import
392 > import time
389 > import time
393 > from mercurial import registrar, scmutil
390 > from mercurial import registrar, scmutil
394 > cmdtable = {}
391 > cmdtable = {}
395 > command = registrar.command(cmdtable)
392 > command = registrar.command(cmdtable)
396 > @command('noop')
393 > @command('noop')
397 > def noop(ui, repo):
394 > def noop(ui, repo):
398 > pass
395 > pass
399 > EOF
396 > EOF
400
397
401 $ hg init blackbox-chg
398 $ hg init blackbox-chg
402 $ cd blackbox-chg
399 $ cd blackbox-chg
403
400
404 $ cat > .hg/hgrc << EOF
401 $ cat > .hg/hgrc << EOF
405 > [blackbox]
402 > [blackbox]
406 > maxsize = 500B
403 > maxsize = 500B
407 > [extensions]
404 > [extensions]
408 > # extension change forces chg to restart
405 > # extension change forces chg to restart
409 > noop=$TESTTMP/noop.py
406 > noop=$TESTTMP/noop.py
410 > EOF
407 > EOF
411
408
412 $ "$PYTHON" -c 'print("a" * 400)' > .hg/blackbox.log
409 $ "$PYTHON" -c 'print("a" * 400)' > .hg/blackbox.log
413 $ chg noop
410 $ chg noop
414 $ chg noop
411 $ chg noop
415 $ chg noop
412 $ chg noop
416 $ chg noop
413 $ chg noop
417 $ chg noop
414 $ chg noop
418
415
419 $ cat > showsize.py << 'EOF'
416 $ cat > showsize.py << 'EOF'
420 > import os
417 > import os
421 > import sys
418 > import sys
422 > limit = 500
419 > limit = 500
423 > for p in sys.argv[1:]:
420 > for p in sys.argv[1:]:
424 > size = os.stat(p).st_size
421 > size = os.stat(p).st_size
425 > if size >= limit:
422 > if size >= limit:
426 > desc = '>='
423 > desc = '>='
427 > else:
424 > else:
428 > desc = '<'
425 > desc = '<'
429 > print('%s: %s %d' % (p, desc, limit))
426 > print('%s: %s %d' % (p, desc, limit))
430 > EOF
427 > EOF
431
428
432 $ "$PYTHON" showsize.py .hg/blackbox*
429 $ "$PYTHON" showsize.py .hg/blackbox*
433 .hg/blackbox.log: < 500
430 .hg/blackbox.log: < 500
434 .hg/blackbox.log.1: >= 500
431 .hg/blackbox.log.1: >= 500
435 .hg/blackbox.log.2: >= 500
432 .hg/blackbox.log.2: >= 500
436
433
437 $ cd ..
434 $ cd ..
438
435
439 With chg, blackbox should not create the log file if the repo is gone
436 With chg, blackbox should not create the log file if the repo is gone
440
437
441 $ hg init repo1
438 $ hg init repo1
442 $ hg --config extensions.a=! -R repo1 log
439 $ hg --config extensions.a=! -R repo1 log
443 $ rm -rf $TESTTMP/repo1
440 $ rm -rf $TESTTMP/repo1
444 $ hg --config extensions.a=! init repo1
441 $ hg --config extensions.a=! init repo1
445
442
446 #endif
443 #endif
447
444
448 blackbox should work if repo.ui.log is not called (issue5518)
445 blackbox should work if repo.ui.log is not called (issue5518)
449
446
450 $ cat > $TESTTMP/raise.py << EOF
447 $ cat > $TESTTMP/raise.py << EOF
451 > from __future__ import absolute_import
448 > from __future__ import absolute_import
452 > from mercurial import registrar, scmutil
449 > from mercurial import registrar, scmutil
453 > cmdtable = {}
450 > cmdtable = {}
454 > command = registrar.command(cmdtable)
451 > command = registrar.command(cmdtable)
455 > @command(b'raise')
452 > @command(b'raise')
456 > def raisecmd(*args):
453 > def raisecmd(*args):
457 > raise RuntimeError('raise')
454 > raise RuntimeError('raise')
458 > EOF
455 > EOF
459
456
460 $ cat >> $HGRCPATH << EOF
457 $ cat >> $HGRCPATH << EOF
461 > [blackbox]
458 > [blackbox]
462 > track = commandexception
459 > track = commandexception
463 > [extensions]
460 > [extensions]
464 > raise=$TESTTMP/raise.py
461 > raise=$TESTTMP/raise.py
465 > EOF
462 > EOF
466
463
467 $ hg init $TESTTMP/blackbox-exception-only
464 $ hg init $TESTTMP/blackbox-exception-only
468 $ cd $TESTTMP/blackbox-exception-only
465 $ cd $TESTTMP/blackbox-exception-only
469
466
470 #if chg
467 #if chg
471 (chg exits 255 because it fails to receive an exit code)
468 (chg exits 255 because it fails to receive an exit code)
472 $ hg raise 2>/dev/null
469 $ hg raise 2>/dev/null
473 [255]
470 [255]
474 #else
471 #else
475 (hg exits 1 because Python default exit code for uncaught exception is 1)
472 (hg exits 1 because Python default exit code for uncaught exception is 1)
476 $ hg raise 2>/dev/null
473 $ hg raise 2>/dev/null
477 [1]
474 [1]
478 #endif
475 #endif
479
476
480 $ head -1 .hg/blackbox.log
477 $ head -1 .hg/blackbox.log
481 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> ** Unknown exception encountered with possibly-broken third-party extension mock
478 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> ** Unknown exception encountered with possibly-broken third-party extension mock
482 $ tail -2 .hg/blackbox.log
479 $ tail -2 .hg/blackbox.log
483 RuntimeError: raise
480 RuntimeError: raise
484
481
General Comments 0
You need to be logged in to leave comments. Login now