diff --git a/tests/test-treemanifest-prefetch.t b/tests/test-treemanifest-prefetch.t --- a/tests/test-treemanifest-prefetch.t +++ b/tests/test-treemanifest-prefetch.t @@ -59,9 +59,10 @@ > usecache = False > EOF -Test prefetchtrees - $ hg prefetchtrees -r '0 + 1 + 2' + Test prefetch + $ hg prefetch -r '0 + 1 + 2' 6 trees fetched over * (glob) + 1 files fetched over * (glob) $ ls $CACHEDIR/master/packs/manifests 29938257d506f677320d5abec8e34a1a9ed635fe.histidx 29938257d506f677320d5abec8e34a1a9ed635fe.histpack @@ -126,24 +127,6 @@ 1 48 62 0 1 1be4ab2126dd ef362f8bbe8a 000000000000 2 110 59 1 2 60a7f7acb6bb 1be4ab2126dd 000000000000 -Test prefetch with base node (subdir/ shouldn't show up in the pack) - $ rm -rf $CACHEDIR/master - $ hg prefetchtrees -r '2' --base '1' - 2 trees fetched over * (glob) - $ ls $CACHEDIR/master/packs/manifests/*.dataidx - $TESTTMP/hgcache/master/packs/manifests/3fb59713808147bda39cbd97b9cd862406f5865c.dataidx - - $ hg debugdatapack $CACHEDIR/master/packs/manifests/3fb59713808147bda39cbd97b9cd862406f5865c.dataidx - $TESTTMP/hgcache/master/packs/manifests/3fb59713808147bda39cbd97b9cd862406f5865c: - dir: - Node Delta Base Delta Length Blob Size - a18d21674e76 000000000000 43 (missing) - - (empty name): - Node Delta Base Delta Length Blob Size - 60a7f7acb6bb 000000000000 95 (missing) - - Test auto prefetch during normal access $ rm -rf $CACHEDIR/master || ( exit 1 ) is needed because ls on OSX and Linux exits differently @@ -202,22 +185,23 @@ Test that auto prefetch scans up the changelog for base trees $ rm -rf $CACHEDIR/master - $ hg prefetchtrees -r 'tip^' + $ hg prefetch -r 'tip^' 3 trees fetched over * (glob) + 2 files fetched over * (glob) $ rm -rf $CACHEDIR/master - $ hg prefetchtrees -r tip + $ hg prefetch -r tip 3 trees fetched over * (glob) + 2 files fetched over * (glob) - Only 2 of the 3 trees from tip^ are downloaded as part of --stat's fetch $ hg log -r tip --stat --pager=off > /dev/null 2 trees fetched over * (glob) - 2 files fetched over * (glob) + 1 files fetched over * (glob) Test auto prefetch during pull - Prefetch everything $ echo a >> a - $ hg commit -Aqm 'draft commit that shouldnt affect prefetching trees' - 1 files fetched over * (glob) + $ hg commit -Aqm 'draft commit that shouldnt affect prefetch' $ rm -rf $CACHEDIR/master $ hg pull --config treemanifest.pullprefetchcount=10 --traceback pulling from ssh://user@dummy/master @@ -279,8 +263,9 @@ - Prefetch commit 1 then minimally prefetch commit 2 $ rm -rf $CACHEDIR/master - $ hg prefetchtrees -r 1 + $ hg prefetch -r 1 3 trees fetched over * (glob) + 2 files fetched over * (glob) $ ls $CACHEDIR/master/packs/manifests/*dataidx $TESTTMP/hgcache/master/packs/manifests/148e9eb32f473ea522c591c95be0f9e772be9675.dataidx $ hg pull --config treemanifest.pullprefetchcount=1 --traceback @@ -373,5 +358,6 @@ trees - in this case 3 trees for commit 2, and 2 for commit 4 despite it having 3 directories) $ rm -rf $CACHEDIR/master - $ hg prefetchtrees -r '2 + 4' + $ hg prefetch -r '2 + 4' 5 trees fetched over * (glob) + 3 files fetched over * (glob) diff --git a/treemanifest/__init__.py b/treemanifest/__init__.py --- a/treemanifest/__init__.py +++ b/treemanifest/__init__.py @@ -81,6 +81,7 @@ registrar, repair, revlog, + scmutil, sshserver, templatekw, util, @@ -157,6 +158,16 @@ extensions.wrapfunction(templatekw, 'showmanifest', showmanifest) templatekw.keywords['manifest'] = templatekw.showmanifest + def wrapremotefilelog(loaded=False): + try: + remotefilelogmod = extensions.find('remotefilelog') + extensions.wrapcommand( + remotefilelogmod.cmdtable, 'prefetch', _prefetchwrapper) + except KeyError: + pass + + extensions.afterloaded('remotefilelog', wrapremotefilelog) + def showmanifest(orig, **args): # The normal manifest template shows a rev number, which we don't have. # Let's just print the node. Note, this breaks the ability for us to do @@ -970,25 +981,14 @@ raise AttributeError(_("%s has no property '%s'") % (type(currcls), propname)) -@command('prefetchtrees', [ - ('r', 'rev', '', _("revs to prefetch the trees for")), - ('', 'base', '', _("revs that are assumed to already be local")), - ] + commands.walkopts, _('--rev REVS PATTERN..')) -def prefetchtrees(ui, repo, *args, **opts): - revs = repo.revs(opts.get('rev')) - baserevs = [] - if opts.get('base'): - baserevs = repo.revs(opts.get('base')) - +def _prefetchwrapper(orig, ui, repo, *args, **opts): + revs = scmutil.revrange(repo, opts.get('rev')) mfnodes = set() for rev in revs: mfnodes.add(repo[rev].manifestnode()) - basemfnodes = set() - for rev in baserevs: - basemfnodes.add(repo[rev].manifestnode()) - - _prefetchtrees(repo, '', mfnodes, basemfnodes, []) + _prefetchtrees(repo, '', mfnodes, set(), []) + orig(ui, repo, *args, **opts) def _prefetchtrees(repo, rootdir, mfnodes, basemfnodes, directories): # If possible, use remotefilelog's more expressive fallbackpath