Mercurial > hg
comparison tests/hghave.py @ 37338:cbc4425e81b5
tests: conditionalize tests based on presence of revlogs for files
~85 tests don't like our non-revlog file store for various reasons.
This commit introduces hghave functionality for declaring and querying
repository features. By default, we assume repositories have
revlog-based file storage. But if the HGREPOFEATURES environment
variable is set, we can override the default set of repository
features. If you run the test harness with our simplestorerepo
extension and an environment variable set to the proper value, you
can override the hghave defaults to agree with simplestorerepo's
version of reality.
Various tests have been modified so behavior dependent on revlog-based
file storage is marked as such.
This fixes a handful of test failures with our custom file storage
extension. But dozens remain. The point of this commit is to demonstrate
how tests will need to be modified to account for custom storage
implementations.
TBH, I'm not convinced hghave is the proper layer for repository
feature detection. I /think/ we'll eventually want something in
run-tests.py itself. But that would require inventing a new primitive
in the test harness. This is all very alpha at the moment. So I think
hghave is an acceptable place to hang this feature detection. I think
the right time to be thinking about integrating this into run-tests.py
is *after* we have a stable alternate storage implementation in core.
For now, let's try to make progress towards the idea of an alternate
storage backend.
Differential Revision: https://phab.mercurial-scm.org/D3030
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 03 Apr 2018 18:15:24 -0700 |
parents | bf73012877a4 |
children | 4e6a6d0dccee |
comparison
equal
deleted
inserted
replaced
37337:d257c5f2a940 | 37338:cbc4425e81b5 |
---|---|
715 from mercurial import policy | 715 from mercurial import policy |
716 bdiff = policy.importmod('bdiff') | 716 bdiff = policy.importmod('bdiff') |
717 return bdiff.xdiffblocks(b'', b'') == [(0, 0, 0, 0)] | 717 return bdiff.xdiffblocks(b'', b'') == [(0, 0, 0, 0)] |
718 except (ImportError, AttributeError): | 718 except (ImportError, AttributeError): |
719 return False | 719 return False |
720 | |
721 def getrepofeatures(): | |
722 """Obtain set of repository features in use. | |
723 | |
724 HGREPOFEATURES can be used to define or remove features. It contains | |
725 a space-delimited list of feature strings. Strings beginning with ``-`` | |
726 mean to remove. | |
727 """ | |
728 # Default list provided by core. | |
729 features = { | |
730 'revlogstore', | |
731 } | |
732 | |
733 # Features that imply other features. | |
734 implies = { | |
735 'simplestore': ['-revlogstore'], | |
736 } | |
737 | |
738 for override in os.environ.get('HGREPOFEATURES', '').split(' '): | |
739 if not override: | |
740 continue | |
741 | |
742 if override.startswith('-'): | |
743 if override[1:] in features: | |
744 features.remove(override[1:]) | |
745 else: | |
746 features.add(override) | |
747 | |
748 for imply in implies.get(override, []): | |
749 if imply.startswith('-'): | |
750 if imply[1:] in features: | |
751 features.remove(imply[1:]) | |
752 else: | |
753 features.add(imply) | |
754 | |
755 return features | |
756 | |
757 @check('reporevlogstore', 'repository using the default revlog store') | |
758 def has_reporevlogstore(): | |
759 return 'revlogstore' in getrepofeatures() | |
760 | |
761 @check('reposimplestore', 'repository using simple storage extension') | |
762 def has_reposimplestore(): | |
763 return 'simplestore' in getrepofeatures() |