Show More
@@ -1,141 +1,144 b'' | |||||
1 | # loggingutil.py - utility for logging events |
|
1 | # loggingutil.py - utility for logging events | |
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 | from __future__ import absolute_import |
|
9 | from __future__ import absolute_import | |
10 |
|
10 | |||
11 | import errno |
|
11 | import errno | |
12 |
|
12 | |||
13 |
from . import |
|
13 | from . import ( | |
|
14 | encoding, | |||
|
15 | pycompat, | |||
|
16 | ) | |||
14 |
|
17 | |||
15 | from .utils import ( |
|
18 | from .utils import ( | |
16 | dateutil, |
|
19 | dateutil, | |
17 | procutil, |
|
20 | procutil, | |
18 | stringutil, |
|
21 | stringutil, | |
19 | ) |
|
22 | ) | |
20 |
|
23 | |||
21 |
|
24 | |||
22 | def openlogfile(ui, vfs, name, maxfiles=0, maxsize=0): |
|
25 | def openlogfile(ui, vfs, name, maxfiles=0, maxsize=0): | |
23 | """Open log file in append mode, with optional rotation |
|
26 | """Open log file in append mode, with optional rotation | |
24 |
|
27 | |||
25 | If maxsize > 0, the log file will be rotated up to maxfiles. |
|
28 | If maxsize > 0, the log file will be rotated up to maxfiles. | |
26 | """ |
|
29 | """ | |
27 |
|
30 | |||
28 | def rotate(oldpath, newpath): |
|
31 | def rotate(oldpath, newpath): | |
29 | try: |
|
32 | try: | |
30 | vfs.unlink(newpath) |
|
33 | vfs.unlink(newpath) | |
31 | except OSError as err: |
|
34 | except OSError as err: | |
32 | if err.errno != errno.ENOENT: |
|
35 | if err.errno != errno.ENOENT: | |
33 | ui.debug( |
|
36 | ui.debug( | |
34 | b"warning: cannot remove '%s': %s\n" |
|
37 | b"warning: cannot remove '%s': %s\n" | |
35 | % (newpath, err.strerror) |
|
38 | % (newpath, encoding.strtolocal(err.strerror)) | |
36 | ) |
|
39 | ) | |
37 | try: |
|
40 | try: | |
38 | if newpath: |
|
41 | if newpath: | |
39 | vfs.rename(oldpath, newpath) |
|
42 | vfs.rename(oldpath, newpath) | |
40 | except OSError as err: |
|
43 | except OSError as err: | |
41 | if err.errno != errno.ENOENT: |
|
44 | if err.errno != errno.ENOENT: | |
42 | ui.debug( |
|
45 | ui.debug( | |
43 | b"warning: cannot rename '%s' to '%s': %s\n" |
|
46 | b"warning: cannot rename '%s' to '%s': %s\n" | |
44 | % (newpath, oldpath, err.strerror) |
|
47 | % (newpath, oldpath, encoding.strtolocal(err.strerror)) | |
45 | ) |
|
48 | ) | |
46 |
|
49 | |||
47 | if maxsize > 0: |
|
50 | if maxsize > 0: | |
48 | try: |
|
51 | try: | |
49 | st = vfs.stat(name) |
|
52 | st = vfs.stat(name) | |
50 | except OSError: |
|
53 | except OSError: | |
51 | pass |
|
54 | pass | |
52 | else: |
|
55 | else: | |
53 | if st.st_size >= maxsize: |
|
56 | if st.st_size >= maxsize: | |
54 | path = vfs.join(name) |
|
57 | path = vfs.join(name) | |
55 | for i in pycompat.xrange(maxfiles - 1, 1, -1): |
|
58 | for i in pycompat.xrange(maxfiles - 1, 1, -1): | |
56 | rotate( |
|
59 | rotate( | |
57 | oldpath=b'%s.%d' % (path, i - 1), |
|
60 | oldpath=b'%s.%d' % (path, i - 1), | |
58 | newpath=b'%s.%d' % (path, i), |
|
61 | newpath=b'%s.%d' % (path, i), | |
59 | ) |
|
62 | ) | |
60 | rotate(oldpath=path, newpath=maxfiles > 0 and path + b'.1') |
|
63 | rotate(oldpath=path, newpath=maxfiles > 0 and path + b'.1') | |
61 | return vfs(name, b'a', makeparentdirs=False) |
|
64 | return vfs(name, b'a', makeparentdirs=False) | |
62 |
|
65 | |||
63 |
|
66 | |||
64 | def _formatlogline(msg): |
|
67 | def _formatlogline(msg): | |
65 | date = dateutil.datestr(format=b'%Y/%m/%d %H:%M:%S') |
|
68 | date = dateutil.datestr(format=b'%Y/%m/%d %H:%M:%S') | |
66 | pid = procutil.getpid() |
|
69 | pid = procutil.getpid() | |
67 | return b'%s (%d)> %s' % (date, pid, msg) |
|
70 | return b'%s (%d)> %s' % (date, pid, msg) | |
68 |
|
71 | |||
69 |
|
72 | |||
70 | def _matchevent(event, tracked): |
|
73 | def _matchevent(event, tracked): | |
71 | return b'*' in tracked or event in tracked |
|
74 | return b'*' in tracked or event in tracked | |
72 |
|
75 | |||
73 |
|
76 | |||
74 | class filelogger(object): |
|
77 | class filelogger(object): | |
75 | """Basic logger backed by physical file with optional rotation""" |
|
78 | """Basic logger backed by physical file with optional rotation""" | |
76 |
|
79 | |||
77 | def __init__(self, vfs, name, tracked, maxfiles=0, maxsize=0): |
|
80 | def __init__(self, vfs, name, tracked, maxfiles=0, maxsize=0): | |
78 | self._vfs = vfs |
|
81 | self._vfs = vfs | |
79 | self._name = name |
|
82 | self._name = name | |
80 | self._trackedevents = set(tracked) |
|
83 | self._trackedevents = set(tracked) | |
81 | self._maxfiles = maxfiles |
|
84 | self._maxfiles = maxfiles | |
82 | self._maxsize = maxsize |
|
85 | self._maxsize = maxsize | |
83 |
|
86 | |||
84 | def tracked(self, event): |
|
87 | def tracked(self, event): | |
85 | return _matchevent(event, self._trackedevents) |
|
88 | return _matchevent(event, self._trackedevents) | |
86 |
|
89 | |||
87 | def log(self, ui, event, msg, opts): |
|
90 | def log(self, ui, event, msg, opts): | |
88 | line = _formatlogline(msg) |
|
91 | line = _formatlogline(msg) | |
89 | try: |
|
92 | try: | |
90 | with openlogfile( |
|
93 | with openlogfile( | |
91 | ui, |
|
94 | ui, | |
92 | self._vfs, |
|
95 | self._vfs, | |
93 | self._name, |
|
96 | self._name, | |
94 | maxfiles=self._maxfiles, |
|
97 | maxfiles=self._maxfiles, | |
95 | maxsize=self._maxsize, |
|
98 | maxsize=self._maxsize, | |
96 | ) as fp: |
|
99 | ) as fp: | |
97 | fp.write(line) |
|
100 | fp.write(line) | |
98 | except IOError as err: |
|
101 | except IOError as err: | |
99 | ui.debug( |
|
102 | ui.debug( | |
100 | b'cannot write to %s: %s\n' |
|
103 | b'cannot write to %s: %s\n' | |
101 | % (self._name, stringutil.forcebytestr(err)) |
|
104 | % (self._name, stringutil.forcebytestr(err)) | |
102 | ) |
|
105 | ) | |
103 |
|
106 | |||
104 |
|
107 | |||
105 | class fileobjectlogger(object): |
|
108 | class fileobjectlogger(object): | |
106 | """Basic logger backed by file-like object""" |
|
109 | """Basic logger backed by file-like object""" | |
107 |
|
110 | |||
108 | def __init__(self, fp, tracked): |
|
111 | def __init__(self, fp, tracked): | |
109 | self._fp = fp |
|
112 | self._fp = fp | |
110 | self._trackedevents = set(tracked) |
|
113 | self._trackedevents = set(tracked) | |
111 |
|
114 | |||
112 | def tracked(self, event): |
|
115 | def tracked(self, event): | |
113 | return _matchevent(event, self._trackedevents) |
|
116 | return _matchevent(event, self._trackedevents) | |
114 |
|
117 | |||
115 | def log(self, ui, event, msg, opts): |
|
118 | def log(self, ui, event, msg, opts): | |
116 | line = _formatlogline(msg) |
|
119 | line = _formatlogline(msg) | |
117 | try: |
|
120 | try: | |
118 | self._fp.write(line) |
|
121 | self._fp.write(line) | |
119 | self._fp.flush() |
|
122 | self._fp.flush() | |
120 | except IOError as err: |
|
123 | except IOError as err: | |
121 | ui.debug( |
|
124 | ui.debug( | |
122 | b'cannot write to %s: %s\n' |
|
125 | b'cannot write to %s: %s\n' | |
123 | % ( |
|
126 | % ( | |
124 | stringutil.forcebytestr(self._fp.name), |
|
127 | stringutil.forcebytestr(self._fp.name), | |
125 | stringutil.forcebytestr(err), |
|
128 | stringutil.forcebytestr(err), | |
126 | ) |
|
129 | ) | |
127 | ) |
|
130 | ) | |
128 |
|
131 | |||
129 |
|
132 | |||
130 | class proxylogger(object): |
|
133 | class proxylogger(object): | |
131 | """Forward log events to another logger to be set later""" |
|
134 | """Forward log events to another logger to be set later""" | |
132 |
|
135 | |||
133 | def __init__(self): |
|
136 | def __init__(self): | |
134 | self.logger = None |
|
137 | self.logger = None | |
135 |
|
138 | |||
136 | def tracked(self, event): |
|
139 | def tracked(self, event): | |
137 | return self.logger is not None and self.logger.tracked(event) |
|
140 | return self.logger is not None and self.logger.tracked(event) | |
138 |
|
141 | |||
139 | def log(self, ui, event, msg, opts): |
|
142 | def log(self, ui, event, msg, opts): | |
140 | assert self.logger is not None |
|
143 | assert self.logger is not None | |
141 | self.logger.log(ui, event, msg, opts) |
|
144 | self.logger.log(ui, event, msg, opts) |
@@ -1,488 +1,499 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 | > 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 abortcmd 2> /dev/null |
|
52 | $ hg abortcmd 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)> abortcmd exited 255 after * seconds (glob) |
|
55 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> abortcmd 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 | #if chg |
|
60 | #if chg | |
61 | (chg exits 255 because it fails to receive an exit code) |
|
61 | (chg exits 255 because it fails to receive an exit code) | |
62 | $ hg crash 2>/dev/null |
|
62 | $ hg crash 2>/dev/null | |
63 | [255] |
|
63 | [255] | |
64 | #else |
|
64 | #else | |
65 | (hg exits 1 because Python default exit code for uncaught exception is 1) |
|
65 | (hg exits 1 because Python default exit code for uncaught exception is 1) | |
66 | $ hg crash 2>/dev/null |
|
66 | $ hg crash 2>/dev/null | |
67 | [1] |
|
67 | [1] | |
68 | #endif |
|
68 | #endif | |
69 | $ hg blackbox -l 2 |
|
69 | $ hg blackbox -l 2 | |
70 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> crash exited 1 after * seconds (glob) |
|
70 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> crash exited 1 after * seconds (glob) | |
71 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox -l 2 |
|
71 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox -l 2 | |
72 |
|
72 | |||
73 | alias expansion is logged |
|
73 | alias expansion is logged | |
74 | $ rm ./.hg/blackbox.log |
|
74 | $ rm ./.hg/blackbox.log | |
75 | $ hg confuse |
|
75 | $ hg confuse | |
76 | $ hg blackbox |
|
76 | $ hg blackbox | |
77 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse |
|
77 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse | |
78 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3' |
|
78 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3' | |
79 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse exited 0 after * seconds (glob) |
|
79 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse exited 0 after * seconds (glob) | |
80 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox |
|
80 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox | |
81 |
|
81 | |||
82 | recursive aliases work correctly |
|
82 | recursive aliases work correctly | |
83 | $ rm ./.hg/blackbox.log |
|
83 | $ rm ./.hg/blackbox.log | |
84 | $ hg so-confusing |
|
84 | $ hg so-confusing | |
85 | $ hg blackbox |
|
85 | $ hg blackbox | |
86 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> so-confusing |
|
86 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> so-confusing | |
87 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'so-confusing' expands to 'confuse --style compact' |
|
87 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'so-confusing' expands to 'confuse --style compact' | |
88 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3' |
|
88 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3' | |
89 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> so-confusing exited 0 after * seconds (glob) |
|
89 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> so-confusing exited 0 after * seconds (glob) | |
90 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox |
|
90 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox | |
91 |
|
91 | |||
92 | custom date format |
|
92 | custom date format | |
93 | $ rm ./.hg/blackbox.log |
|
93 | $ rm ./.hg/blackbox.log | |
94 | $ hg --config blackbox.date-format='%Y-%m-%d @ %H:%M:%S' \ |
|
94 | $ hg --config blackbox.date-format='%Y-%m-%d @ %H:%M:%S' \ | |
95 | > --config devel.default-date='1334347993 0' --traceback status |
|
95 | > --config devel.default-date='1334347993 0' --traceback status | |
96 | A a |
|
96 | A a | |
97 | $ hg blackbox |
|
97 | $ hg blackbox | |
98 | 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) |
|
98 | 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) | |
99 | 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) |
|
99 | 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) | |
100 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox |
|
100 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox | |
101 |
|
101 | |||
102 | incoming change tracking |
|
102 | incoming change tracking | |
103 |
|
103 | |||
104 | create two heads to verify that we only see one change in the log later |
|
104 | create two heads to verify that we only see one change in the log later | |
105 | $ hg commit -ma |
|
105 | $ hg commit -ma | |
106 | $ hg up null |
|
106 | $ hg up null | |
107 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
107 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
108 | $ echo b > b |
|
108 | $ echo b > b | |
109 | $ hg commit -Amb |
|
109 | $ hg commit -Amb | |
110 | adding b |
|
110 | adding b | |
111 | created new head |
|
111 | created new head | |
112 |
|
112 | |||
113 | clone, commit, pull |
|
113 | clone, commit, pull | |
114 | $ hg clone . ../blackboxtest2 |
|
114 | $ hg clone . ../blackboxtest2 | |
115 | updating to branch default |
|
115 | updating to branch default | |
116 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
116 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
117 | $ echo c > c |
|
117 | $ echo c > c | |
118 | $ hg commit -Amc |
|
118 | $ hg commit -Amc | |
119 | adding c |
|
119 | adding c | |
120 | $ cd ../blackboxtest2 |
|
120 | $ cd ../blackboxtest2 | |
121 | $ hg pull |
|
121 | $ hg pull | |
122 | pulling from $TESTTMP/blackboxtest |
|
122 | pulling from $TESTTMP/blackboxtest | |
123 | searching for changes |
|
123 | searching for changes | |
124 | adding changesets |
|
124 | adding changesets | |
125 | adding manifests |
|
125 | adding manifests | |
126 | adding file changes |
|
126 | adding file changes | |
127 | added 1 changesets with 1 changes to 1 files |
|
127 | added 1 changesets with 1 changes to 1 files | |
128 | new changesets d02f48003e62 |
|
128 | new changesets d02f48003e62 | |
129 | (run 'hg update' to get a working copy) |
|
129 | (run 'hg update' to get a working copy) | |
130 | $ hg blackbox -l 6 |
|
130 | $ hg blackbox -l 6 | |
131 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote branch cache (served) with 1 labels and 2 nodes |
|
131 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote branch cache (served) with 1 labels and 2 nodes | |
132 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated branch cache (served.hidden) in * seconds (glob) |
|
132 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated branch cache (served.hidden) in * seconds (glob) | |
133 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote branch cache (served.hidden) with 1 labels and 2 nodes |
|
133 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote branch cache (served.hidden) with 1 labels and 2 nodes | |
134 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> 1 incoming changes - new heads: d02f48003e62 |
|
134 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> 1 incoming changes - new heads: d02f48003e62 | |
135 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull exited 0 after * seconds (glob) |
|
135 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull exited 0 after * seconds (glob) | |
136 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6 |
|
136 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6 | |
137 |
|
137 | |||
138 | we must not cause a failure if we cannot write to the log |
|
138 | we must not cause a failure if we cannot write to the log | |
139 |
|
139 | |||
140 | $ hg rollback |
|
140 | $ hg rollback | |
141 | repository tip rolled back to revision 1 (undo pull) |
|
141 | repository tip rolled back to revision 1 (undo pull) | |
142 |
|
142 | |||
143 | $ mv .hg/blackbox.log .hg/blackbox.log- |
|
143 | $ mv .hg/blackbox.log .hg/blackbox.log- | |
144 | $ mkdir .hg/blackbox.log |
|
144 | $ mkdir .hg/blackbox.log | |
145 | $ hg --debug incoming |
|
145 | $ hg --debug incoming | |
146 | warning: cannot write to blackbox.log: * (glob) |
|
146 | warning: cannot write to blackbox.log: * (glob) | |
147 | comparing with $TESTTMP/blackboxtest |
|
147 | comparing with $TESTTMP/blackboxtest | |
148 | query 1; heads |
|
148 | query 1; heads | |
149 | searching for changes |
|
149 | searching for changes | |
150 | all local changesets known remotely |
|
150 | all local changesets known remotely | |
151 | changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51 |
|
151 | changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51 | |
152 | tag: tip |
|
152 | tag: tip | |
153 | phase: draft |
|
153 | phase: draft | |
154 | parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06 |
|
154 | parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06 | |
155 | parent: -1:0000000000000000000000000000000000000000 |
|
155 | parent: -1:0000000000000000000000000000000000000000 | |
156 | manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892 |
|
156 | manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892 | |
157 | user: test |
|
157 | user: test | |
158 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
158 | date: Thu Jan 01 00:00:00 1970 +0000 | |
159 | files+: c |
|
159 | files+: c | |
160 | extra: branch=default |
|
160 | extra: branch=default | |
161 | description: |
|
161 | description: | |
162 | c |
|
162 | c | |
163 |
|
163 | |||
164 |
|
164 | |||
165 | $ hg pull |
|
165 | $ hg pull | |
166 | pulling from $TESTTMP/blackboxtest |
|
166 | pulling from $TESTTMP/blackboxtest | |
167 | searching for changes |
|
167 | searching for changes | |
168 | adding changesets |
|
168 | adding changesets | |
169 | adding manifests |
|
169 | adding manifests | |
170 | adding file changes |
|
170 | adding file changes | |
171 | added 1 changesets with 1 changes to 1 files |
|
171 | added 1 changesets with 1 changes to 1 files | |
172 | new changesets d02f48003e62 |
|
172 | new changesets d02f48003e62 | |
173 | (run 'hg update' to get a working copy) |
|
173 | (run 'hg update' to get a working copy) | |
174 |
|
174 | |||
175 | a failure reading from the log is fatal |
|
175 | a failure reading from the log is fatal | |
176 |
|
176 | |||
177 | $ hg blackbox -l 3 |
|
177 | $ hg blackbox -l 3 | |
178 | abort: *$TESTTMP/blackboxtest2/.hg/blackbox.log* (glob) |
|
178 | abort: *$TESTTMP/blackboxtest2/.hg/blackbox.log* (glob) | |
179 | [255] |
|
179 | [255] | |
180 |
|
180 | |||
181 | $ rmdir .hg/blackbox.log |
|
181 | $ rmdir .hg/blackbox.log | |
182 | $ mv .hg/blackbox.log- .hg/blackbox.log |
|
182 | $ mv .hg/blackbox.log- .hg/blackbox.log | |
183 |
|
183 | |||
184 | backup bundles get logged |
|
184 | backup bundles get logged | |
185 |
|
185 | |||
186 | $ touch d |
|
186 | $ touch d | |
187 | $ hg commit -Amd |
|
187 | $ hg commit -Amd | |
188 | adding d |
|
188 | adding d | |
189 | created new head |
|
189 | created new head | |
190 | $ hg strip tip |
|
190 | $ hg strip tip | |
191 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
191 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
192 | saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob) |
|
192 | saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob) | |
193 | $ hg blackbox -l 6 |
|
193 | $ hg blackbox -l 6 | |
194 | 1970/01/01 00:00:00 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip |
|
194 | 1970/01/01 00:00:00 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip | |
195 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg |
|
195 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg | |
196 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated branch cache (immutable) in * seconds (glob) |
|
196 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated branch cache (immutable) in * seconds (glob) | |
197 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote branch cache (immutable) with 1 labels and 2 nodes |
|
197 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote branch cache (immutable) with 1 labels and 2 nodes | |
198 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> strip tip exited 0 after * seconds (glob) |
|
198 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> strip tip exited 0 after * seconds (glob) | |
199 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6 |
|
199 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6 | |
200 |
|
200 | |||
201 | extension and python hooks - use the eol extension for a pythonhook |
|
201 | extension and python hooks - use the eol extension for a pythonhook | |
202 |
|
202 | |||
203 | $ echo '[extensions]' >> .hg/hgrc |
|
203 | $ echo '[extensions]' >> .hg/hgrc | |
204 | $ echo 'eol=' >> .hg/hgrc |
|
204 | $ echo 'eol=' >> .hg/hgrc | |
205 | $ echo '[hooks]' >> .hg/hgrc |
|
205 | $ echo '[hooks]' >> .hg/hgrc | |
206 | $ echo 'update = echo hooked' >> .hg/hgrc |
|
206 | $ echo 'update = echo hooked' >> .hg/hgrc | |
207 | $ hg update |
|
207 | $ hg update | |
208 | The fsmonitor extension is incompatible with the eol extension and has been disabled. (fsmonitor !) |
|
208 | The fsmonitor extension is incompatible with the eol extension and has been disabled. (fsmonitor !) | |
209 | hooked |
|
209 | hooked | |
210 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
210 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
211 | updated to "d02f48003e62: c" |
|
211 | updated to "d02f48003e62: c" | |
212 | 1 other heads for branch "default" |
|
212 | 1 other heads for branch "default" | |
213 | $ cat >> .hg/hgrc <<EOF |
|
213 | $ cat >> .hg/hgrc <<EOF | |
214 | > [extensions] |
|
214 | > [extensions] | |
215 | > # disable eol, because it is not needed for subsequent tests |
|
215 | > # disable eol, because it is not needed for subsequent tests | |
216 | > # (in addition, keeping it requires extra care for fsmonitor) |
|
216 | > # (in addition, keeping it requires extra care for fsmonitor) | |
217 | > eol=! |
|
217 | > eol=! | |
218 | > EOF |
|
218 | > EOF | |
219 | $ hg blackbox -l 5 |
|
219 | $ hg blackbox -l 5 | |
220 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> update (no-chg !) |
|
220 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> update (no-chg !) | |
221 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob) |
|
221 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob) | |
222 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> exthook-update: echo hooked finished in * seconds (glob) |
|
222 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> exthook-update: echo hooked finished in * seconds (glob) | |
223 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> update exited 0 after * seconds (glob) |
|
223 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> update exited 0 after * seconds (glob) | |
224 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> serve --cmdserver chgunix --address $TESTTMP.chgsock/server.* --daemon-postexec 'chdir:/' (glob) (chg !) |
|
224 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> serve --cmdserver chgunix --address $TESTTMP.chgsock/server.* --daemon-postexec 'chdir:/' (glob) (chg !) | |
225 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> blackbox -l 5 |
|
225 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> blackbox -l 5 | |
226 |
|
226 | |||
227 | log rotation |
|
227 | log rotation | |
228 |
|
228 | |||
229 | $ echo '[blackbox]' >> .hg/hgrc |
|
229 | $ echo '[blackbox]' >> .hg/hgrc | |
230 | $ echo 'maxsize = 20 b' >> .hg/hgrc |
|
230 | $ echo 'maxsize = 20 b' >> .hg/hgrc | |
231 | $ echo 'maxfiles = 3' >> .hg/hgrc |
|
231 | $ echo 'maxfiles = 3' >> .hg/hgrc | |
232 | $ hg status |
|
232 | $ hg status | |
233 | $ hg status |
|
233 | $ hg status | |
234 | $ hg status |
|
234 | $ hg status | |
235 | $ hg tip -q |
|
235 | $ hg tip -q | |
236 | 2:d02f48003e62 |
|
236 | 2:d02f48003e62 | |
237 | $ ls .hg/blackbox.log* |
|
237 | $ ls .hg/blackbox.log* | |
238 | .hg/blackbox.log |
|
238 | .hg/blackbox.log | |
239 | .hg/blackbox.log.1 |
|
239 | .hg/blackbox.log.1 | |
240 | .hg/blackbox.log.2 |
|
240 | .hg/blackbox.log.2 | |
241 | $ cd .. |
|
241 | $ cd .. | |
242 |
|
242 | |||
243 | $ hg init blackboxtest3 |
|
243 | $ hg init blackboxtest3 | |
244 | $ cd blackboxtest3 |
|
244 | $ cd blackboxtest3 | |
245 | $ hg blackbox |
|
245 | $ hg blackbox | |
246 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> init blackboxtest3 exited 0 after * seconds (glob) |
|
246 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> init blackboxtest3 exited 0 after * seconds (glob) | |
247 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox |
|
247 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox | |
248 | $ mv .hg/blackbox.log .hg/blackbox.log- |
|
248 | $ mv .hg/blackbox.log .hg/blackbox.log- | |
249 | $ mkdir .hg/blackbox.log |
|
249 | $ mkdir .hg/blackbox.log | |
250 | $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\ |
|
250 | $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\ | |
251 | > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\ |
|
251 | > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\ | |
252 | > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py |
|
252 | > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py | |
253 | $ "$PYTHON" $TESTDIR/blackbox-readonly-dispatch.py |
|
253 | $ "$PYTHON" $TESTDIR/blackbox-readonly-dispatch.py | |
254 | running: --debug add foo |
|
254 | running: --debug add foo | |
255 | warning: cannot write to blackbox.log: Is a directory (no-windows !) |
|
255 | warning: cannot write to blackbox.log: Is a directory (no-windows !) | |
256 | warning: cannot write to blackbox.log: $TESTTMP/blackboxtest3/.hg/blackbox.log: Access is denied (windows !) |
|
256 | warning: cannot write to blackbox.log: $TESTTMP/blackboxtest3/.hg/blackbox.log: Access is denied (windows !) | |
257 | adding foo |
|
257 | adding foo | |
258 | result: 0 |
|
258 | result: 0 | |
259 | running: --debug commit -m commit1 -d 2000-01-01 foo |
|
259 | running: --debug commit -m commit1 -d 2000-01-01 foo | |
260 | warning: cannot write to blackbox.log: Is a directory (no-windows !) |
|
260 | warning: cannot write to blackbox.log: Is a directory (no-windows !) | |
261 | warning: cannot write to blackbox.log: $TESTTMP/blackboxtest3/.hg/blackbox.log: Access is denied (windows !) |
|
261 | warning: cannot write to blackbox.log: $TESTTMP/blackboxtest3/.hg/blackbox.log: Access is denied (windows !) | |
262 | committing files: |
|
262 | committing files: | |
263 | foo |
|
263 | foo | |
264 | committing manifest |
|
264 | committing manifest | |
265 | committing changelog |
|
265 | committing changelog | |
266 | updating the branch cache |
|
266 | updating the branch cache | |
267 | committed changeset 0:0e46349438790c460c5c9f7546bfcd39b267bbd2 |
|
267 | committed changeset 0:0e46349438790c460c5c9f7546bfcd39b267bbd2 | |
268 | result: 0 |
|
268 | result: 0 | |
269 | running: --debug commit -m commit2 -d 2000-01-02 foo |
|
269 | running: --debug commit -m commit2 -d 2000-01-02 foo | |
270 | committing files: |
|
270 | committing files: | |
271 | foo |
|
271 | foo | |
272 | committing manifest |
|
272 | committing manifest | |
273 | committing changelog |
|
273 | committing changelog | |
274 | updating the branch cache |
|
274 | updating the branch cache | |
275 | committed changeset 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7 |
|
275 | committed changeset 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7 | |
276 | result: 0 |
|
276 | result: 0 | |
277 | running: --debug log -r 0 |
|
277 | running: --debug log -r 0 | |
278 | changeset: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2 |
|
278 | changeset: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2 | |
279 | phase: draft |
|
279 | phase: draft | |
280 | parent: -1:0000000000000000000000000000000000000000 |
|
280 | parent: -1:0000000000000000000000000000000000000000 | |
281 | parent: -1:0000000000000000000000000000000000000000 |
|
281 | parent: -1:0000000000000000000000000000000000000000 | |
282 | manifest: 0:9091aa5df980aea60860a2e39c95182e68d1ddec |
|
282 | manifest: 0:9091aa5df980aea60860a2e39c95182e68d1ddec | |
283 | user: test |
|
283 | user: test | |
284 | date: Sat Jan 01 00:00:00 2000 +0000 |
|
284 | date: Sat Jan 01 00:00:00 2000 +0000 | |
285 | files+: foo |
|
285 | files+: foo | |
286 | extra: branch=default |
|
286 | extra: branch=default | |
287 | description: |
|
287 | description: | |
288 | commit1 |
|
288 | commit1 | |
289 |
|
289 | |||
290 |
|
290 | |||
291 | result: 0 |
|
291 | result: 0 | |
292 | running: --debug log -r tip |
|
292 | running: --debug log -r tip | |
293 | changeset: 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7 |
|
293 | changeset: 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7 | |
294 | tag: tip |
|
294 | tag: tip | |
295 | phase: draft |
|
295 | phase: draft | |
296 | parent: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2 |
|
296 | parent: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2 | |
297 | parent: -1:0000000000000000000000000000000000000000 |
|
297 | parent: -1:0000000000000000000000000000000000000000 | |
298 | manifest: 1:895aa9b7886f89dd017a6d62524e1f9180b04df9 |
|
298 | manifest: 1:895aa9b7886f89dd017a6d62524e1f9180b04df9 | |
299 | user: test |
|
299 | user: test | |
300 | date: Sun Jan 02 00:00:00 2000 +0000 |
|
300 | date: Sun Jan 02 00:00:00 2000 +0000 | |
301 | files: foo |
|
301 | files: foo | |
302 | extra: branch=default |
|
302 | extra: branch=default | |
303 | description: |
|
303 | description: | |
304 | commit2 |
|
304 | commit2 | |
305 |
|
305 | |||
306 |
|
306 | |||
307 | result: 0 |
|
307 | result: 0 | |
308 | $ hg blackbox |
|
308 | $ hg blackbox | |
309 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updating the branch cache |
|
309 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updating the branch cache | |
310 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updated branch cache (served) in * seconds (glob) |
|
310 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updated branch cache (served) in * seconds (glob) | |
311 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> wrote branch cache (served) with 1 labels and 1 nodes |
|
311 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> wrote branch cache (served) with 1 labels and 1 nodes | |
312 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug commit -m commit2 -d 2000-01-02 foo exited 0 after *.?? seconds (glob) |
|
312 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug commit -m commit2 -d 2000-01-02 foo exited 0 after *.?? seconds (glob) | |
313 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r 0 |
|
313 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r 0 | |
314 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> writing .hg/cache/tags2-visible with 0 tags |
|
314 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> writing .hg/cache/tags2-visible with 0 tags | |
315 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r 0 exited 0 after *.?? seconds (glob) |
|
315 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r 0 exited 0 after *.?? seconds (glob) | |
316 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r tip |
|
316 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r tip | |
317 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r tip exited 0 after *.?? seconds (glob) |
|
317 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r tip exited 0 after *.?? seconds (glob) | |
318 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox |
|
318 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox | |
319 |
|
319 | |||
|
320 | Skip rotation if the .hg is read-only | |||
|
321 | ||||
|
322 | #if unix-permissions | |||
|
323 | $ chmod -w .hg | |||
|
324 | $ hg log -r. -T '{rev}\n' --config blackbox.maxsize=1 --debug | |||
|
325 | warning: cannot rename '$TESTTMP/blackboxtest3/.hg/blackbox.log.1' to '$TESTTMP/blackboxtest3/.hg/blackbox.log': Permission denied | |||
|
326 | warning: cannot write to blackbox.log: Permission denied | |||
|
327 | 1 | |||
|
328 | $ chmod +w .hg | |||
|
329 | #endif | |||
|
330 | ||||
320 | Test log recursion from dirty status check |
|
331 | Test log recursion from dirty status check | |
321 |
|
332 | |||
322 | $ cat > ../r.py <<EOF |
|
333 | $ cat > ../r.py <<EOF | |
323 | > from mercurial import context, error, extensions |
|
334 | > from mercurial import context, error, extensions | |
324 | > x=[False] |
|
335 | > x=[False] | |
325 | > def status(orig, *args, **opts): |
|
336 | > def status(orig, *args, **opts): | |
326 | > args[0].repo().ui.log(b"broken", b"recursion?") |
|
337 | > args[0].repo().ui.log(b"broken", b"recursion?") | |
327 | > return orig(*args, **opts) |
|
338 | > return orig(*args, **opts) | |
328 | > def reposetup(ui, repo): |
|
339 | > def reposetup(ui, repo): | |
329 | > extensions.wrapfunction(context.basectx, 'status', status) |
|
340 | > extensions.wrapfunction(context.basectx, 'status', status) | |
330 | > EOF |
|
341 | > EOF | |
331 | $ hg id --config extensions.x=../r.py --config blackbox.dirty=True |
|
342 | $ hg id --config extensions.x=../r.py --config blackbox.dirty=True | |
332 | 45589e459b2e tip |
|
343 | 45589e459b2e tip | |
333 |
|
344 | |||
334 | cleanup |
|
345 | cleanup | |
335 | $ cd .. |
|
346 | $ cd .. | |
336 |
|
347 | |||
337 | Test missing log directory, which shouldn't be created automatically |
|
348 | Test missing log directory, which shouldn't be created automatically | |
338 |
|
349 | |||
339 | $ cat <<'EOF' > closeremove.py |
|
350 | $ cat <<'EOF' > closeremove.py | |
340 | > def reposetup(ui, repo): |
|
351 | > def reposetup(ui, repo): | |
341 | > class rmrepo(repo.__class__): |
|
352 | > class rmrepo(repo.__class__): | |
342 | > def close(self): |
|
353 | > def close(self): | |
343 | > super(rmrepo, self).close() |
|
354 | > super(rmrepo, self).close() | |
344 | > self.ui.debug(b'removing %s\n' % self.vfs.base) |
|
355 | > self.ui.debug(b'removing %s\n' % self.vfs.base) | |
345 | > self.vfs.rmtree() |
|
356 | > self.vfs.rmtree() | |
346 | > repo.__class__ = rmrepo |
|
357 | > repo.__class__ = rmrepo | |
347 | > EOF |
|
358 | > EOF | |
348 |
|
359 | |||
349 | $ hg init gone |
|
360 | $ hg init gone | |
350 | $ cd gone |
|
361 | $ cd gone | |
351 | $ cat <<'EOF' > .hg/hgrc |
|
362 | $ cat <<'EOF' > .hg/hgrc | |
352 | > [extensions] |
|
363 | > [extensions] | |
353 | > closeremove = ../closeremove.py |
|
364 | > closeremove = ../closeremove.py | |
354 | > EOF |
|
365 | > EOF | |
355 | $ hg log --debug |
|
366 | $ hg log --debug | |
356 | removing $TESTTMP/gone/.hg |
|
367 | removing $TESTTMP/gone/.hg | |
357 | warning: cannot write to blackbox.log: $ENOENT$ (no-windows !) |
|
368 | warning: cannot write to blackbox.log: $ENOENT$ (no-windows !) | |
358 | warning: cannot write to blackbox.log: $TESTTMP/gone/.hg/blackbox.log: $ENOTDIR$ (windows !) |
|
369 | warning: cannot write to blackbox.log: $TESTTMP/gone/.hg/blackbox.log: $ENOTDIR$ (windows !) | |
359 | $ cd .. |
|
370 | $ cd .. | |
360 |
|
371 | |||
361 | blackbox should disable itself if track is empty |
|
372 | blackbox should disable itself if track is empty | |
362 |
|
373 | |||
363 | $ hg --config blackbox.track= init nothing_tracked |
|
374 | $ hg --config blackbox.track= init nothing_tracked | |
364 | $ cd nothing_tracked |
|
375 | $ cd nothing_tracked | |
365 | $ cat >> .hg/hgrc << EOF |
|
376 | $ cat >> .hg/hgrc << EOF | |
366 | > [blackbox] |
|
377 | > [blackbox] | |
367 | > track = |
|
378 | > track = | |
368 | > EOF |
|
379 | > EOF | |
369 | $ hg blackbox |
|
380 | $ hg blackbox | |
370 | $ cd $TESTTMP |
|
381 | $ cd $TESTTMP | |
371 |
|
382 | |||
372 | a '*' entry in blackbox.track is interpreted as log everything |
|
383 | a '*' entry in blackbox.track is interpreted as log everything | |
373 |
|
384 | |||
374 | $ hg --config blackbox.track='*' \ |
|
385 | $ hg --config blackbox.track='*' \ | |
375 | > --config blackbox.logsource=True \ |
|
386 | > --config blackbox.logsource=True \ | |
376 | > init track_star |
|
387 | > init track_star | |
377 | $ cd track_star |
|
388 | $ cd track_star | |
378 | $ cat >> .hg/hgrc << EOF |
|
389 | $ cat >> .hg/hgrc << EOF | |
379 | > [blackbox] |
|
390 | > [blackbox] | |
380 | > logsource = True |
|
391 | > logsource = True | |
381 | > track = * |
|
392 | > track = * | |
382 | > EOF |
|
393 | > EOF | |
383 | (only look for entries with specific logged sources, otherwise this test is |
|
394 | (only look for entries with specific logged sources, otherwise this test is | |
384 | pretty brittle) |
|
395 | pretty brittle) | |
385 | $ hg blackbox | egrep '\[command(finish)?\]' |
|
396 | $ hg blackbox | egrep '\[command(finish)?\]' | |
386 | 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) |
|
397 | 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) | |
387 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000) [command]> blackbox |
|
398 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000) [command]> blackbox | |
388 | $ cd $TESTTMP |
|
399 | $ cd $TESTTMP | |
389 |
|
400 | |||
390 | #if chg |
|
401 | #if chg | |
391 |
|
402 | |||
392 | when using chg, blackbox.log should get rotated correctly |
|
403 | when using chg, blackbox.log should get rotated correctly | |
393 |
|
404 | |||
394 | $ cat > $TESTTMP/noop.py << EOF |
|
405 | $ cat > $TESTTMP/noop.py << EOF | |
395 | > from __future__ import absolute_import |
|
406 | > from __future__ import absolute_import | |
396 | > import time |
|
407 | > import time | |
397 | > from mercurial import registrar, scmutil |
|
408 | > from mercurial import registrar, scmutil | |
398 | > cmdtable = {} |
|
409 | > cmdtable = {} | |
399 | > command = registrar.command(cmdtable) |
|
410 | > command = registrar.command(cmdtable) | |
400 | > @command(b'noop') |
|
411 | > @command(b'noop') | |
401 | > def noop(ui, repo): |
|
412 | > def noop(ui, repo): | |
402 | > pass |
|
413 | > pass | |
403 | > EOF |
|
414 | > EOF | |
404 |
|
415 | |||
405 | $ hg init blackbox-chg |
|
416 | $ hg init blackbox-chg | |
406 | $ cd blackbox-chg |
|
417 | $ cd blackbox-chg | |
407 |
|
418 | |||
408 | $ cat > .hg/hgrc << EOF |
|
419 | $ cat > .hg/hgrc << EOF | |
409 | > [blackbox] |
|
420 | > [blackbox] | |
410 | > maxsize = 500B |
|
421 | > maxsize = 500B | |
411 | > [extensions] |
|
422 | > [extensions] | |
412 | > # extension change forces chg to restart |
|
423 | > # extension change forces chg to restart | |
413 | > noop=$TESTTMP/noop.py |
|
424 | > noop=$TESTTMP/noop.py | |
414 | > EOF |
|
425 | > EOF | |
415 |
|
426 | |||
416 | $ "$PYTHON" -c 'print("a" * 400)' > .hg/blackbox.log |
|
427 | $ "$PYTHON" -c 'print("a" * 400)' > .hg/blackbox.log | |
417 | $ chg noop |
|
428 | $ chg noop | |
418 | $ chg noop |
|
429 | $ chg noop | |
419 | $ chg noop |
|
430 | $ chg noop | |
420 | $ chg noop |
|
431 | $ chg noop | |
421 | $ chg noop |
|
432 | $ chg noop | |
422 |
|
433 | |||
423 | $ cat > showsize.py << 'EOF' |
|
434 | $ cat > showsize.py << 'EOF' | |
424 | > import os |
|
435 | > import os | |
425 | > import sys |
|
436 | > import sys | |
426 | > limit = 500 |
|
437 | > limit = 500 | |
427 | > for p in sys.argv[1:]: |
|
438 | > for p in sys.argv[1:]: | |
428 | > size = os.stat(p).st_size |
|
439 | > size = os.stat(p).st_size | |
429 | > if size >= limit: |
|
440 | > if size >= limit: | |
430 | > desc = '>=' |
|
441 | > desc = '>=' | |
431 | > else: |
|
442 | > else: | |
432 | > desc = '<' |
|
443 | > desc = '<' | |
433 | > print('%s: %s %d' % (p, desc, limit)) |
|
444 | > print('%s: %s %d' % (p, desc, limit)) | |
434 | > EOF |
|
445 | > EOF | |
435 |
|
446 | |||
436 | $ "$PYTHON" showsize.py .hg/blackbox* |
|
447 | $ "$PYTHON" showsize.py .hg/blackbox* | |
437 | .hg/blackbox.log: < 500 |
|
448 | .hg/blackbox.log: < 500 | |
438 | .hg/blackbox.log.1: >= 500 |
|
449 | .hg/blackbox.log.1: >= 500 | |
439 | .hg/blackbox.log.2: >= 500 |
|
450 | .hg/blackbox.log.2: >= 500 | |
440 |
|
451 | |||
441 | $ cd .. |
|
452 | $ cd .. | |
442 |
|
453 | |||
443 | With chg, blackbox should not create the log file if the repo is gone |
|
454 | With chg, blackbox should not create the log file if the repo is gone | |
444 |
|
455 | |||
445 | $ hg init repo1 |
|
456 | $ hg init repo1 | |
446 | $ hg --config extensions.a=! -R repo1 log |
|
457 | $ hg --config extensions.a=! -R repo1 log | |
447 | $ rm -rf $TESTTMP/repo1 |
|
458 | $ rm -rf $TESTTMP/repo1 | |
448 | $ hg --config extensions.a=! init repo1 |
|
459 | $ hg --config extensions.a=! init repo1 | |
449 |
|
460 | |||
450 | #endif |
|
461 | #endif | |
451 |
|
462 | |||
452 | blackbox should work if repo.ui.log is not called (issue5518) |
|
463 | blackbox should work if repo.ui.log is not called (issue5518) | |
453 |
|
464 | |||
454 | $ cat > $TESTTMP/raise.py << EOF |
|
465 | $ cat > $TESTTMP/raise.py << EOF | |
455 | > from __future__ import absolute_import |
|
466 | > from __future__ import absolute_import | |
456 | > from mercurial import registrar, scmutil |
|
467 | > from mercurial import registrar, scmutil | |
457 | > cmdtable = {} |
|
468 | > cmdtable = {} | |
458 | > command = registrar.command(cmdtable) |
|
469 | > command = registrar.command(cmdtable) | |
459 | > @command(b'raise') |
|
470 | > @command(b'raise') | |
460 | > def raisecmd(*args): |
|
471 | > def raisecmd(*args): | |
461 | > raise RuntimeError('raise') |
|
472 | > raise RuntimeError('raise') | |
462 | > EOF |
|
473 | > EOF | |
463 |
|
474 | |||
464 | $ cat >> $HGRCPATH << EOF |
|
475 | $ cat >> $HGRCPATH << EOF | |
465 | > [blackbox] |
|
476 | > [blackbox] | |
466 | > track = commandexception |
|
477 | > track = commandexception | |
467 | > [extensions] |
|
478 | > [extensions] | |
468 | > raise=$TESTTMP/raise.py |
|
479 | > raise=$TESTTMP/raise.py | |
469 | > EOF |
|
480 | > EOF | |
470 |
|
481 | |||
471 | $ hg init $TESTTMP/blackbox-exception-only |
|
482 | $ hg init $TESTTMP/blackbox-exception-only | |
472 | $ cd $TESTTMP/blackbox-exception-only |
|
483 | $ cd $TESTTMP/blackbox-exception-only | |
473 |
|
484 | |||
474 | #if chg |
|
485 | #if chg | |
475 | (chg exits 255 because it fails to receive an exit code) |
|
486 | (chg exits 255 because it fails to receive an exit code) | |
476 | $ hg raise 2>/dev/null |
|
487 | $ hg raise 2>/dev/null | |
477 | [255] |
|
488 | [255] | |
478 | #else |
|
489 | #else | |
479 | (hg exits 1 because Python default exit code for uncaught exception is 1) |
|
490 | (hg exits 1 because Python default exit code for uncaught exception is 1) | |
480 | $ hg raise 2>/dev/null |
|
491 | $ hg raise 2>/dev/null | |
481 | [1] |
|
492 | [1] | |
482 | #endif |
|
493 | #endif | |
483 |
|
494 | |||
484 | $ head -1 .hg/blackbox.log |
|
495 | $ head -1 .hg/blackbox.log | |
485 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> ** Unknown exception encountered with possibly-broken third-party extension "mock" (version N/A) |
|
496 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> ** Unknown exception encountered with possibly-broken third-party extension "mock" (version N/A) | |
486 | $ tail -2 .hg/blackbox.log |
|
497 | $ tail -2 .hg/blackbox.log | |
487 | RuntimeError: raise |
|
498 | RuntimeError: raise | |
488 |
|
499 |
General Comments 0
You need to be logged in to leave comments.
Login now