hgext/remotefilelog/repack.py
changeset 50928 d718eddf01d9
parent 49284 d44e3c45f0e4
equal deleted inserted replaced
50927:7a8ea1397816 50928:d718eddf01d9
    47     procutil.runbgcommand(cmd, encoding.environ, ensurestart=False, **kwargs)
    47     procutil.runbgcommand(cmd, encoding.environ, ensurestart=False, **kwargs)
    48 
    48 
    49 
    49 
    50 def fullrepack(repo, options=None):
    50 def fullrepack(repo, options=None):
    51     """If ``packsonly`` is True, stores creating only loose objects are skipped."""
    51     """If ``packsonly`` is True, stores creating only loose objects are skipped."""
    52     if util.safehasattr(repo, 'shareddatastores'):
    52     if hasattr(repo, 'shareddatastores'):
    53         datasource = contentstore.unioncontentstore(*repo.shareddatastores)
    53         datasource = contentstore.unioncontentstore(*repo.shareddatastores)
    54         historysource = metadatastore.unionmetadatastore(
    54         historysource = metadatastore.unionmetadatastore(
    55             *repo.sharedhistorystores, allowincomplete=True
    55             *repo.sharedhistorystores, allowincomplete=True
    56         )
    56         )
    57 
    57 
    65             packpath,
    65             packpath,
    66             constants.FILEPACK_CATEGORY,
    66             constants.FILEPACK_CATEGORY,
    67             options=options,
    67             options=options,
    68         )
    68         )
    69 
    69 
    70     if util.safehasattr(repo.manifestlog, 'datastore'):
    70     if hasattr(repo.manifestlog, 'datastore'):
    71         localdata, shareddata = _getmanifeststores(repo)
    71         localdata, shareddata = _getmanifeststores(repo)
    72         lpackpath, ldstores, lhstores = localdata
    72         lpackpath, ldstores, lhstores = localdata
    73         spackpath, sdstores, shstores = shareddata
    73         spackpath, sdstores, shstores = shareddata
    74 
    74 
    75         # Repack the shared manifest store
    75         # Repack the shared manifest store
   105 
   105 
   106 def incrementalrepack(repo, options=None):
   106 def incrementalrepack(repo, options=None):
   107     """This repacks the repo by looking at the distribution of pack files in the
   107     """This repacks the repo by looking at the distribution of pack files in the
   108     repo and performing the most minimal repack to keep the repo in good shape.
   108     repo and performing the most minimal repack to keep the repo in good shape.
   109     """
   109     """
   110     if util.safehasattr(repo, 'shareddatastores'):
   110     if hasattr(repo, 'shareddatastores'):
   111         packpath = shallowutil.getcachepackpath(
   111         packpath = shallowutil.getcachepackpath(
   112             repo, constants.FILEPACK_CATEGORY
   112             repo, constants.FILEPACK_CATEGORY
   113         )
   113         )
   114         _incrementalrepack(
   114         _incrementalrepack(
   115             repo,
   115             repo,
   118             packpath,
   118             packpath,
   119             constants.FILEPACK_CATEGORY,
   119             constants.FILEPACK_CATEGORY,
   120             options=options,
   120             options=options,
   121         )
   121         )
   122 
   122 
   123     if util.safehasattr(repo.manifestlog, 'datastore'):
   123     if hasattr(repo.manifestlog, 'datastore'):
   124         localdata, shareddata = _getmanifeststores(repo)
   124         localdata, shareddata = _getmanifeststores(repo)
   125         lpackpath, ldstores, lhstores = localdata
   125         lpackpath, ldstores, lhstores = localdata
   126         spackpath, sdstores, shstores = shareddata
   126         spackpath, sdstores, shstores = shareddata
   127 
   127 
   128         # Repack the shared manifest store
   128         # Repack the shared manifest store
   893         # If garbage collected
   893         # If garbage collected
   894         self.gced = False
   894         self.gced = False
   895 
   895 
   896 
   896 
   897 def repacklockvfs(repo):
   897 def repacklockvfs(repo):
   898     if util.safehasattr(repo, 'name'):
   898     if hasattr(repo, 'name'):
   899         # Lock in the shared cache so repacks across multiple copies of the same
   899         # Lock in the shared cache so repacks across multiple copies of the same
   900         # repo are coordinated.
   900         # repo are coordinated.
   901         sharedcachepath = shallowutil.getcachepackpath(
   901         sharedcachepath = shallowutil.getcachepackpath(
   902             repo, constants.FILEPACK_CATEGORY
   902             repo, constants.FILEPACK_CATEGORY
   903         )
   903         )