remotefilelog: make repack work for non-remotefilelog repos

Summary:
treemanifest also has the concept of repack and shares the same code as
remotefilelog's repack. We want treemanifest to be usable even without
remotefilelog, so let's update the repack code to not require the presence of
remotefilelog configured members on the repo object.

In the long term we'll probably move the repack and pack code out of
remotefilelog entirely.

Test Plan: A future patch adds a test that caught this

Reviewers: #mercurial, dsyang, rmcelroy

Reviewed By: rmcelroy

Subscribers: mjpieters

Differential Revision: https://phabricator.intern.facebook.com/D4261571

Signature: t1:4261571:1480705343:2ceabbbbdeaf7408ef8b94ad3e670b9423162399
This commit is contained in:
Durham Goode 2016-12-02 14:37:49 -08:00
parent edd8b25c30
commit 27e07eeed4

View File

@ -19,13 +19,17 @@ def backgroundrepack(repo, incremental=True):
runshellcommand(cmd, os.environ)
def fullrepack(repo):
datasource = contentstore.unioncontentstore(*repo.shareddatastores)
historysource = metadatastore.unionmetadatastore(*repo.sharedhistorystores,
allowincomplete=True)
if util.safehasattr(repo, 'shareddatastores'):
datasource = contentstore.unioncontentstore(*repo.shareddatastores)
historysource = metadatastore.unionmetadatastore(
*repo.sharedhistorystores,
allowincomplete=True)
packpath = shallowutil.getcachepackpath(repo, constants.FILEPACK_CATEGORY)
_runrepack(repo, datasource, historysource, packpath,
constants.FILEPACK_CATEGORY)
packpath = shallowutil.getcachepackpath(
repo,
constants.FILEPACK_CATEGORY)
_runrepack(repo, datasource, historysource, packpath,
constants.FILEPACK_CATEGORY)
if util.safehasattr(repo.svfs, 'manifestdatastore'):
# Repack the shared manifest store
@ -53,12 +57,15 @@ def incrementalrepack(repo):
"""This repacks the repo by looking at the distribution of pack files in the
repo and performing the most minimal repack to keep the repo in good shape.
"""
packpath = shallowutil.getcachepackpath(repo, constants.FILEPACK_CATEGORY)
_incrementalrepack(repo,
repo.shareddatastores,
repo.sharedhistorystores,
packpath,
constants.FILEPACK_CATEGORY)
if util.safehasattr(repo, 'shareddatastores'):
packpath = shallowutil.getcachepackpath(
repo,
constants.FILEPACK_CATEGORY)
_incrementalrepack(repo,
repo.shareddatastores,
repo.sharedhistorystores,
packpath,
constants.FILEPACK_CATEGORY)
if util.safehasattr(repo.svfs, 'manifestdatastore'):
# Repack the shared manifest store