Exemplo n.º 1
0
def absolute(builder, co_dir, co_name, repo_url, rev=None, branch=None):
    """
    Check out a multilevel repository from an absolute URL.

    <repo_url> must be of the form <vcs>+<url>, where <vcs> is one of the
    support version control systems (e.g., 'git', 'svn').

    <rev> may be a revision (specified as a string). "HEAD" (or its equivalent)
    is assumed by default.

    <branch> may be a branch. "master" (or its equivalent) is assumed by
    default.

    The repository <repo_url> will be checked out into src/<co_dir>. The
    checkout will be identified by the label checkout:<co_name>/checked_out.
    """

    vcs, base_url = split_vcs_url(repo_url)

    repo = Repository.from_url(vcs, base_url, revision=rev, branch=branch)

    # The version control handler wants to know the "leaf" separately
    # from the rest of the checkout path relative to src/
    co_dir_dir, co_dir_leaf = os.path.split(co_dir)

    co_label = Label(utils.LabelType.Checkout, co_name, domain=builder.default_domain)
    checkout_from_repo(builder, co_label, repo, co_dir=co_dir_dir, co_leaf=co_dir_leaf)
Exemplo n.º 2
0
def relative(builder, co_name, repo_relative=None, rev=None, branch=None):
    """
    A simple, VCS-controlled, checkout.

    <rev> may be a revision (specified as a string). "HEAD" (or its equivalent)
    is assumed by default.

    <branch> may be a branch. "master" (or its equivalent) is assumed by
    default.

    If <repo_relative> is None then the repository <base_url>/<co_name> will
    be checked out into src/<co_name>, where <base_url> is the base URL as
    specified in .muddle/RootRepository (i.e., the base URL of the build
    description, as used in "muddle init").

    For example::

        <base_url>/<co_name>  -->  src/<co_name>

    If <repo_relative> is not None, then the repository
    <base_url>/<repo_relative> will be checked out instead::

        <base_url>/<repo_relative>  -->  src/<co_name>
    """

    base_repo = builder.build_desc_repo
    if repo_relative:
        repo_url = urljoin(base_repo.base_url, repo_relative)
        repo = Repository.from_url(base_repo.vcs, repo_url,
                                   revision=rev, branch=branch)
    else:
        repo = base_repo.copy_with_changes(co_name, revision=rev, branch=branch)

    co_label = Label(utils.LabelType.Checkout, co_name, domain=builder.default_domain)
    checkout_from_repo(builder, co_label, repo)
Exemplo n.º 3
0
def absolute(builder, co_dir, co_name, repo_url, rev=None, branch=None):
    """
    Check out a twolevel repository from an absolute URL.

    <repo_url> must be of the form <vcs>+<url>, where <vcs> is one of the
    support version control systems (e.g., 'git', 'svn').

    <rev> may be a revision (specified as a string). "HEAD" (or its equivalent)
    is assumed by default.

    <branch> may be a branch. "master" (or its equivalent) is assumed by
    default.

    The repository <repo_url>/<co_name> will be checked out into
    src/<co_dir>/<co_name>.
    """

    co_path = os.path.join(co_dir, co_name)

    vcs, base_url = split_vcs_url(repo_url)
    repo = Repository.from_url(vcs, base_url, revision=rev, branch=branch)
    co_label = Label(utils.LabelType.Checkout,
                     co_name,
                     domain=builder.default_domain)
    checkout_from_repo(builder, co_label, repo, co_dir=co_dir)
Exemplo n.º 4
0
def relative(builder, co_dir, co_name, repo_relative = None, rev = None, branch = None):
    """
    A two-level version of checkout.simple.relative().

    It attempts to check out <co_dir>/<co_name> (but see below).

    <rev> may be a revision (specified as a string). "HEAD" (or its equivalent)
    is assumed by default.

    <branch> may be a branch. "master" (or its equivalent) is assumed by
    default.

    If <repo_relative> is None then the repository <base_url>/<co_name> will
    be checked out, where <base_url> is the base URL as specified in
    .muddle/RootRepository (i.e., the base URL of the build description, as
    used in "muddle init").

    If <repo_relative> is not None, then the repository
    <base_url>/<repo_relative> ...

    In the normal case, the location in the repository and in the checkout
    is assumed the same (i.e., <co_dir>/<co_name>). So, for instance, with
    co_dir="A" and co_name="B", the repository would have::

        <base_url>/A/B

    which we would check out into::

        src/A/B

    Occasionally, though, the repository is organised differently, so for
    instance, one might want to checkout::

        <base_url>/B

    into::

        src/A/B

    In this latter case, one can use the 'repo_relative' argument, to say where
    the checkout is relative to the repository's "base". So, in the example
    above, we still have co_dir="A" and co_name="B", but we also want to say
    repo_relative=B.
    """

    base_repo = builder.build_desc_repo
    if repo_relative:
        repo_co_dir, repo_co_name = os.path.split(repo_relative)
        repo = base_repo.copy_with_changes(repo_co_name, prefix=repo_co_dir,
                                           revision=rev, branch=branch)
    else:
        repo = base_repo.copy_with_changes(co_name, prefix=co_dir,
                                           revision=rev, branch=branch)

    co_label = Label(utils.LabelType.Checkout, co_name, domain=builder.default_domain)
    checkout_from_repo(builder, co_label, repo, co_dir=co_dir)
Exemplo n.º 5
0
def absolute(builder, co_name, repo_url, rev=None, branch=None):
    """
    Check out a repository from an absolute URL.

    <repo_url> must be of the form <vcs>+<url>, where <vcs> is one of the
    support version control systems (e.g., 'git', 'svn').

    <rev> may be a revision (specified as a string). "HEAD" (or its equivalent)
    is assumed by default.

    <branch> may be a branch. "master" (or its equivalent) is assumed by
    default.

    The repository <repo_url>/<co_name> will be checked out into src/<co_name>.
    """

    vcs, base_url = split_vcs_url(repo_url)
    repo = Repository.from_url(vcs, base_url, revision=rev, branch=branch)
    co_label = Label(utils.LabelType.Checkout, co_name, domain=builder.default_domain)
    checkout_from_repo(builder, co_label, repo)
Exemplo n.º 6
0
def relative(builder, co_dir, co_name, repo_relative = None, rev = None,
             branch = None):
    """
    A multilevel checkout, with checkout name unrelated to checkout directory.

    Sometimes it is necessary to cope with checkouts that either:

        a. are more than two directories below src/, or
        b. have a checkout name that is not the same as the "leaf"
           directory in their path

    Both of these can happen when trying to represent an Android build,
    for instance.

    Thus::

      multilevel.relative(builder, co_dir='this/is/here', co_name='checkout1')

    will look for the repository <base_url>/this/is/here and check it out
    into src/this/is/here, but give it label checkout:checkout1/checked_out.

       (<base_url> is the base URL as specified in .muddle/RootRepository
       (i.e., the base URL of the build description, as used in "muddle init").

    For the moment, <repo_relative> is ignored.
    """
    base_repo = builder.build_desc_repo

    # urljoin doesn't work well with the sort of path fragment we tend to have
    repo_url = posixpath.join(base_repo.base_url, co_dir)
    repo = Repository.from_url(base_repo.vcs, repo_url,
                               revision=rev, branch=branch)

    # The version control handler wants to know the "leaf" separately
    # from the rest of the checkout path relative to src/
    co_dir_dir, co_dir_leaf = os.path.split(co_dir)

    co_label = Label(utils.LabelType.Checkout, co_name, domain=builder.default_domain)
    checkout_from_repo(builder, co_label, repo, co_dir=co_dir_dir, co_leaf=co_dir_leaf)
Exemplo n.º 7
0
def relative(builder,
             co_dir,
             co_name,
             repo_relative=None,
             rev=None,
             branch=None):
    """
    A two-level version of checkout.simple.relative().

    It attempts to check out <co_dir>/<co_name> (but see below).

    <rev> may be a revision (specified as a string). "HEAD" (or its equivalent)
    is assumed by default.

    <branch> may be a branch. "master" (or its equivalent) is assumed by
    default.

    If <repo_relative> is None then the repository <base_url>/<co_name> will
    be checked out, where <base_url> is the base URL as specified in
    .muddle/RootRepository (i.e., the base URL of the build description, as
    used in "muddle init").

    If <repo_relative> is not None, then the repository
    <base_url>/<repo_relative> ...

    In the normal case, the location in the repository and in the checkout
    is assumed the same (i.e., <co_dir>/<co_name>). So, for instance, with
    co_dir="A" and co_name="B", the repository would have::

        <base_url>/A/B

    which we would check out into::

        src/A/B

    Occasionally, though, the repository is organised differently, so for
    instance, one might want to checkout::

        <base_url>/B

    into::

        src/A/B

    In this latter case, one can use the 'repo_relative' argument, to say where
    the checkout is relative to the repository's "base". So, in the example
    above, we still have co_dir="A" and co_name="B", but we also want to say
    repo_relative=B.
    """

    base_repo = builder.build_desc_repo
    if repo_relative:
        repo_co_dir, repo_co_name = os.path.split(repo_relative)
        repo = base_repo.copy_with_changes(repo_co_name,
                                           prefix=repo_co_dir,
                                           revision=rev,
                                           branch=branch)
    else:
        repo = base_repo.copy_with_changes(co_name,
                                           prefix=co_dir,
                                           revision=rev,
                                           branch=branch)

    co_label = Label(utils.LabelType.Checkout,
                     co_name,
                     domain=builder.default_domain)
    checkout_from_repo(builder, co_label, repo, co_dir=co_dir)