Esempio n. 1
0
def get_metadata_revisions(app,
                           repository,
                           sort_revisions=True,
                           reverse=False,
                           downloadable=True):
    """
    Return a list of changesets for the provided repository.
    """
    sa_session = app.model.context.current
    if downloadable:
        metadata_revisions = repository.downloadable_revisions
    else:
        metadata_revisions = repository.metadata_revisions
    repo_path = repository.repo_path(app)
    changeset_tups = []
    for repository_metadata in metadata_revisions:
        if repository_metadata.numeric_revision == -1 or repository_metadata.numeric_revision is None:
            try:
                rev = changeset2rev(repo_path,
                                    repository_metadata.changeset_revision)
                repository_metadata.numeric_revision = rev
                sa_session.add(repository_metadata)
                sa_session.flush()
            except Exception:
                rev = -1
        else:
            rev = repository_metadata.numeric_revision
        changeset_tups.append((rev, repository_metadata.changeset_revision))
    if sort_revisions:
        changeset_tups.sort(key=itemgetter(0), reverse=reverse)
    return changeset_tups
Esempio n. 2
0
def get_repo_info_dict(app, user, repository_id, changeset_revision):
    repository = get_repository_in_tool_shed(app, repository_id)
    repository_clone_url = common_util.generate_clone_url_for_repository_in_tool_shed(
        user, repository)
    repository_metadata = get_repository_metadata_by_changeset_revision(
        app, repository_id, changeset_revision)
    if not repository_metadata:
        # The received changeset_revision is no longer installable, so get the next changeset_revision
        # in the repository's changelog.  This generally occurs only with repositories of type
        # repository_suite_definition or tool_dependency_definition.
        next_downloadable_changeset_revision = \
            get_next_downloadable_changeset_revision(app, repository, changeset_revision)
        if next_downloadable_changeset_revision and next_downloadable_changeset_revision != changeset_revision:
            repository_metadata = get_repository_metadata_by_changeset_revision(
                app, repository_id, next_downloadable_changeset_revision)
    if repository_metadata:
        # For now, we'll always assume that we'll get repository_metadata, but if we discover our assumption
        # is not valid we'll have to enhance the callers to handle repository_metadata values of None in the
        # returned repo_info_dict.
        metadata = repository_metadata.metadata
        if 'tools' in metadata:
            includes_tools = True
        else:
            includes_tools = False
        includes_tools_for_display_in_tool_panel = repository_metadata.includes_tools_for_display_in_tool_panel
        repository_dependencies_dict = metadata.get('repository_dependencies',
                                                    {})
        repository_dependencies = repository_dependencies_dict.get(
            'repository_dependencies', [])
        has_repository_dependencies, has_repository_dependencies_only_if_compiling_contained_td = \
            get_repository_dependency_types(repository_dependencies)
        if 'tool_dependencies' in metadata:
            includes_tool_dependencies = True
        else:
            includes_tool_dependencies = False
    else:
        # Here's where we may have to handle enhancements to the callers. See above comment.
        includes_tools = False
        has_repository_dependencies = False
        has_repository_dependencies_only_if_compiling_contained_td = False
        includes_tool_dependencies = False
        includes_tools_for_display_in_tool_panel = False
    repo_path = repository.repo_path(app)
    ctx_rev = str(changeset2rev(repo_path, changeset_revision))
    repo_info_dict = create_repo_info_dict(
        app=app,
        repository_clone_url=repository_clone_url,
        changeset_revision=changeset_revision,
        ctx_rev=ctx_rev,
        repository_owner=repository.user.username,
        repository_name=repository.name,
        repository=repository,
        repository_metadata=repository_metadata,
        tool_dependencies=None,
        repository_dependencies=None)
    return repo_info_dict, includes_tools, includes_tool_dependencies, includes_tools_for_display_in_tool_panel, \
        has_repository_dependencies, has_repository_dependencies_only_if_compiling_contained_td
def get_metadata_revisions(app, repository, sort_revisions=True, reverse=False, downloadable=True):
    """
    Return a list of changesets for the provided repository.
    """
    if downloadable:
        metadata_revisions = repository.downloadable_revisions
    else:
        metadata_revisions = repository.metadata_revisions
    repo_path = repository.repo_path(app)
    changeset_tups = []
    for repository_metadata in metadata_revisions:
        try:
            rev = hg_util.changeset2rev(repo_path, repository_metadata.changeset_revision)
        except Exception:
            rev = -1
        changeset_tups.append((rev, repository_metadata.changeset_revision))
    if sort_revisions:
        changeset_tups.sort(key=itemgetter(0), reverse=reverse)
    return changeset_tups
def get_metadata_revisions(app,
                           repository,
                           sort_revisions=True,
                           reverse=False,
                           downloadable=True):
    """
    Return a list of changesets for the provided repository.
    """
    if downloadable:
        metadata_revisions = repository.downloadable_revisions
    else:
        metadata_revisions = repository.metadata_revisions
    repo_path = repository.repo_path(app)
    changeset_tups = []
    for repository_metadata in metadata_revisions:
        try:
            rev = hg_util.changeset2rev(repo_path,
                                        repository_metadata.changeset_revision)
        except Exception:
            rev = -1
        changeset_tups.append((rev, repository_metadata.changeset_revision))
    if sort_revisions:
        changeset_tups.sort(key=itemgetter(0), reverse=reverse)
    return changeset_tups