Show More
@@ -1,265 +1,252 b'' | |||||
1 | # blackbox.py - log repository events to a file for post-mortem debugging |
|
1 | # blackbox.py - log repository events to a file for post-mortem debugging | |
2 | # |
|
2 | # | |
3 | # Copyright 2010 Nicolas Dumazet |
|
3 | # Copyright 2010 Nicolas Dumazet | |
4 | # Copyright 2013 Facebook, Inc. |
|
4 | # Copyright 2013 Facebook, Inc. | |
5 | # |
|
5 | # | |
6 | # This software may be used and distributed according to the terms of the |
|
6 | # This software may be used and distributed according to the terms of the | |
7 | # GNU General Public License version 2 or any later version. |
|
7 | # GNU General Public License version 2 or any later version. | |
8 |
|
8 | |||
9 | """log repository events to a blackbox for debugging |
|
9 | """log repository events to a blackbox for debugging | |
10 |
|
10 | |||
11 | Logs event information to .hg/blackbox.log to help debug and diagnose problems. |
|
11 | Logs event information to .hg/blackbox.log to help debug and diagnose problems. | |
12 | The events that get logged can be configured via the blackbox.track config key. |
|
12 | The events that get logged can be configured via the blackbox.track config key. | |
13 |
|
13 | |||
14 | Examples:: |
|
14 | Examples:: | |
15 |
|
15 | |||
16 | [blackbox] |
|
16 | [blackbox] | |
17 | track = * |
|
17 | track = * | |
18 | # dirty is *EXPENSIVE* (slow); |
|
18 | # dirty is *EXPENSIVE* (slow); | |
19 | # each log entry indicates `+` if the repository is dirty, like :hg:`id`. |
|
19 | # each log entry indicates `+` if the repository is dirty, like :hg:`id`. | |
20 | dirty = True |
|
20 | dirty = True | |
21 | # record the source of log messages |
|
21 | # record the source of log messages | |
22 | logsource = True |
|
22 | logsource = True | |
23 |
|
23 | |||
24 | [blackbox] |
|
24 | [blackbox] | |
25 | track = command, commandfinish, commandexception, exthook, pythonhook |
|
25 | track = command, commandfinish, commandexception, exthook, pythonhook | |
26 |
|
26 | |||
27 | [blackbox] |
|
27 | [blackbox] | |
28 | track = incoming |
|
28 | track = incoming | |
29 |
|
29 | |||
30 | [blackbox] |
|
30 | [blackbox] | |
31 | # limit the size of a log file |
|
31 | # limit the size of a log file | |
32 | maxsize = 1.5 MB |
|
32 | maxsize = 1.5 MB | |
33 | # rotate up to N log files when the current one gets too big |
|
33 | # rotate up to N log files when the current one gets too big | |
34 | maxfiles = 3 |
|
34 | maxfiles = 3 | |
35 |
|
35 | |||
36 | """ |
|
36 | """ | |
37 |
|
37 | |||
38 | from __future__ import absolute_import |
|
38 | from __future__ import absolute_import | |
39 |
|
39 | |||
40 | import errno |
|
40 | import errno | |
41 | import re |
|
41 | import re | |
42 |
|
42 | |||
43 | from mercurial.i18n import _ |
|
43 | from mercurial.i18n import _ | |
44 | from mercurial.node import hex |
|
44 | from mercurial.node import hex | |
45 |
|
45 | |||
46 | from mercurial import ( |
|
46 | from mercurial import ( | |
47 | registrar, |
|
47 | registrar, | |
48 | ui as uimod, |
|
48 | ui as uimod, | |
49 | util, |
|
49 | util, | |
50 | ) |
|
50 | ) | |
51 |
|
51 | |||
52 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
|
52 | # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for | |
53 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
|
53 | # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should | |
54 | # be specifying the version(s) of Mercurial they are tested with, or |
|
54 | # be specifying the version(s) of Mercurial they are tested with, or | |
55 | # leave the attribute unspecified. |
|
55 | # leave the attribute unspecified. | |
56 | testedwith = 'ships-with-hg-core' |
|
56 | testedwith = 'ships-with-hg-core' | |
57 |
|
57 | |||
58 | cmdtable = {} |
|
58 | cmdtable = {} | |
59 | command = registrar.command(cmdtable) |
|
59 | command = registrar.command(cmdtable) | |
60 |
|
60 | |||
61 | configtable = {} |
|
61 | configtable = {} | |
62 | configitem = registrar.configitem(configtable) |
|
62 | configitem = registrar.configitem(configtable) | |
63 |
|
63 | |||
64 | configitem('blackbox', 'dirty', |
|
64 | configitem('blackbox', 'dirty', | |
65 | default=False, |
|
65 | default=False, | |
66 | ) |
|
66 | ) | |
67 | configitem('blackbox', 'maxsize', |
|
67 | configitem('blackbox', 'maxsize', | |
68 | default='1 MB', |
|
68 | default='1 MB', | |
69 | ) |
|
69 | ) | |
70 | configitem('blackbox', 'logsource', |
|
70 | configitem('blackbox', 'logsource', | |
71 | default=False, |
|
71 | default=False, | |
72 | ) |
|
72 | ) | |
73 |
|
73 | |||
74 | lastui = None |
|
74 | lastui = None | |
75 |
|
75 | |||
76 | filehandles = {} |
|
|||
77 |
|
||||
78 | def _openlog(vfs): |
|
|||
79 | path = vfs.join('blackbox.log') |
|
|||
80 | if path in filehandles: |
|
|||
81 | return filehandles[path] |
|
|||
82 | filehandles[path] = fp = vfs('blackbox.log', 'a') |
|
|||
83 | return fp |
|
|||
84 |
|
||||
85 | def _closelog(vfs): |
|
|||
86 | path = vfs.join('blackbox.log') |
|
|||
87 | fp = filehandles[path] |
|
|||
88 | del filehandles[path] |
|
|||
89 | fp.close() |
|
|||
90 |
|
||||
91 | def wrapui(ui): |
|
76 | def wrapui(ui): | |
92 | class blackboxui(ui.__class__): |
|
77 | class blackboxui(ui.__class__): | |
93 | def __init__(self, src=None): |
|
78 | def __init__(self, src=None): | |
94 | super(blackboxui, self).__init__(src) |
|
79 | super(blackboxui, self).__init__(src) | |
95 | if src is None: |
|
80 | if src is None: | |
96 | self._partialinit() |
|
81 | self._partialinit() | |
97 | else: |
|
82 | else: | |
98 | self._bbfp = getattr(src, '_bbfp', None) |
|
83 | self._bbfp = getattr(src, '_bbfp', None) | |
99 | self._bbinlog = False |
|
84 | self._bbinlog = False | |
100 | self._bbrepo = getattr(src, '_bbrepo', None) |
|
85 | self._bbrepo = getattr(src, '_bbrepo', None) | |
101 | self._bbvfs = getattr(src, '_bbvfs', None) |
|
86 | self._bbvfs = getattr(src, '_bbvfs', None) | |
102 |
|
87 | |||
103 | def _partialinit(self): |
|
88 | def _partialinit(self): | |
104 | if util.safehasattr(self, '_bbvfs'): |
|
89 | if util.safehasattr(self, '_bbvfs'): | |
105 | return |
|
90 | return | |
106 | self._bbfp = None |
|
91 | self._bbfp = None | |
107 | self._bbinlog = False |
|
92 | self._bbinlog = False | |
108 | self._bbrepo = None |
|
93 | self._bbrepo = None | |
109 | self._bbvfs = None |
|
94 | self._bbvfs = None | |
110 |
|
95 | |||
111 | def copy(self): |
|
96 | def copy(self): | |
112 | self._partialinit() |
|
97 | self._partialinit() | |
113 | return self.__class__(self) |
|
98 | return self.__class__(self) | |
114 |
|
99 | |||
115 | @util.propertycache |
|
100 | @util.propertycache | |
116 | def track(self): |
|
101 | def track(self): | |
117 | return self.configlist('blackbox', 'track', ['*']) |
|
102 | return self.configlist('blackbox', 'track', ['*']) | |
118 |
|
103 | |||
119 | def _openlogfile(self): |
|
104 | def _openlogfile(self): | |
120 | def rotate(oldpath, newpath): |
|
105 | def rotate(oldpath, newpath): | |
121 | try: |
|
106 | try: | |
122 | self._bbvfs.unlink(newpath) |
|
107 | self._bbvfs.unlink(newpath) | |
123 | except OSError as err: |
|
108 | except OSError as err: | |
124 | if err.errno != errno.ENOENT: |
|
109 | if err.errno != errno.ENOENT: | |
125 | self.debug("warning: cannot remove '%s': %s\n" % |
|
110 | self.debug("warning: cannot remove '%s': %s\n" % | |
126 | (newpath, err.strerror)) |
|
111 | (newpath, err.strerror)) | |
127 | try: |
|
112 | try: | |
128 | if newpath: |
|
113 | if newpath: | |
129 | self._bbvfs.rename(oldpath, newpath) |
|
114 | self._bbvfs.rename(oldpath, newpath) | |
130 | except OSError as err: |
|
115 | except OSError as err: | |
131 | if err.errno != errno.ENOENT: |
|
116 | if err.errno != errno.ENOENT: | |
132 | self.debug("warning: cannot rename '%s' to '%s': %s\n" % |
|
117 | self.debug("warning: cannot rename '%s' to '%s': %s\n" % | |
133 | (newpath, oldpath, err.strerror)) |
|
118 | (newpath, oldpath, err.strerror)) | |
134 |
|
119 | |||
135 | fp = _openlog(self._bbvfs) |
|
|||
136 | maxsize = self.configbytes('blackbox', 'maxsize') |
|
120 | maxsize = self.configbytes('blackbox', 'maxsize') | |
|
121 | name = 'blackbox.log' | |||
137 | if maxsize > 0: |
|
122 | if maxsize > 0: | |
138 | st = self._bbvfs.fstat(fp) |
|
123 | try: | |
139 | if st.st_size >= maxsize: |
|
124 | st = self._bbvfs.stat(name) | |
140 | path = fp.name |
|
125 | except OSError: | |
141 |
|
|
126 | pass | |
142 | maxfiles = self.configint('blackbox', 'maxfiles', 7) |
|
127 | else: | |
143 |
f |
|
128 | if st.st_size >= maxsize: | |
144 | rotate(oldpath='%s.%d' % (path, i - 1), |
|
129 | path = self._bbvfs.join(name) | |
145 | newpath='%s.%d' % (path, i)) |
|
130 | maxfiles = self.configint('blackbox', 'maxfiles', 7) | |
146 | rotate(oldpath=path, |
|
131 | for i in xrange(maxfiles - 1, 1, -1): | |
147 |
|
|
132 | rotate(oldpath='%s.%d' % (path, i - 1), | |
148 | fp = _openlog(self._bbvfs) |
|
133 | newpath='%s.%d' % (path, i)) | |
149 | return fp |
|
134 | rotate(oldpath=path, | |
|
135 | newpath=maxfiles > 0 and path + '.1') | |||
|
136 | return self._bbvfs(name, 'a') | |||
150 |
|
137 | |||
151 | def _bbwrite(self, fmt, *args): |
|
138 | def _bbwrite(self, fmt, *args): | |
152 | self._bbfp.write(fmt % args) |
|
139 | self._bbfp.write(fmt % args) | |
153 | self._bbfp.flush() |
|
140 | self._bbfp.flush() | |
154 |
|
141 | |||
155 | def log(self, event, *msg, **opts): |
|
142 | def log(self, event, *msg, **opts): | |
156 | global lastui |
|
143 | global lastui | |
157 | super(blackboxui, self).log(event, *msg, **opts) |
|
144 | super(blackboxui, self).log(event, *msg, **opts) | |
158 | self._partialinit() |
|
145 | self._partialinit() | |
159 |
|
146 | |||
160 | if not '*' in self.track and not event in self.track: |
|
147 | if not '*' in self.track and not event in self.track: | |
161 | return |
|
148 | return | |
162 |
|
149 | |||
163 | if self._bbfp: |
|
150 | if self._bbfp: | |
164 | ui = self |
|
151 | ui = self | |
165 | elif self._bbvfs: |
|
152 | elif self._bbvfs: | |
166 | try: |
|
153 | try: | |
167 | self._bbfp = self._openlogfile() |
|
154 | self._bbfp = self._openlogfile() | |
168 | except (IOError, OSError) as err: |
|
155 | except (IOError, OSError) as err: | |
169 | self.debug('warning: cannot write to blackbox.log: %s\n' % |
|
156 | self.debug('warning: cannot write to blackbox.log: %s\n' % | |
170 | err.strerror) |
|
157 | err.strerror) | |
171 | del self._bbvfs |
|
158 | del self._bbvfs | |
172 | self._bbfp = None |
|
159 | self._bbfp = None | |
173 | ui = self |
|
160 | ui = self | |
174 | else: |
|
161 | else: | |
175 | # certain ui instances exist outside the context of |
|
162 | # certain ui instances exist outside the context of | |
176 | # a repo, so just default to the last blackbox that |
|
163 | # a repo, so just default to the last blackbox that | |
177 | # was seen. |
|
164 | # was seen. | |
178 | ui = lastui |
|
165 | ui = lastui | |
179 |
|
166 | |||
180 | if not ui or not ui._bbfp: |
|
167 | if not ui or not ui._bbfp: | |
181 | return |
|
168 | return | |
182 | if not lastui or ui._bbrepo: |
|
169 | if not lastui or ui._bbrepo: | |
183 | lastui = ui |
|
170 | lastui = ui | |
184 | if ui._bbinlog: |
|
171 | if ui._bbinlog: | |
185 | # recursion guard |
|
172 | # recursion guard | |
186 | return |
|
173 | return | |
187 | try: |
|
174 | try: | |
188 | ui._bbinlog = True |
|
175 | ui._bbinlog = True | |
189 | default = self.configdate('devel', 'default-date') |
|
176 | default = self.configdate('devel', 'default-date') | |
190 | date = util.datestr(default, '%Y/%m/%d %H:%M:%S') |
|
177 | date = util.datestr(default, '%Y/%m/%d %H:%M:%S') | |
191 | user = util.getuser() |
|
178 | user = util.getuser() | |
192 | pid = '%d' % util.getpid() |
|
179 | pid = '%d' % util.getpid() | |
193 | formattedmsg = msg[0] % msg[1:] |
|
180 | formattedmsg = msg[0] % msg[1:] | |
194 | rev = '(unknown)' |
|
181 | rev = '(unknown)' | |
195 | changed = '' |
|
182 | changed = '' | |
196 | if ui._bbrepo: |
|
183 | if ui._bbrepo: | |
197 | ctx = ui._bbrepo[None] |
|
184 | ctx = ui._bbrepo[None] | |
198 | parents = ctx.parents() |
|
185 | parents = ctx.parents() | |
199 | rev = ('+'.join([hex(p.node()) for p in parents])) |
|
186 | rev = ('+'.join([hex(p.node()) for p in parents])) | |
200 | if (ui.configbool('blackbox', 'dirty') and |
|
187 | if (ui.configbool('blackbox', 'dirty') and | |
201 | ctx.dirty(missing=True, merge=False, branch=False)): |
|
188 | ctx.dirty(missing=True, merge=False, branch=False)): | |
202 | changed = '+' |
|
189 | changed = '+' | |
203 | if ui.configbool('blackbox', 'logsource'): |
|
190 | if ui.configbool('blackbox', 'logsource'): | |
204 | src = ' [%s]' % event |
|
191 | src = ' [%s]' % event | |
205 | else: |
|
192 | else: | |
206 | src = '' |
|
193 | src = '' | |
207 | try: |
|
194 | try: | |
208 | ui._bbwrite('%s %s @%s%s (%s)%s> %s', |
|
195 | ui._bbwrite('%s %s @%s%s (%s)%s> %s', | |
209 | date, user, rev, changed, pid, src, formattedmsg) |
|
196 | date, user, rev, changed, pid, src, formattedmsg) | |
210 | except IOError as err: |
|
197 | except IOError as err: | |
211 | self.debug('warning: cannot write to blackbox.log: %s\n' % |
|
198 | self.debug('warning: cannot write to blackbox.log: %s\n' % | |
212 | err.strerror) |
|
199 | err.strerror) | |
213 | finally: |
|
200 | finally: | |
214 | ui._bbinlog = False |
|
201 | ui._bbinlog = False | |
215 |
|
202 | |||
216 | def setrepo(self, repo): |
|
203 | def setrepo(self, repo): | |
217 | self._bbfp = None |
|
204 | self._bbfp = None | |
218 | self._bbinlog = False |
|
205 | self._bbinlog = False | |
219 | self._bbrepo = repo |
|
206 | self._bbrepo = repo | |
220 | self._bbvfs = repo.vfs |
|
207 | self._bbvfs = repo.vfs | |
221 |
|
208 | |||
222 | ui.__class__ = blackboxui |
|
209 | ui.__class__ = blackboxui | |
223 | uimod.ui = blackboxui |
|
210 | uimod.ui = blackboxui | |
224 |
|
211 | |||
225 | def uisetup(ui): |
|
212 | def uisetup(ui): | |
226 | wrapui(ui) |
|
213 | wrapui(ui) | |
227 |
|
214 | |||
228 | def reposetup(ui, repo): |
|
215 | def reposetup(ui, repo): | |
229 | # During 'hg pull' a httppeer repo is created to represent the remote repo. |
|
216 | # During 'hg pull' a httppeer repo is created to represent the remote repo. | |
230 | # It doesn't have a .hg directory to put a blackbox in, so we don't do |
|
217 | # It doesn't have a .hg directory to put a blackbox in, so we don't do | |
231 | # the blackbox setup for it. |
|
218 | # the blackbox setup for it. | |
232 | if not repo.local(): |
|
219 | if not repo.local(): | |
233 | return |
|
220 | return | |
234 |
|
221 | |||
235 | if util.safehasattr(ui, 'setrepo'): |
|
222 | if util.safehasattr(ui, 'setrepo'): | |
236 | ui.setrepo(repo) |
|
223 | ui.setrepo(repo) | |
237 | repo._wlockfreeprefix.add('blackbox.log') |
|
224 | repo._wlockfreeprefix.add('blackbox.log') | |
238 |
|
225 | |||
239 | @command('^blackbox', |
|
226 | @command('^blackbox', | |
240 | [('l', 'limit', 10, _('the number of events to show')), |
|
227 | [('l', 'limit', 10, _('the number of events to show')), | |
241 | ], |
|
228 | ], | |
242 | _('hg blackbox [OPTION]...')) |
|
229 | _('hg blackbox [OPTION]...')) | |
243 | def blackbox(ui, repo, *revs, **opts): |
|
230 | def blackbox(ui, repo, *revs, **opts): | |
244 | '''view the recent repository events |
|
231 | '''view the recent repository events | |
245 | ''' |
|
232 | ''' | |
246 |
|
233 | |||
247 | if not repo.vfs.exists('blackbox.log'): |
|
234 | if not repo.vfs.exists('blackbox.log'): | |
248 | return |
|
235 | return | |
249 |
|
236 | |||
250 | limit = opts.get('limit') |
|
237 | limit = opts.get('limit') | |
251 | fp = repo.vfs('blackbox.log', 'r') |
|
238 | fp = repo.vfs('blackbox.log', 'r') | |
252 | lines = fp.read().split('\n') |
|
239 | lines = fp.read().split('\n') | |
253 |
|
240 | |||
254 | count = 0 |
|
241 | count = 0 | |
255 | output = [] |
|
242 | output = [] | |
256 | for line in reversed(lines): |
|
243 | for line in reversed(lines): | |
257 | if count >= limit: |
|
244 | if count >= limit: | |
258 | break |
|
245 | break | |
259 |
|
246 | |||
260 | # count the commands by matching lines like: 2013/01/23 19:13:36 root> |
|
247 | # count the commands by matching lines like: 2013/01/23 19:13:36 root> | |
261 | if re.match('^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} .*> .*', line): |
|
248 | if re.match('^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} .*> .*', line): | |
262 | count += 1 |
|
249 | count += 1 | |
263 | output.append(line) |
|
250 | output.append(line) | |
264 |
|
251 | |||
265 | ui.status('\n'.join(reversed(output))) |
|
252 | ui.status('\n'.join(reversed(output))) |
@@ -1,232 +1,286 b'' | |||||
1 | setup |
|
1 | setup | |
2 | $ cat >> $HGRCPATH <<EOF |
|
2 | $ cat >> $HGRCPATH <<EOF | |
3 | > [extensions] |
|
3 | > [extensions] | |
4 | > blackbox= |
|
4 | > blackbox= | |
5 | > mock=$TESTDIR/mockblackbox.py |
|
5 | > mock=$TESTDIR/mockblackbox.py | |
6 | > mq= |
|
6 | > mq= | |
7 | > [alias] |
|
7 | > [alias] | |
8 | > confuse = log --limit 3 |
|
8 | > confuse = log --limit 3 | |
9 | > EOF |
|
9 | > EOF | |
10 | $ hg init blackboxtest |
|
10 | $ hg init blackboxtest | |
11 | $ cd blackboxtest |
|
11 | $ cd blackboxtest | |
12 |
|
12 | |||
13 | command, exit codes, and duration |
|
13 | command, exit codes, and duration | |
14 |
|
14 | |||
15 | $ echo a > a |
|
15 | $ echo a > a | |
16 | $ hg add a |
|
16 | $ hg add a | |
17 | $ hg blackbox --config blackbox.dirty=True |
|
17 | $ hg blackbox --config blackbox.dirty=True | |
18 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a |
|
18 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a | |
19 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob) |
|
19 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob) | |
20 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox |
|
20 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox | |
21 |
|
21 | |||
22 | alias expansion is logged |
|
22 | alias expansion is logged | |
23 | $ hg confuse |
|
23 | $ hg confuse | |
24 | $ hg blackbox |
|
24 | $ hg blackbox | |
25 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a |
|
25 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a | |
26 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob) |
|
26 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob) | |
27 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox |
|
27 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox | |
28 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox --config *blackbox.dirty=True* exited 0 after * seconds (glob) |
|
28 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox --config *blackbox.dirty=True* exited 0 after * seconds (glob) | |
29 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse |
|
29 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse | |
30 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3' |
|
30 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3' | |
31 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse exited 0 after * seconds (glob) |
|
31 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse exited 0 after * seconds (glob) | |
32 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox |
|
32 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox | |
33 |
|
33 | |||
34 | incoming change tracking |
|
34 | incoming change tracking | |
35 |
|
35 | |||
36 | create two heads to verify that we only see one change in the log later |
|
36 | create two heads to verify that we only see one change in the log later | |
37 | $ hg commit -ma |
|
37 | $ hg commit -ma | |
38 | $ hg up null |
|
38 | $ hg up null | |
39 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
39 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
40 | $ echo b > b |
|
40 | $ echo b > b | |
41 | $ hg commit -Amb |
|
41 | $ hg commit -Amb | |
42 | adding b |
|
42 | adding b | |
43 | created new head |
|
43 | created new head | |
44 |
|
44 | |||
45 | clone, commit, pull |
|
45 | clone, commit, pull | |
46 | $ hg clone . ../blackboxtest2 |
|
46 | $ hg clone . ../blackboxtest2 | |
47 | updating to branch default |
|
47 | updating to branch default | |
48 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
48 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
49 | $ echo c > c |
|
49 | $ echo c > c | |
50 | $ hg commit -Amc |
|
50 | $ hg commit -Amc | |
51 | adding c |
|
51 | adding c | |
52 | $ cd ../blackboxtest2 |
|
52 | $ cd ../blackboxtest2 | |
53 | $ hg pull |
|
53 | $ hg pull | |
54 | pulling from $TESTTMP/blackboxtest (glob) |
|
54 | pulling from $TESTTMP/blackboxtest (glob) | |
55 | searching for changes |
|
55 | searching for changes | |
56 | adding changesets |
|
56 | adding changesets | |
57 | adding manifests |
|
57 | adding manifests | |
58 | adding file changes |
|
58 | adding file changes | |
59 | added 1 changesets with 1 changes to 1 files |
|
59 | added 1 changesets with 1 changes to 1 files | |
60 | (run 'hg update' to get a working copy) |
|
60 | (run 'hg update' to get a working copy) | |
61 | $ hg blackbox -l 6 |
|
61 | $ hg blackbox -l 6 | |
62 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull |
|
62 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull | |
63 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated served branch cache in * seconds (glob) |
|
63 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated served branch cache in * seconds (glob) | |
64 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote served branch cache with 1 labels and 2 nodes |
|
64 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote served branch cache with 1 labels and 2 nodes | |
65 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> 1 incoming changes - new heads: d02f48003e62 |
|
65 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> 1 incoming changes - new heads: d02f48003e62 | |
66 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull exited 0 after * seconds (glob) |
|
66 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull exited 0 after * seconds (glob) | |
67 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6 |
|
67 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6 | |
68 |
|
68 | |||
69 | we must not cause a failure if we cannot write to the log |
|
69 | we must not cause a failure if we cannot write to the log | |
70 |
|
70 | |||
71 | $ hg rollback |
|
71 | $ hg rollback | |
72 | repository tip rolled back to revision 1 (undo pull) |
|
72 | repository tip rolled back to revision 1 (undo pull) | |
73 |
|
73 | |||
74 | $ mv .hg/blackbox.log .hg/blackbox.log- |
|
74 | $ mv .hg/blackbox.log .hg/blackbox.log- | |
75 | $ mkdir .hg/blackbox.log |
|
75 | $ mkdir .hg/blackbox.log | |
76 | $ hg --debug incoming |
|
76 | $ hg --debug incoming | |
77 | warning: cannot write to blackbox.log: * (glob) |
|
77 | warning: cannot write to blackbox.log: * (glob) | |
78 | comparing with $TESTTMP/blackboxtest (glob) |
|
78 | comparing with $TESTTMP/blackboxtest (glob) | |
79 | query 1; heads |
|
79 | query 1; heads | |
80 | searching for changes |
|
80 | searching for changes | |
81 | all local heads known remotely |
|
81 | all local heads known remotely | |
82 | changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51 |
|
82 | changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51 | |
83 | tag: tip |
|
83 | tag: tip | |
84 | phase: draft |
|
84 | phase: draft | |
85 | parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06 |
|
85 | parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06 | |
86 | parent: -1:0000000000000000000000000000000000000000 |
|
86 | parent: -1:0000000000000000000000000000000000000000 | |
87 | manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892 |
|
87 | manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892 | |
88 | user: test |
|
88 | user: test | |
89 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
89 | date: Thu Jan 01 00:00:00 1970 +0000 | |
90 | files+: c |
|
90 | files+: c | |
91 | extra: branch=default |
|
91 | extra: branch=default | |
92 | description: |
|
92 | description: | |
93 | c |
|
93 | c | |
94 |
|
94 | |||
95 |
|
95 | |||
96 | $ hg pull |
|
96 | $ hg pull | |
97 | pulling from $TESTTMP/blackboxtest (glob) |
|
97 | pulling from $TESTTMP/blackboxtest (glob) | |
98 | searching for changes |
|
98 | searching for changes | |
99 | adding changesets |
|
99 | adding changesets | |
100 | adding manifests |
|
100 | adding manifests | |
101 | adding file changes |
|
101 | adding file changes | |
102 | added 1 changesets with 1 changes to 1 files |
|
102 | added 1 changesets with 1 changes to 1 files | |
103 | (run 'hg update' to get a working copy) |
|
103 | (run 'hg update' to get a working copy) | |
104 |
|
104 | |||
105 | a failure reading from the log is fatal |
|
105 | a failure reading from the log is fatal | |
106 |
|
106 | |||
107 | $ hg blackbox -l 3 |
|
107 | $ hg blackbox -l 3 | |
108 | abort: *$TESTTMP/blackboxtest2/.hg/blackbox.log* (glob) |
|
108 | abort: *$TESTTMP/blackboxtest2/.hg/blackbox.log* (glob) | |
109 | [255] |
|
109 | [255] | |
110 |
|
110 | |||
111 | $ rmdir .hg/blackbox.log |
|
111 | $ rmdir .hg/blackbox.log | |
112 | $ mv .hg/blackbox.log- .hg/blackbox.log |
|
112 | $ mv .hg/blackbox.log- .hg/blackbox.log | |
113 |
|
113 | |||
114 | backup bundles get logged |
|
114 | backup bundles get logged | |
115 |
|
115 | |||
116 | $ touch d |
|
116 | $ touch d | |
117 | $ hg commit -Amd |
|
117 | $ hg commit -Amd | |
118 | adding d |
|
118 | adding d | |
119 | created new head |
|
119 | created new head | |
120 | $ hg strip tip |
|
120 | $ hg strip tip | |
121 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
121 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved | |
122 | saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob) |
|
122 | saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob) | |
123 | $ hg blackbox -l 6 |
|
123 | $ hg blackbox -l 6 | |
124 | 1970/01/01 00:00:00 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip |
|
124 | 1970/01/01 00:00:00 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip | |
125 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg (glob) |
|
125 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg (glob) | |
126 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated base branch cache in * seconds (glob) |
|
126 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated base branch cache in * seconds (glob) | |
127 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote base branch cache with 1 labels and 2 nodes |
|
127 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote base branch cache with 1 labels and 2 nodes | |
128 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> strip tip exited 0 after * seconds (glob) |
|
128 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> strip tip exited 0 after * seconds (glob) | |
129 | 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 | |
130 |
|
130 | |||
131 | extension and python hooks - use the eol extension for a pythonhook |
|
131 | extension and python hooks - use the eol extension for a pythonhook | |
132 |
|
132 | |||
133 | $ echo '[extensions]' >> .hg/hgrc |
|
133 | $ echo '[extensions]' >> .hg/hgrc | |
134 | $ echo 'eol=' >> .hg/hgrc |
|
134 | $ echo 'eol=' >> .hg/hgrc | |
135 | $ echo '[hooks]' >> .hg/hgrc |
|
135 | $ echo '[hooks]' >> .hg/hgrc | |
136 | $ echo 'update = echo hooked' >> .hg/hgrc |
|
136 | $ echo 'update = echo hooked' >> .hg/hgrc | |
137 | $ hg update |
|
137 | $ hg update | |
138 | The fsmonitor extension is incompatible with the eol extension and has been disabled. (fsmonitor !) |
|
138 | The fsmonitor extension is incompatible with the eol extension and has been disabled. (fsmonitor !) | |
139 | hooked |
|
139 | hooked | |
140 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
140 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
141 | updated to "d02f48003e62: c" |
|
141 | updated to "d02f48003e62: c" | |
142 | 1 other heads for branch "default" |
|
142 | 1 other heads for branch "default" | |
143 | $ cat >> .hg/hgrc <<EOF |
|
143 | $ cat >> .hg/hgrc <<EOF | |
144 | > [extensions] |
|
144 | > [extensions] | |
145 | > # disable eol, because it is not needed for subsequent tests |
|
145 | > # disable eol, because it is not needed for subsequent tests | |
146 | > # (in addition, keeping it requires extra care for fsmonitor) |
|
146 | > # (in addition, keeping it requires extra care for fsmonitor) | |
147 | > eol=! |
|
147 | > eol=! | |
148 | > EOF |
|
148 | > EOF | |
149 | $ hg blackbox -l 6 |
|
149 | $ hg blackbox -l 6 | |
150 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> update (no-chg !) |
|
150 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> update (no-chg !) | |
151 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> writing .hg/cache/tags2-visible with 0 tags |
|
151 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> writing .hg/cache/tags2-visible with 0 tags | |
152 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob) |
|
152 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob) | |
153 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> exthook-update: echo hooked finished in * seconds (glob) |
|
153 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> exthook-update: echo hooked finished in * seconds (glob) | |
154 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> update exited 0 after * seconds (glob) |
|
154 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> update exited 0 after * seconds (glob) | |
155 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> serve --cmdserver chgunix --address $TESTTMP.chgsock/server.* --daemon-postexec 'chdir:/' (glob) (chg !) |
|
155 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> serve --cmdserver chgunix --address $TESTTMP.chgsock/server.* --daemon-postexec 'chdir:/' (glob) (chg !) | |
156 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> blackbox -l 6 |
|
156 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> blackbox -l 6 | |
157 |
|
157 | |||
158 | log rotation |
|
158 | log rotation | |
159 |
|
159 | |||
160 | $ echo '[blackbox]' >> .hg/hgrc |
|
160 | $ echo '[blackbox]' >> .hg/hgrc | |
161 | $ echo 'maxsize = 20 b' >> .hg/hgrc |
|
161 | $ echo 'maxsize = 20 b' >> .hg/hgrc | |
162 | $ echo 'maxfiles = 3' >> .hg/hgrc |
|
162 | $ echo 'maxfiles = 3' >> .hg/hgrc | |
163 | $ hg status |
|
163 | $ hg status | |
164 | $ hg status |
|
164 | $ hg status | |
165 | $ hg status |
|
165 | $ hg status | |
166 | $ hg tip -q |
|
166 | $ hg tip -q | |
167 | 2:d02f48003e62 |
|
167 | 2:d02f48003e62 | |
168 | $ ls .hg/blackbox.log* |
|
168 | $ ls .hg/blackbox.log* | |
169 | .hg/blackbox.log |
|
169 | .hg/blackbox.log | |
170 | .hg/blackbox.log.1 |
|
170 | .hg/blackbox.log.1 | |
171 | .hg/blackbox.log.2 |
|
171 | .hg/blackbox.log.2 | |
172 | $ cd .. |
|
172 | $ cd .. | |
173 |
|
173 | |||
174 | $ hg init blackboxtest3 |
|
174 | $ hg init blackboxtest3 | |
175 | $ cd blackboxtest3 |
|
175 | $ cd blackboxtest3 | |
176 | $ hg blackbox |
|
176 | $ hg blackbox | |
177 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox |
|
177 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox | |
178 | $ mv .hg/blackbox.log .hg/blackbox.log- |
|
178 | $ mv .hg/blackbox.log .hg/blackbox.log- | |
179 | $ mkdir .hg/blackbox.log |
|
179 | $ mkdir .hg/blackbox.log | |
180 | $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\ |
|
180 | $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\ | |
181 | > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\ |
|
181 | > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\ | |
182 | > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py |
|
182 | > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py | |
183 | $ $PYTHON $TESTDIR/blackbox-readonly-dispatch.py |
|
183 | $ $PYTHON $TESTDIR/blackbox-readonly-dispatch.py | |
184 | running: add foo |
|
184 | running: add foo | |
185 | result: 0 |
|
185 | result: 0 | |
186 | running: commit -m commit1 -d 2000-01-01 foo |
|
186 | running: commit -m commit1 -d 2000-01-01 foo | |
187 | result: None |
|
187 | result: None | |
188 | running: commit -m commit2 -d 2000-01-02 foo |
|
188 | running: commit -m commit2 -d 2000-01-02 foo | |
189 | result: None |
|
189 | result: None | |
190 | running: log -r 0 |
|
190 | running: log -r 0 | |
191 | changeset: 0:0e4634943879 |
|
191 | changeset: 0:0e4634943879 | |
192 | user: test |
|
192 | user: test | |
193 | date: Sat Jan 01 00:00:00 2000 +0000 |
|
193 | date: Sat Jan 01 00:00:00 2000 +0000 | |
194 | summary: commit1 |
|
194 | summary: commit1 | |
195 |
|
195 | |||
196 | result: None |
|
196 | result: None | |
197 | running: log -r tip |
|
197 | running: log -r tip | |
198 | changeset: 1:45589e459b2e |
|
198 | changeset: 1:45589e459b2e | |
199 | tag: tip |
|
199 | tag: tip | |
200 | user: test |
|
200 | user: test | |
201 | date: Sun Jan 02 00:00:00 2000 +0000 |
|
201 | date: Sun Jan 02 00:00:00 2000 +0000 | |
202 | summary: commit2 |
|
202 | summary: commit2 | |
203 |
|
203 | |||
204 | result: None |
|
204 | result: None | |
205 | $ hg blackbox |
|
205 | $ hg blackbox | |
206 | 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> commit -m commit2 -d 2000-01-02 foo |
|
206 | 1970/01/01 00:00:00 bob @0e46349438790c460c5c9f7546bfcd39b267bbd2 (5000)> commit -m commit2 -d 2000-01-02 foo | |
207 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updated served branch cache in * seconds (glob) |
|
207 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updated served branch cache in * seconds (glob) | |
208 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> wrote served branch cache with 1 labels and 1 nodes |
|
208 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> wrote served branch cache with 1 labels and 1 nodes | |
209 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> commit -m commit2 -d 2000-01-02 foo exited 0 after * seconds (glob) |
|
209 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> commit -m commit2 -d 2000-01-02 foo exited 0 after * seconds (glob) | |
210 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0 |
|
210 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0 | |
211 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> writing .hg/cache/tags2-visible with 0 tags |
|
211 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> writing .hg/cache/tags2-visible with 0 tags | |
212 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0 exited 0 after * seconds (glob) |
|
212 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r 0 exited 0 after * seconds (glob) | |
213 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip |
|
213 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip | |
214 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip exited 0 after * seconds (glob) |
|
214 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> log -r tip exited 0 after * seconds (glob) | |
215 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox |
|
215 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox | |
216 |
|
216 | |||
217 | Test log recursion from dirty status check |
|
217 | Test log recursion from dirty status check | |
218 |
|
218 | |||
219 | $ cat > ../r.py <<EOF |
|
219 | $ cat > ../r.py <<EOF | |
220 | > from mercurial import context, error, extensions |
|
220 | > from mercurial import context, error, extensions | |
221 | > x=[False] |
|
221 | > x=[False] | |
222 | > def status(orig, *args, **opts): |
|
222 | > def status(orig, *args, **opts): | |
223 | > args[0].repo().ui.log("broken", "recursion?") |
|
223 | > args[0].repo().ui.log("broken", "recursion?") | |
224 | > return orig(*args, **opts) |
|
224 | > return orig(*args, **opts) | |
225 | > def reposetup(ui, repo): |
|
225 | > def reposetup(ui, repo): | |
226 | > extensions.wrapfunction(context.basectx, 'status', status) |
|
226 | > extensions.wrapfunction(context.basectx, 'status', status) | |
227 | > EOF |
|
227 | > EOF | |
228 | $ hg id --config extensions.x=../r.py --config blackbox.dirty=True |
|
228 | $ hg id --config extensions.x=../r.py --config blackbox.dirty=True | |
229 | 45589e459b2e tip |
|
229 | 45589e459b2e tip | |
230 |
|
230 | |||
231 | cleanup |
|
231 | cleanup | |
232 | $ cd .. |
|
232 | $ cd .. | |
|
233 | ||||
|
234 | #if chg | |||
|
235 | ||||
|
236 | when using chg, blackbox.log should get rotated correctly | |||
|
237 | ||||
|
238 | $ cat > $TESTTMP/noop.py << EOF | |||
|
239 | > from __future__ import absolute_import | |||
|
240 | > import time | |||
|
241 | > from mercurial import registrar, scmutil | |||
|
242 | > cmdtable = {} | |||
|
243 | > command = registrar.command(cmdtable) | |||
|
244 | > @command('noop') | |||
|
245 | > def noop(ui, repo): | |||
|
246 | > pass | |||
|
247 | > EOF | |||
|
248 | ||||
|
249 | $ hg init blackbox-chg | |||
|
250 | $ cd blackbox-chg | |||
|
251 | ||||
|
252 | $ cat > .hg/hgrc << EOF | |||
|
253 | > [blackbox] | |||
|
254 | > maxsize = 500B | |||
|
255 | > [extensions] | |||
|
256 | > # extension change forces chg to restart | |||
|
257 | > noop=$TESTTMP/noop.py | |||
|
258 | > EOF | |||
|
259 | ||||
|
260 | $ $PYTHON -c 'print("a" * 400)' > .hg/blackbox.log | |||
|
261 | $ chg noop | |||
|
262 | $ chg noop | |||
|
263 | $ chg noop | |||
|
264 | $ chg noop | |||
|
265 | $ chg noop | |||
|
266 | ||||
|
267 | $ cat > showsize.py << 'EOF' | |||
|
268 | > import os, sys | |||
|
269 | > limit = 500 | |||
|
270 | > for p in sys.argv[1:]: | |||
|
271 | > size = os.stat(p).st_size | |||
|
272 | > if size >= limit: | |||
|
273 | > desc = '>=' | |||
|
274 | > else: | |||
|
275 | > desc = '<' | |||
|
276 | > print('%s: %s %d' % (p, desc, limit)) | |||
|
277 | > EOF | |||
|
278 | ||||
|
279 | $ $PYTHON showsize.py .hg/blackbox* | |||
|
280 | .hg/blackbox.log: < 500 | |||
|
281 | .hg/blackbox.log.1: >= 500 | |||
|
282 | .hg/blackbox.log.2: >= 500 | |||
|
283 | ||||
|
284 | $ cd .. | |||
|
285 | ||||
|
286 | #endif |
General Comments 0
You need to be logged in to leave comments.
Login now