403 return orig(self, *args) |
402 return orig(self, *args) |
404 extensions.wrapfunction(dirstate.dirstate, func, _wrapper) |
403 extensions.wrapfunction(dirstate.dirstate, func, _wrapper) |
405 |
404 |
406 def _wraprepo(ui, repo): |
405 def _wraprepo(ui, repo): |
407 class SparseRepo(repo.__class__): |
406 class SparseRepo(repo.__class__): |
408 def _sparsechecksum(self, path): |
|
409 data = self.vfs.read(path) |
|
410 return hashlib.sha1(data).hexdigest() |
|
411 |
|
412 def _sparsesignature(self, includetemp=True): |
|
413 """Returns the signature string representing the contents of the |
|
414 current project sparse configuration. This can be used to cache the |
|
415 sparse matcher for a given set of revs.""" |
|
416 signaturecache = self._sparsesignaturecache |
|
417 signature = signaturecache.get('signature') |
|
418 if includetemp: |
|
419 tempsignature = signaturecache.get('tempsignature') |
|
420 else: |
|
421 tempsignature = 0 |
|
422 |
|
423 if signature is None or (includetemp and tempsignature is None): |
|
424 signature = 0 |
|
425 try: |
|
426 signature = self._sparsechecksum('sparse') |
|
427 except (OSError, IOError): |
|
428 pass |
|
429 signaturecache['signature'] = signature |
|
430 |
|
431 tempsignature = 0 |
|
432 if includetemp: |
|
433 try: |
|
434 tempsignature = self._sparsechecksum('tempsparse') |
|
435 except (OSError, IOError): |
|
436 pass |
|
437 signaturecache['tempsignature'] = tempsignature |
|
438 return '%s %s' % (str(signature), str(tempsignature)) |
|
439 |
|
440 def sparsematch(self, *revs, **kwargs): |
407 def sparsematch(self, *revs, **kwargs): |
441 """Returns the sparse match function for the given revs. |
408 """Returns the sparse match function for the given revs. |
442 |
409 |
443 If multiple revs are specified, the match function is the union |
410 If multiple revs are specified, the match function is the union |
444 of all the revs. |
411 of all the revs. |
449 if not revs or revs == (None,): |
416 if not revs or revs == (None,): |
450 revs = [self.changelog.rev(node) for node in |
417 revs = [self.changelog.rev(node) for node in |
451 self.dirstate.parents() if node != nullid] |
418 self.dirstate.parents() if node != nullid] |
452 |
419 |
453 includetemp = kwargs.get('includetemp', True) |
420 includetemp = kwargs.get('includetemp', True) |
454 signature = self._sparsesignature(includetemp=includetemp) |
421 signature = sparse.configsignature(self, includetemp=includetemp) |
455 |
422 |
456 key = '%s %s' % (str(signature), ' '.join([str(r) for r in revs])) |
423 key = '%s %s' % (str(signature), ' '.join([str(r) for r in revs])) |
457 |
424 |
458 result = self._sparsematchercache.get(key, None) |
425 result = self._sparsematchercache.get(key, None) |
459 if result: |
426 if result: |