# HG changeset patch # User Sean Farley # Date 1395678061 18000 # Node ID 3b96075bffa75bbc1c4986f7085df536324e05d8 # Parent 75745298d99d689df40e1f1842e9caa20d1414f1 maps: add custom __contains__ Similar to dict.__contains__ except we our own matching function, _findkey. diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py --- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -94,6 +94,10 @@ class BaseMap(dict): key = re.compile(re.escape(key)) super(BaseMap, self).__setitem__(key, value) + def __contains__(self, key): + '''Similar to dict.get, except we use our own matcher, _findkey.''' + return self._findkey(key) is not None + def load(self, path): '''Load mappings from a file at the specified path.''' path = os.path.expandvars(path)