Mercurial > hgsubversion
changeset 1380:332ad9ea579b
maps: add custom __contains__ to author map
We add a custom __contains__ method to AuthorMap so that we can encapsulate the
meta.caseignoreauthor logic.
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Mon, 24 Mar 2014 11:20:58 -0500 |
parents | 367e65989b41 |
children | 2522049c6bed |
files | hgsubversion/maps.py |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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