diff --git a/remotefilelog/__init__.py b/remotefilelog/__init__.py --- a/remotefilelog/__init__.py +++ b/remotefilelog/__init__.py @@ -18,6 +18,8 @@ ``remotefilelog.nodettl`` specifies maximum TTL of a node in seconds before it is garbage collected ``remotefilelog.repackonhggc`` runs repack on hg gc when True + ``remotefilelog.prefetchdays`` specifies the maximum age of a commit in + days after which it is no longer prefetched. """ from . import fileserverclient, remotefilelog, remotefilectx, shallowstore @@ -779,6 +781,16 @@ return orig(ui, repo, *pats, **opts) +def revdatelimit(ui, revset): + """Update revset so that only changesets no older than 'prefetchdays' days + are included. The default value is set to 14 days. If 'prefetchdays' is set + to zero or negative value then date restriction is not applied. + """ + days = ui.configint('remotefilelog', 'prefetchdays', 14) + if days > 0: + revset = '(%s) & date(-%s)' % (revset, days) + return revset + def wcpprefetch(ui, repo, **kwargs): """Prefetches in background revisions specified by bgprefetchrevs revset. Does background repack if backgroundrepack flag is set in config. @@ -789,6 +801,9 @@ if shallow and bgprefetchrevs: bgrepack = repo.ui.configbool('remotefilelog', 'backgroundrepack', False) + # update a revset with a date limit + bgprefetchrevs = revdatelimit(ui, bgprefetchrevs) + def anon(): if util.safehasattr(repo, 'ranprefetch') and repo.ranprefetch: return @@ -929,8 +944,12 @@ bgprefetchrevs = ui.config('remotefilelog', 'bgprefetchrevs', None) if bgprefetchrevs: revset.append('(%s)' % bgprefetchrevs) + revset = '+'.join(revset) - opts['rev'] = ['+'.join(revset)] + # update a revset with a date limit + revset = revdatelimit(ui, revset) + + opts['rev'] = [revset] revs = scmutil.revrange(repo, opts.get('rev')) diff --git a/tests/test-remotefilelog-bgprefetch.t b/tests/test-remotefilelog-bgprefetch.t --- a/tests/test-remotefilelog-bgprefetch.t +++ b/tests/test-remotefilelog-bgprefetch.t @@ -22,7 +22,7 @@ $ cd .. -# prefetch a revision +# clone the repo $ hgcloneshallow ssh://user@dummy/master shallow --noupdate streaming all changes @@ -30,6 +30,17 @@ transferred 776 bytes in * seconds (*/sec) (glob) searching for changes no changes found + +# Set the prefetchdays config to zero so that all commits are prefetched +# no matter what their creation date is. + $ cd shallow + $ cat >> .hg/hgrc < [remotefilelog] + > prefetchdays=0 + > EOF + $ cd .. + +# prefetch a revision $ cd shallow $ hg prefetch -r 0 diff --git a/tests/test-remotefilelog-gc.t b/tests/test-remotefilelog-gc.t --- a/tests/test-remotefilelog-gc.t +++ b/tests/test-remotefilelog-gc.t @@ -17,6 +17,15 @@ $ hgcloneshallow ssh://user@dummy/master shallow -q 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) +# Set the prefetchdays config to zero so that all commits are prefetched +# no matter what their creation date is. + $ cd shallow + $ cat >> .hg/hgrc < [remotefilelog] + > prefetchdays=0 + > EOF + $ cd .. + # commit a new version of x so we can gc the old one $ cd master diff --git a/tests/test-remotefilelog-gcrepack.t b/tests/test-remotefilelog-gcrepack.t --- a/tests/test-remotefilelog-gcrepack.t +++ b/tests/test-remotefilelog-gcrepack.t @@ -21,6 +21,15 @@ $ hgcloneshallow ssh://user@dummy/master shallow -q 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) +# Set the prefetchdays config to zero so that all commits are prefetched +# no matter what their creation date is. + $ cd shallow + $ cat >> .hg/hgrc < [remotefilelog] + > prefetchdays=0 + > EOF + $ cd .. + # Prefetch all data and repack $ cd shallow diff --git a/tests/test-remotefilelog-repack-fast.t b/tests/test-remotefilelog-repack-fast.t --- a/tests/test-remotefilelog-repack-fast.t +++ b/tests/test-remotefilelog-repack-fast.t @@ -24,6 +24,15 @@ $ hgcloneshallow ssh://user@dummy/master shallow -q 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) +# Set the prefetchdays config to zero so that all commits are prefetched +# no matter what their creation date is. + $ cd shallow + $ cat >> .hg/hgrc < [remotefilelog] + > prefetchdays=0 + > EOF + $ cd .. + # Test that repack cleans up the old files and creates new packs $ cd shallow diff --git a/tests/test-remotefilelog-repack.t b/tests/test-remotefilelog-repack.t --- a/tests/test-remotefilelog-repack.t +++ b/tests/test-remotefilelog-repack.t @@ -19,6 +19,15 @@ $ hgcloneshallow ssh://user@dummy/master shallow -q 1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob) +# Set the prefetchdays config to zero so that all commits are prefetched +# no matter what their creation date is. + $ cd shallow + $ cat >> .hg/hgrc < [remotefilelog] + > prefetchdays=0 + > EOF + $ cd .. + # Test that repack cleans up the old files and creates new packs $ cd shallow