Mercurial > hg
comparison hgext/largefiles/overrides.py @ 24670:dfb86af18a35
treemanifest: optimize treemanifest._walk() to skip directories
This makes treemanifest.walk() not visit submanifests that are known not to
have any matching files. It does this by calling match.visitdir() on
submanifests as it walks.
This change also updates largefiles to be able to work with this new behavior
in treemanifests. It overrides match.visitdir(), the function that dictates
how walk() and matches() skip over directories.
The greatest speed improvements are seen with narrower scopes. For example,
this commit speeds up the following command on the Mozilla repo from 1.14s
to 1.02s:
hg files -r . dom/apps/
Whereas with a wider scope, dom/, the speed only improves from 1.21s to 1.13s.
As with similar a similar optimization to treemanifest.matches(), this change
will bring out even bigger performance improvements once treemanifests are
loaded lazily. Once that happens, we won't just skip over looking at
submanifests, but we'll skip even loading them.
author | Drew Gottlieb <drgott@google.com> |
---|---|
date | Tue, 07 Apr 2015 15:18:52 -0700 |
parents | 1925769b4ff8 |
children | 0974d3a0be29 |
comparison
equal
deleted
inserted
replaced
24669:fbdbff1b486a | 24670:dfb86af18a35 |
---|---|
1272 origbadfn = m.bad | 1272 origbadfn = m.bad |
1273 def lfbadfn(f, msg): | 1273 def lfbadfn(f, msg): |
1274 if not f in notbad: | 1274 if not f in notbad: |
1275 origbadfn(f, msg) | 1275 origbadfn(f, msg) |
1276 m.bad = lfbadfn | 1276 m.bad = lfbadfn |
1277 | |
1278 origvisitdirfn = m.visitdir | |
1279 def lfvisitdirfn(dir): | |
1280 if dir == lfutil.shortname: | |
1281 return True | |
1282 ret = origvisitdirfn(dir) | |
1283 if ret: | |
1284 return ret | |
1285 lf = lfutil.splitstandin(dir) | |
1286 if lf is None: | |
1287 return False | |
1288 return origvisitdirfn(lf) | |
1289 m.visitdir = lfvisitdirfn | |
1290 | |
1277 for f in ctx.walk(m): | 1291 for f in ctx.walk(m): |
1278 fp = cmdutil.makefileobj(repo, opts.get('output'), ctx.node(), | 1292 fp = cmdutil.makefileobj(repo, opts.get('output'), ctx.node(), |
1279 pathname=f) | 1293 pathname=f) |
1280 lf = lfutil.splitstandin(f) | 1294 lf = lfutil.splitstandin(f) |
1281 if lf is None or origmatchfn(f): | 1295 if lf is None or origmatchfn(f): |