@classmethod
def to_hg_scheme_url(cls, url):
    """
        convert a URL to local mercurial URL schemes

        example::

            # schemes.gh = git://github.com/
            >> remote_url = git://github.com/westurner/dotfiles'
            >> to_hg_scheme_url(remote_url)
            << gh://westurner/dotfiles

        """
    regexes = cls._get_url_scheme_regexes()
    for scheme_key, pattern, regex in regexes:
        match = regex.match(url)
        if match is not None:
            groups = match.groups()
            if len(groups) == 2:
                return u''.join(scheme_key, '://', pattern.replace('{1}',
                    groups[0]), groups[1])
            elif len(groups) == 1:
                return u''.join(scheme_key, '://', pattern, groups[0])
