Mercurial > public > mercurial-scm > hg-stable
diff hgext/sparse.py @ 33317:df1287268cc0
sparse: move config signature logic into core
This is a pretty straightforward port. It will be cleaned up in
a subsequent commit.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 06 Jul 2017 16:11:56 -0700 |
parents | 310f7bcab50b |
children | 3c84591e7321 |
line wrap: on
line diff
--- a/hgext/sparse.py Thu Jul 06 17:31:33 2017 -0700 +++ b/hgext/sparse.py Thu Jul 06 16:11:56 2017 -0700 @@ -75,7 +75,6 @@ from __future__ import absolute_import import collections -import hashlib import os from mercurial.i18n import _ @@ -405,38 +404,6 @@ def _wraprepo(ui, repo): class SparseRepo(repo.__class__): - def _sparsechecksum(self, path): - data = self.vfs.read(path) - return hashlib.sha1(data).hexdigest() - - def _sparsesignature(self, includetemp=True): - """Returns the signature string representing the contents of the - current project sparse configuration. This can be used to cache the - sparse matcher for a given set of revs.""" - signaturecache = self._sparsesignaturecache - signature = signaturecache.get('signature') - if includetemp: - tempsignature = signaturecache.get('tempsignature') - else: - tempsignature = 0 - - if signature is None or (includetemp and tempsignature is None): - signature = 0 - try: - signature = self._sparsechecksum('sparse') - except (OSError, IOError): - pass - signaturecache['signature'] = signature - - tempsignature = 0 - if includetemp: - try: - tempsignature = self._sparsechecksum('tempsparse') - except (OSError, IOError): - pass - signaturecache['tempsignature'] = tempsignature - return '%s %s' % (str(signature), str(tempsignature)) - def sparsematch(self, *revs, **kwargs): """Returns the sparse match function for the given revs. @@ -451,7 +418,7 @@ self.dirstate.parents() if node != nullid] includetemp = kwargs.get('includetemp', True) - signature = self._sparsesignature(includetemp=includetemp) + signature = sparse.configsignature(self, includetemp=includetemp) key = '%s %s' % (str(signature), ' '.join([str(r) for r in revs]))