diff --git a/remotefilelog/__init__.py b/remotefilelog/__init__.py --- a/remotefilelog/__init__.py +++ b/remotefilelog/__init__.py @@ -32,6 +32,8 @@ 1MB, 100MB) and [100MB, infinity). ``remotefilelog.data.maxrepackpacks`` the maximum number of pack files to include in an incremental data repack. + ``remotefilelog.data.repackmaxpacksize`` the maximum size of a pack file for + it to be considered for an incremental data repack. ``remotefilelog.data.repacksizelimit`` the maximum total size of pack files to include in an incremental data repack. ``remotefilelog.history.gencountlimit`` constraints the minimum number of @@ -43,6 +45,8 @@ 0, 1MB), [1MB, 100MB) and [100MB, infinity). ``remotefilelog.history.maxrepackpacks`` the maximum number of pack files to include in an incremental history repack. + ``remotefilelog.history.repackmaxpacksize`` the maximum size of a pack file + for it to be considered for an incremental history repack. ``remotefilelog.history.repacksizelimit`` the maximum total size of pack files to include in an incremental history repack. """ diff --git a/remotefilelog/repack.py b/remotefilelog/repack.py --- a/remotefilelog/repack.py +++ b/remotefilelog/repack.py @@ -228,6 +228,8 @@ 'remotefilelog', 'data.generations', ['1GB', '100MB', '1MB']), 'maxrepackpacks' : ui.configint( 'remotefilelog', 'data.maxrepackpacks', 50), + 'repackmaxpacksize' : ui.configbytes( + 'remotefilelog', 'data.repackmaxpacksize', '4GB'), 'repacksizelimit' : ui.configbytes( 'remotefilelog', 'data.repacksizelimit', '100MB'), } @@ -244,6 +246,8 @@ 'remotefilelog', 'history.generations', ['100MB']), 'maxrepackpacks' : ui.configint( 'remotefilelog', 'history.maxrepackpacks', 50), + 'repackmaxpacksize' : ui.configbytes( + 'remotefilelog', 'history.repackmaxpacksize', '400MB'), 'repacksizelimit' : ui.configbytes( 'remotefilelog', 'history.repacksizelimit', '100MB'), } @@ -290,6 +294,9 @@ sizes = {} for prefix, mode, stat in files: size = stat.st_size + if size > opts['repackmaxpacksize']: + continue + sizes[prefix] = size for i, limit in enumerate(limits): if size > limit: 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 @@ -327,7 +327,29 @@ -r--r--r-- 336 094b530486dad4427a0faf6bcbc031571b99ca24.histpack -r--r--r-- 172 276d308429d0303762befa376788300f0310f90e.histpack -r--r--r-- 90 c3399b56e035f73c3295276ed098235a08a0ed8c.histpack - $ hg repack --incremental + +For the data packs, setting the limit for the repackmaxpacksize to be 64 such +that data pack with size 65 is more than the limit. This effectively ensures +that no generation has 3 packs and therefore, no packs are chosen for the +incremental repacking. As for the history packs, setting repackmaxpacksize to be +0 which should always result in no repacking. + $ hg repack --incremental --config remotefilelog.data.repackmaxpacksize=64 \ + > --config remotefilelog.history.repackmaxpacksize=0 + $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack + -r--r--r-- 59 5b7dec902026f0cddb0ef8acb62f27b5698494d4.datapack + -r--r--r-- 65 6c499d21350d79f92fd556b4b7a902569d88e3c9.datapack + -r--r--r-- 61 817d294043bd21a3de01f807721971abe45219ce.datapack + -r--r--r-- 63 ff45add45ab3f59c4f75efc6a087d86c821219d6.datapack + $ ls_l $TESTTMP/hgcache/master/packs/ | grep histpack + -r--r--r-- 254 077e7ce5dfe862dc40cc8f3c9742d96a056865f2.histpack + -r--r--r-- 336 094b530486dad4427a0faf6bcbc031571b99ca24.histpack + -r--r--r-- 172 276d308429d0303762befa376788300f0310f90e.histpack + -r--r--r-- 90 c3399b56e035f73c3295276ed098235a08a0ed8c.histpack + +Setting limit for the repackmaxpacksize to be the size of the biggest pack file +which ensures that it is effectively ignored in the incremental repacking. + $ hg repack --incremental --config remotefilelog.data.repackmaxpacksize=65 \ + > --config remotefilelog.history.repackmaxpacksize=336 $ ls_l $TESTTMP/hgcache/master/packs/ | grep datapack -r--r--r-- 59 5b7dec902026f0cddb0ef8acb62f27b5698494d4.datapack -r--r--r-- 225 8fe685c56f6f7edf550bfcec74eeecc5f3c2ba15.datapack