view hgsubversion/layouts/__init__.py @ 1265:4744b7bfa476

layouts: change constructor to take a meta object This change is another step forward to centralize subversion configuration options and help refactor. I couldn't find an easier way to split up this change since there are many interdependent function calls. There is no functionality change in this patch, only renaming ui -> meta.
author Sean Farley <sean.michael.farley@gmail.com>
date Mon, 24 Mar 2014 11:20:49 -0500
parents eded1e736a7e
children 14dab195b2b4
line wrap: on
line source

"""Code for dealing with subversion layouts

This package is intended to encapsulate everything about subversion
layouts.  This includes detecting the layout based on looking at
subversion, mapping subversion paths to hg branches, and doing any
other path translation necessary.

NB: this has a long way to go before it does everything it claims to

"""

from mercurial import util as hgutil

import custom
import detect
import single
import standard

__all__ = [
    "detect",
    "layout_from_name",
    ]

# This is the authoritative store of what layouts are available.
# The intention is for extension authors who wish to build their own
# layout to add it to this dict.
NAME_TO_CLASS = {
    "custom": custom.CustomLayout,
    "single": single.SingleLayout,
    "standard": standard.StandardLayout,
}


def layout_from_name(name, meta):
    """Returns a layout module given the layout name

    You should use one of the layout.detect.* functions to get the
    name to pass to this function.

    """

    if name not in NAME_TO_CLASS:
        raise hgutil.Abort('Unknown hgsubversion layout: %s' % name)
    return NAME_TO_CLASS[name](meta)