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