##// END OF EJS Templates
blackbox: store the blackbox ui object instead of the log file...
timeless -
r28247:d2c0527a default
parent child Browse files
Show More
@@ -54,7 +54,7 b' command = cmdutil.command(cmdtable)'
54 54 # be specifying the version(s) of Mercurial they are tested with, or
55 55 # leave the attribute unspecified.
56 56 testedwith = 'internal'
57 lastfp = None
57 lastui = None
58 58
59 59 filehandles = {}
60 60
@@ -115,15 +115,19 b' def wrapui(ui):'
115 115 fp = _openlog(self._bbvfs)
116 116 return fp
117 117
118 def _bbwrite(self, fmt, *args):
119 self._bbfp.write(fmt % args)
120 self._bbfp.flush()
121
118 122 def log(self, event, *msg, **opts):
119 global lastfp
123 global lastui
120 124 super(blackboxui, self).log(event, *msg, **opts)
121 125
122 126 if not '*' in self.track and not event in self.track:
123 127 return
124 128
125 if util.safehasattr(self, '_blackbox'):
126 fp = self._blackbox
129 if util.safehasattr(self, '_bbfp'):
130 ui = self
127 131 elif util.safehasattr(self, '_bbvfs'):
128 132 try:
129 133 self._bbfp = self._openlogfile()
@@ -132,41 +136,41 b' def wrapui(ui):'
132 136 err.strerror)
133 137 del self._bbvfs
134 138 self._bbfp = None
135 fp = self._bbfp
139 ui = self
136 140 else:
137 141 # certain ui instances exist outside the context of
138 142 # a repo, so just default to the last blackbox that
139 143 # was seen.
140 fp = lastfp
144 ui = lastui
141 145
142 if fp:
146 if (util.safehasattr(ui, '_bbfp') and
147 ui._bbfp is not None):
143 148 date = util.datestr(None, '%Y/%m/%d %H:%M:%S')
144 149 user = util.getuser()
145 150 pid = str(util.getpid())
146 151 formattedmsg = msg[0] % msg[1:]
147 152 rev = '(unknown)'
148 153 changed = ''
149 if util.safehasattr(self, '_bbrepo'):
150 ctx = self._bbrepo[None]
154 if util.safehasattr(ui, '_bbrepo'):
155 ctx = ui._bbrepo[None]
151 156 if ctx.rev() is not None:
152 157 rev = hexfn(ctx.node())
153 158 else:
154 159 parents = ctx.parents()
155 160 rev = ('+'.join([hexfn(p.node()) for p in parents]))
156 if (self.configbool('blackbox', 'dirty', False) and (
157 any(self._bbrepo.status()) or
161 if (ui.configbool('blackbox', 'dirty', False) and (
162 any(ui._bbrepo.status()) or
158 163 any(ctx.sub(s).dirty() for s in ctx.substate)
159 164 )):
160 165 changed = '+'
161 166 try:
162 fp.write('%s %s @%s%s (%s)> %s' %
163 (date, user, rev, changed, pid, formattedmsg))
164 fp.flush()
167 ui._bbwrite('%s %s @%s%s (%s)> %s',
168 date, user, rev, changed, pid, formattedmsg)
165 169 except IOError as err:
166 170 self.debug('warning: cannot write to blackbox.log: %s\n' %
167 171 err.strerror)
168 if not lastfp or util.safehasattr(self, '_bbrepo'):
169 lastfp = fp
172 if not lastui or util.safehasattr(ui, '_bbrepo'):
173 lastui = ui
170 174
171 175 def setrepo(self, repo):
172 176 self._bbvfs = repo.vfs
@@ -12,12 +12,9 b' command, exit codes, and duration'
12 12
13 13 $ echo a > a
14 14 $ hg add a
15 $ hg id --config blackbox.dirty=True > /dev/null
16 15 $ hg blackbox --config blackbox.dirty=True
17 16 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a
18 1970/01/01 00:00:00 bob @(unknown) (5000)> add a exited 0 after * seconds (glob)
19 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> id
20 1970/01/01 00:00:00 bob @(unknown) (5000)> id --config blackbox.dirty=True exited 0 after * seconds (glob)
17 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob)
21 18 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox
22 19
23 20 incoming change tracking
@@ -52,7 +49,7 b' clone, commit, pull'
52 49 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated served branch cache in * seconds (glob)
53 50 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote served branch cache with 1 labels and 2 nodes
54 51 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> 1 incoming changes - new heads: d02f48003e62
55 1970/01/01 00:00:00 bob @(unknown) (5000)> pull exited 0 after * seconds (glob)
52 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull exited 0 after * seconds (glob)
56 53 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
57 54
58 55 we must not cause a failure if we cannot write to the log
@@ -114,7 +111,7 b' backup bundles get logged'
114 111 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg
115 112 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated base branch cache in * seconds (glob)
116 113 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote base branch cache with 1 labels and 2 nodes
117 1970/01/01 00:00:00 bob @(unknown) (5000)> strip tip exited 0 after * seconds (glob)
114 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> strip tip exited 0 after * seconds (glob)
118 115 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6
119 116
120 117 extension and python hooks - use the eol extension for a pythonhook
@@ -132,7 +129,7 b' extension and python hooks - use the eol'
132 129 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> writing .hg/cache/tags2-visible with 0 tags
133 130 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob)
134 131 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> exthook-update: echo hooked finished in * seconds (glob)
135 1970/01/01 00:00:00 bob @(unknown) (5000)> update exited 0 after * seconds (glob)
132 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> update exited 0 after * seconds (glob)
136 133 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> blackbox -l 6
137 134
138 135 log rotation
@@ -182,7 +179,7 b' log rotation'
182 179 result: None
183 180 $ hg blackbox
184 181 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
185 1970/01/01 00:00:00 bob @(unknown) (5000)> blackbox exited 0 after * seconds (glob)
182 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox exited 0 after * seconds (glob)
186 183 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox
187 184
188 185 cleanup
@@ -71,7 +71,7 b' Hiding a non-tip changeset should change'
71 71 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> tags
72 72 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> 2/2 cache hits/lookups in * seconds (glob)
73 73 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> writing .hg/cache/tags2-visible with 2 tags
74 1970/01/01 00:00:00 bob @(unknown) (5000)> tags exited 0 after * seconds (glob)
74 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> tags exited 0 after * seconds (glob)
75 75 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> blackbox -l 5
76 76
77 77 Hiding another changeset should cause the filtered hash to change
@@ -91,7 +91,7 b' Hiding another changeset should cause th'
91 91 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> tags
92 92 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> 1/1 cache hits/lookups in * seconds (glob)
93 93 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> writing .hg/cache/tags2-visible with 1 tags
94 1970/01/01 00:00:00 bob @(unknown) (5000)> tags exited 0 after * seconds (glob)
94 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> tags exited 0 after * seconds (glob)
95 95 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> blackbox -l 5
96 96
97 97 Resolving tags on an unfiltered repo writes a separate tags cache
@@ -112,5 +112,5 b' Resolving tags on an unfiltered repo wri'
112 112 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> --hidden tags
113 113 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> 2/2 cache hits/lookups in * seconds (glob)
114 114 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> writing .hg/cache/tags2 with 3 tags
115 1970/01/01 00:00:00 bob @(unknown) (5000)> --hidden tags exited 0 after * seconds (glob)
115 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> --hidden tags exited 0 after * seconds (glob)
116 116 1970/01/01 00:00:00 bob @2942a772f72a444bef4bef13874d515f50fa27b6 (5000)> blackbox -l 5
@@ -141,7 +141,7 b' Tag cache debug info written to blackbox'
141 141 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> writing 48 bytes to cache/hgtagsfnodes1
142 142 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> 0/1 cache hits/lookups in * seconds (glob)
143 143 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> writing .hg/cache/tags2-visible with 1 tags
144 1970/01/01 00:00:00 bob @(unknown) (5000)> identify exited 0 after * seconds (glob)
144 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> identify exited 0 after * seconds (glob)
145 145 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> blackbox -l 6
146 146
147 147 Failure to acquire lock results in no write
@@ -155,7 +155,7 b' Failure to acquire lock results in no wr'
155 155 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> not writing .hg/cache/hgtagsfnodes1 because lock cannot be acquired
156 156 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> 0/1 cache hits/lookups in * seconds (glob)
157 157 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> writing .hg/cache/tags2-visible with 1 tags
158 1970/01/01 00:00:00 bob @(unknown) (5000)> identify exited 0 after * seconds (glob)
158 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> identify exited 0 after * seconds (glob)
159 159 1970/01/01 00:00:00 bob @b9154636be938d3d431e75a7c906504a079bfe07 (5000)> blackbox -l 6
160 160
161 161 $ fnodescacheexists
@@ -218,7 +218,7 b' Merge the two heads:'
218 218 (branch merge, don't forget to commit)
219 219 $ hg blackbox -l3
220 220 1970/01/01 00:00:00 bob @c8edf04160c7f731e4589d66ab3ab3486a64ac28 (5000)> merge 1
221 1970/01/01 00:00:00 bob @(unknown) (5000)> merge 1 exited 0 after * seconds (glob)
221 1970/01/01 00:00:00 bob @c8edf04160c7f731e4589d66ab3ab3486a64ac28+b9154636be938d3d431e75a7c906504a079bfe07 (5000)> merge 1 exited 0 after * seconds (glob)
222 222 1970/01/01 00:00:00 bob @c8edf04160c7f731e4589d66ab3ab3486a64ac28+b9154636be938d3d431e75a7c906504a079bfe07 (5000)> blackbox -l3
223 223 $ hg id
224 224 c8edf04160c7+b9154636be93+ tip
@@ -359,7 +359,7 b' Extra junk data at the end should get ov'
359 359 1970/01/01 00:00:00 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> writing 24 bytes to cache/hgtagsfnodes1
360 360 1970/01/01 00:00:00 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> 2/3 cache hits/lookups in * seconds (glob)
361 361 1970/01/01 00:00:00 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> writing .hg/cache/tags2-visible with 1 tags
362 1970/01/01 00:00:00 bob @(unknown) (5000)> tags exited 0 after * seconds (glob)
362 1970/01/01 00:00:00 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> tags exited 0 after * seconds (glob)
363 363 1970/01/01 00:00:00 bob @8dbfe60eff306a54259cfe007db9e330e7ecf866 (5000)> blackbox -l 6
364 364
365 365 #if unix-permissions no-root
@@ -380,7 +380,7 b' Errors writing to .hgtags fnodes cache a'
380 380 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> couldn't write cache/hgtagsfnodes1: [Errno 13] Permission denied: '$TESTTMP/t2/.hg/cache/hgtagsfnodes1'
381 381 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> 2/3 cache hits/lookups in * seconds (glob)
382 382 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> writing .hg/cache/tags2-visible with 1 tags
383 1970/01/01 00:00:00 bob @(unknown) (5000)> tags exited 0 after * seconds (glob)
383 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> tags exited 0 after * seconds (glob)
384 384 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> blackbox -l 6
385 385
386 386 $ chmod a+w .hg/cache/hgtagsfnodes1
@@ -395,7 +395,7 b' Errors writing to .hgtags fnodes cache a'
395 395 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> writing 24 bytes to cache/hgtagsfnodes1
396 396 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> 2/3 cache hits/lookups in * seconds (glob)
397 397 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> writing .hg/cache/tags2-visible with 1 tags
398 1970/01/01 00:00:00 bob @(unknown) (5000)> tags exited 0 after * seconds (glob)
398 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> tags exited 0 after * seconds (glob)
399 399 1970/01/01 00:00:00 bob @b968051b5cf3f624b771779c6d5f84f1d4c3fb5d (5000)> blackbox -l 6
400 400
401 401 $ f --size .hg/cache/hgtagsfnodes1
@@ -423,7 +423,7 b" Stripping doesn't truncate the tags cach"
423 423 1970/01/01 00:00:00 bob @0c192d7d5e6b78a714de54a2e9627952a877e25a (5000)> writing 24 bytes to cache/hgtagsfnodes1
424 424 1970/01/01 00:00:00 bob @0c192d7d5e6b78a714de54a2e9627952a877e25a (5000)> 2/3 cache hits/lookups in * seconds (glob)
425 425 1970/01/01 00:00:00 bob @0c192d7d5e6b78a714de54a2e9627952a877e25a (5000)> writing .hg/cache/tags2-visible with 1 tags
426 1970/01/01 00:00:00 bob @(unknown) (5000)> tags exited 0 after * seconds (glob)
426 1970/01/01 00:00:00 bob @0c192d7d5e6b78a714de54a2e9627952a877e25a (5000)> tags exited 0 after * seconds (glob)
427 427 1970/01/01 00:00:00 bob @0c192d7d5e6b78a714de54a2e9627952a877e25a (5000)> blackbox -l 5
428 428
429 429 $ f --size .hg/cache/hgtagsfnodes1
@@ -441,7 +441,7 b" Stripping doesn't truncate the tags cach"
441 441 1970/01/01 00:00:00 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> writing 24 bytes to cache/hgtagsfnodes1
442 442 1970/01/01 00:00:00 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> 2/3 cache hits/lookups in * seconds (glob)
443 443 1970/01/01 00:00:00 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> writing .hg/cache/tags2-visible with 1 tags
444 1970/01/01 00:00:00 bob @(unknown) (5000)> tags exited 0 after * seconds (glob)
444 1970/01/01 00:00:00 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> tags exited 0 after * seconds (glob)
445 445 1970/01/01 00:00:00 bob @035f65efb448350f4772141702a81ab1df48c465 (5000)> blackbox -l 6
446 446 $ f --size .hg/cache/hgtagsfnodes1
447 447 .hg/cache/hgtagsfnodes1: size=144
General Comments 0
You need to be logged in to leave comments. Login now