diff --git a/remotefilelog/__init__.py b/remotefilelog/__init__.py --- a/remotefilelog/__init__.py +++ b/remotefilelog/__init__.py @@ -992,6 +992,7 @@ @command('repack', [ ('', 'background', None, _('run in a background process'), None), ('', 'incremental', None, _('do an incremental repack'), None), + ('', 'packsonly', None, _('only repack packs (skip loose objects)'), None), ], _('hg repack [OPTIONS]')) def repack(ui, repo, *pats, **opts): if opts.get('background'): @@ -1001,4 +1002,4 @@ if opts.get('incremental'): repackmod.incrementalrepack(repo) else: - repackmod.fullrepack(repo) + repackmod.fullrepack(repo, packsonly=opts.get('packsonly')) diff --git a/remotefilelog/repack.py b/remotefilelog/repack.py --- a/remotefilelog/repack.py +++ b/remotefilelog/repack.py @@ -36,11 +36,21 @@ repo.ui.warn(msg) runshellcommand(cmd, os.environ) -def fullrepack(repo): +def fullrepack(repo, packsonly=False): + """If ``packsonly`` is True, stores creating only loose objects are skipped. + """ if util.safehasattr(repo, 'shareddatastores'): - datasource = contentstore.unioncontentstore(*repo.shareddatastores) + def ispackstore(store): + return callable(getattr(store, 'getpack', None)) + def filterstores(stores): + if packsonly: + return filter(ispackstore, stores) + else: + return stores + datasource = contentstore.unioncontentstore( + *filterstores(repo.shareddatastores)) historysource = metadatastore.unionmetadatastore( - *repo.sharedhistorystores, + *filterstores(repo.sharedhistorystores), allowincomplete=True) packpath = shallowutil.getcachepackpath( 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 @@ -82,6 +82,18 @@ $TESTTMP/hgcache/master/packs/8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.datapack $TESTTMP/hgcache/repos +# First assert that with --packsonly, the loose object will be ignored: + + $ hg repack --packsonly + + $ find $CACHEDIR -type f | sort + $TESTTMP/hgcache/master/11/f6ad8ec52a2984abaafd7c3b516503785c2072/d4a3ed9310e5bd9887e3bf779da5077efab28216 + $TESTTMP/hgcache/master/packs/276d308429d0303762befa376788300f0310f90e.histidx + $TESTTMP/hgcache/master/packs/276d308429d0303762befa376788300f0310f90e.histpack + $TESTTMP/hgcache/master/packs/8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.dataidx + $TESTTMP/hgcache/master/packs/8e25dec685d5e0bb1f1b39df3acebda0e0d75c6e.datapack + $TESTTMP/hgcache/repos + $ hg repack --traceback $ find $CACHEDIR -type f | sort diff --git a/tests/test-treemanifest-repack.t b/tests/test-treemanifest-repack.t --- a/tests/test-treemanifest-repack.t +++ b/tests/test-treemanifest-repack.t @@ -180,7 +180,8 @@ data/dir/b.i meta/dir/00manifest.i - $ hg repack +Also verify that --packsonly doesn't stop packs from being repacked: + $ hg repack --packsonly $ ls .hg/cache/packs/manifests 56e8c6f0ca2a324b8b5ca1a2730323a1b4d0793a.dataidx 56e8c6f0ca2a324b8b5ca1a2730323a1b4d0793a.datapack