Show More
@@ -232,6 +232,28 b' def getbranchmapsubsettable():' | |||||
232 | raise error.Abort(("perfbranchmap not available with this Mercurial"), |
|
232 | raise error.Abort(("perfbranchmap not available with this Mercurial"), | |
233 | hint="use 2.5 or later") |
|
233 | hint="use 2.5 or later") | |
234 |
|
234 | |||
|
235 | def getsvfs(repo): | |||
|
236 | """Return appropriate object to access files under .hg/store | |||
|
237 | """ | |||
|
238 | # for "historical portability": | |||
|
239 | # repo.svfs has been available since 2.3 (or 7034365089bf) | |||
|
240 | svfs = getattr(repo, 'svfs', None) | |||
|
241 | if svfs: | |||
|
242 | return svfs | |||
|
243 | else: | |||
|
244 | return getattr(repo, 'sopener') | |||
|
245 | ||||
|
246 | def getvfs(repo): | |||
|
247 | """Return appropriate object to access files under .hg | |||
|
248 | """ | |||
|
249 | # for "historical portability": | |||
|
250 | # repo.vfs has been available since 2.3 (or 7034365089bf) | |||
|
251 | vfs = getattr(repo, 'vfs', None) | |||
|
252 | if vfs: | |||
|
253 | return vfs | |||
|
254 | else: | |||
|
255 | return getattr(repo, 'opener') | |||
|
256 | ||||
235 | # perf commands |
|
257 | # perf commands | |
236 |
|
258 | |||
237 | @command('perfwalk', formatteropts) |
|
259 | @command('perfwalk', formatteropts) | |
@@ -302,9 +324,10 b' def perftags(ui, repo, **opts):' | |||||
302 | import mercurial.changelog |
|
324 | import mercurial.changelog | |
303 | import mercurial.manifest |
|
325 | import mercurial.manifest | |
304 | timer, fm = gettimer(ui, opts) |
|
326 | timer, fm = gettimer(ui, opts) | |
|
327 | svfs = getsvfs(repo) | |||
305 | def t(): |
|
328 | def t(): | |
306 |
repo.changelog = mercurial.changelog.changelog( |
|
329 | repo.changelog = mercurial.changelog.changelog(svfs) | |
307 |
repo.manifest = mercurial.manifest.manifest( |
|
330 | repo.manifest = mercurial.manifest.manifest(svfs) | |
308 | repo._tags = None |
|
331 | repo._tags = None | |
309 | return len(repo.tags()) |
|
332 | return len(repo.tags()) | |
310 | timer(t) |
|
333 | timer(t) | |
@@ -483,8 +506,9 b' def perfindex(ui, repo, **opts):' | |||||
483 | timer, fm = gettimer(ui, opts) |
|
506 | timer, fm = gettimer(ui, opts) | |
484 | mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg |
|
507 | mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg | |
485 | n = repo["tip"].node() |
|
508 | n = repo["tip"].node() | |
|
509 | svfs = getsvfs(repo) | |||
486 | def d(): |
|
510 | def d(): | |
487 |
cl = mercurial.revlog.revlog( |
|
511 | cl = mercurial.revlog.revlog(svfs, "00changelog.i") | |
488 | cl.rev(n) |
|
512 | cl.rev(n) | |
489 | timer(d) |
|
513 | timer(d) | |
490 | fm.end() |
|
514 | fm.end() | |
@@ -556,7 +580,7 b' def perfnodelookup(ui, repo, rev, **opts' | |||||
556 | import mercurial.revlog |
|
580 | import mercurial.revlog | |
557 | mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg |
|
581 | mercurial.revlog._prereadsize = 2**24 # disable lazy parser in old hg | |
558 | n = repo[rev].node() |
|
582 | n = repo[rev].node() | |
559 |
cl = mercurial.revlog.revlog(repo |
|
583 | cl = mercurial.revlog.revlog(getsvfs(repo), "00changelog.i") | |
560 | def d(): |
|
584 | def d(): | |
561 | cl.rev(n) |
|
585 | cl.rev(n) | |
562 | clearcaches(cl) |
|
586 | clearcaches(cl) | |
@@ -903,7 +927,8 b' def perfloadmarkers(ui, repo):' | |||||
903 |
|
927 | |||
904 | Result is the number of markers in the repo.""" |
|
928 | Result is the number of markers in the repo.""" | |
905 | timer, fm = gettimer(ui) |
|
929 | timer, fm = gettimer(ui) | |
906 | timer(lambda: len(obsolete.obsstore(repo.svfs))) |
|
930 | svfs = getsvfs(repo) | |
|
931 | timer(lambda: len(obsolete.obsstore(svfs))) | |||
907 | fm.end() |
|
932 | fm.end() | |
908 |
|
933 | |||
909 | @command('perflrucachedict', formatteropts + |
|
934 | @command('perflrucachedict', formatteropts + |
@@ -12,6 +12,8 b' perfpypats = [' | |||||
12 | [ |
|
12 | [ | |
13 | (r'(branchmap|repoview)\.subsettable', |
|
13 | (r'(branchmap|repoview)\.subsettable', | |
14 | "use getbranchmapsubsettable() for early Mercurial"), |
|
14 | "use getbranchmapsubsettable() for early Mercurial"), | |
|
15 | (r'\.(vfs|svfs|opener|sopener)', | |||
|
16 | "use getvfs()/getsvfs() for early Mercurial"), | |||
15 | ], |
|
17 | ], | |
16 | # warnings |
|
18 | # warnings | |
17 | [ |
|
19 | [ |
General Comments 0
You need to be logged in to leave comments.
Login now