mirror of
https://github.com/facebook/sapling.git
synced 2025-01-06 04:43:19 +03:00
treemanifest: don't purge shared packs while repack is running
Summary: If treemanifest finds there are too many shared packs (more than `packs.maxpackfilecount`) then it will purge them. This is a shame if there is currently a repack in progress, as it will purge the packfiles from underneath the repack, deleting lots of cache data that will be imminently repacked). Skip the purge if there is a repack ongoing. Reviewed By: mitrandir77 Differential Revision: D17155854 fbshipit-source-id: 20d46f29c252e508177b1fde08ca7a69841dcd7e
This commit is contained in:
parent
0b570f65a7
commit
d21fc6233a
@ -191,6 +191,7 @@ from edenscm.mercurial.node import bin, hex, nullid, short
|
||||
from edenscmnative import cstore
|
||||
from edenscmnative.bindings import manifest as rustmanifest, revisionstore
|
||||
|
||||
from ..extutil import flock
|
||||
from ..remotefilelog import (
|
||||
cmdtable as remotefilelogcmdtable,
|
||||
edenapi,
|
||||
@ -211,6 +212,7 @@ from ..remotefilelog.repack import (
|
||||
_runrepack,
|
||||
_topacks,
|
||||
domaintenancerepack,
|
||||
repacklockvfs,
|
||||
)
|
||||
|
||||
|
||||
@ -628,13 +630,27 @@ def _prunesharedpacks(repo, packpath):
|
||||
# Note this is based on file count, not pack count.
|
||||
config = repo.ui.configint("packs", "maxpackfilecount")
|
||||
if config and numentries > config:
|
||||
repo.ui.warn(
|
||||
(
|
||||
"purging shared treemanifest pack cache (%d entries) "
|
||||
"-- too many files\n" % numentries
|
||||
try:
|
||||
with flock(
|
||||
repacklockvfs(repo).join("repacklock"),
|
||||
_("purging excess packs for %s") % packpath,
|
||||
timeout=0,
|
||||
):
|
||||
repo.ui.warn(
|
||||
(
|
||||
"purging shared treemanifest pack cache (%d entries) "
|
||||
"-- too many files\n" % numentries
|
||||
)
|
||||
)
|
||||
shutil.rmtree(packpath, True)
|
||||
except error.LockHeld:
|
||||
repo.ui.warn(
|
||||
(
|
||||
"not purging shared treemanifest pack cache (%d entries) "
|
||||
"as repack is still running\n"
|
||||
)
|
||||
% numentries
|
||||
)
|
||||
)
|
||||
shutil.rmtree(packpath, True)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
$ enable amend
|
||||
$ setconfig extensions.treemanifest=!
|
||||
$ . "$TESTDIR/library.sh"
|
||||
$ setconfig treemanifest.treeonly=False
|
||||
@ -272,11 +273,14 @@ Test incremental repack that doesn't take all packs
|
||||
$ ls_l .hg/cache/packs/manifests/ | grep datapack
|
||||
-r--r--r-- 496 bc6c2ebb080844d7a227dacbc847a5b375ec620c.datapack
|
||||
|
||||
- Test pruning the manifest cache using packs.maxpackfilecount
|
||||
$ hg repack --incremental --config packs.maxpackfilecount=0
|
||||
$ hg repack --incremental --packsonly --config packs.maxpackfilecount=1
|
||||
- Test pruning the manifest cache using packs.maxpackfilecount.
|
||||
- (Use 'hg metaedit' as repack itself will not trigger the purge, and
|
||||
- 'metaedit' won't create any new objects to pack.)
|
||||
$ hg metaedit -m 'modify a (2)' --config packs.maxpackfilecount=0
|
||||
$ hg metaedit -m 'modify a (3)' --config packs.maxpackfilecount=1
|
||||
purging shared treemanifest pack cache (4 entries) -- too many files
|
||||
$ ls_l .hg/cache/packs/manifests/
|
||||
$ test -d .hg/cache/packs/manifests/
|
||||
[1]
|
||||
$ cd ..
|
||||
|
||||
Test hg gc with multiple repositories
|
||||
|
Loading…
Reference in New Issue
Block a user