# HG changeset patch # User Sean Farley # Date 1395678058 18000 # Node ID 332ad9ea579bd8458c7454752b4c1ed76627196f # Parent 367e65989b41394e898badcbb0fb7747cc27d0cd maps: add custom __contains__ to author map We add a custom __contains__ method to AuthorMap so that we can encapsulate the meta.caseignoreauthor logic. diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py --- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -96,6 +96,14 @@ class AuthorMap(dict): key = key.lower() super(AuthorMap, self).__setitem__(key, value) + def __contains__(self, key): + '''Similar to dict.__contains__, except we check caseignoreauthors to + use lowercase string or not + ''' + if self.meta.caseignoreauthors: + key = key.lower() + return super(AuthorMap, self).__contains__(key) + def __getitem__(self, author): ''' Similar to dict.__getitem__, except in case of an unknown author. In such cases, a new value is generated and added to the dictionary