def get_ordered_installable_revisions(self, trans, name, owner, **kwd): """ GET /api/repositories/get_ordered_installable_revisions :param name: the name of the Repository :param owner: the owner of the Repository Returns the ordered list of changeset revision hash strings that are associated with installable revisions. As in the changelog, the list is ordered oldest to newest. """ # Example URL: http://localhost:9009/api/repositories/get_installable_revisions?name=add_column&owner=test try: # Get the repository information. repository = suc.get_repository_by_name_and_owner( trans.app, name, owner) encoded_repository_id = trans.security.encode_id(repository.id) repo_dir = repository.repo_path(trans.app) repo = hg.repository(suc.get_configured_ui(), repo_dir) ordered_installable_revisions = suc.get_ordered_metadata_changeset_revisions( repository, repo, downloadable=True) return ordered_installable_revisions except Exception, e: message = "Error in the Tool Shed repositories API in get_ordered_installable_revisions: %s" % str( e) log.error(message, exc_info=True) trans.response.status = 500 return message
def get_ordered_installable_revisions( self, trans, name, owner, **kwd ): """ GET /api/repositories/get_ordered_installable_revisions :param name: the name of the Repository :param owner: the owner of the Repository Returns the ordered list of changeset revision hash strings that are associated with installable revisions. As in the changelog, the list is ordered oldest to newest. """ # Example URL: http://localhost:9009/api/repositories/get_installable_revisions?name=add_column&owner=test if name and owner: # Get the repository information. repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) if repository is None: error_message = "Error in the Tool Shed repositories API in get_ordered_installable_revisions: " error_message += "cannot locate repository %s owned by %s." % ( str( name ), str( owner ) ) log.debug( error_message ) return [] repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) ordered_installable_revisions = suc.get_ordered_metadata_changeset_revisions( repository, repo, downloadable=True ) return ordered_installable_revisions else: error_message = "Error in the Tool Shed repositories API in get_ordered_installable_revisions: " error_message += "invalid name %s or owner %s received." % ( str( name ), str( owner ) ) log.debug( error_message ) return []
def get_ordered_installable_revisions(self, trans, name, owner, **kwd): """ GET /api/repositories/get_ordered_installable_revisions :param name: the name of the Repository :param owner: the owner of the Repository Returns the ordered list of changeset revision hash strings that are associated with installable revisions. As in the changelog, the list is ordered oldest to newest. """ # Example URL: http://localhost:9009/api/repositories/get_installable_revisions?name=add_column&owner=test if name and owner: # Get the repository information. repository = suc.get_repository_by_name_and_owner( trans.app, name, owner) if repository is None: error_message = "Error in the Tool Shed repositories API in get_ordered_installable_revisions: " error_message += "cannot locate repository %s owned by %s." % ( str(name), str(owner)) log.debug(error_message) return [] repo = hg_util.get_repo_for_repository(trans.app, repository=repository, repo_path=None, create=False) ordered_installable_revisions = suc.get_ordered_metadata_changeset_revisions( repository, repo, downloadable=True) return ordered_installable_revisions else: error_message = "Error in the Tool Shed repositories API in get_ordered_installable_revisions: " error_message += "invalid name %s or owner %s received." % ( str(name), str(owner)) log.debug(error_message) return []
def get_previous_metadata_changeset_revision(repository, repo, before_changeset_revision, downloadable=True): """ Return the changeset_revision in the repository changelog that has associated metadata prior to the changeset to which before_changeset_revision refers. If there isn't one, return the hash value of an empty repository changelog, hg_util.INITIAL_CHANGELOG_HASH. """ changeset_revisions = suc.get_ordered_metadata_changeset_revisions( repository, repo, downloadable=downloadable) if len(changeset_revisions) == 1: changeset_revision = changeset_revisions[0] if changeset_revision == before_changeset_revision: return hg_util.INITIAL_CHANGELOG_HASH return changeset_revision previous_changeset_revision = None for changeset_revision in changeset_revisions: if changeset_revision == before_changeset_revision: if previous_changeset_revision: return previous_changeset_revision else: # Return the hash value of an empty repository changelog - note that this will not be a valid changeset revision. return hg_util.INITIAL_CHANGELOG_HASH else: previous_changeset_revision = changeset_revision
def get_latest_changeset_revision( app, repository, repo ): repository_tip = repository.tip( app ) repository_metadata = suc.get_repository_metadata_by_changeset_revision( app, app.security.encode_id( repository.id ), repository_tip ) if repository_metadata and repository_metadata.downloadable: return repository_tip changeset_revisions = suc.get_ordered_metadata_changeset_revisions( repository, repo, downloadable=False ) if changeset_revisions: return changeset_revisions[ -1 ] return hg_util.INITIAL_CHANGELOG_HASH
def should_set_do_not_test_flag( app, repository, changeset_revision, testable_revision ): """ The received testable_revision is True if the tool has defined tests and test files are in the repository This method returns True if the received repository has multiple downloadable revisions and the received changeset_revision is not the most recent downloadable revision and the received testable_revision is False. In this case, the received changeset_revision will never be updated with correct data, and re-testing it would be redundant. """ if not testable_revision: repo = hg_util.get_repo_for_repository( app, repository=repository, repo_path=None, create=False ) changeset_revisions = suc.get_ordered_metadata_changeset_revisions( repository, repo, downloadable=True ) if len( changeset_revisions ) > 1: latest_downloadable_revision = changeset_revisions[ -1 ] if changeset_revision != latest_downloadable_revision: return True return False
def should_set_do_not_test_flag(app, repository, changeset_revision, testable_revision): """ The received testable_revision is True if the tool has defined tests and test files are in the repository This method returns True if the received repository has multiple downloadable revisions and the received changeset_revision is not the most recent downloadable revision and the received testable_revision is False. In this case, the received changeset_revision will never be updated with correct data, and re-testing it would be redundant. """ if not testable_revision: repo = hg_util.get_repo_for_repository(app, repository=repository, repo_path=None, create=False) changeset_revisions = suc.get_ordered_metadata_changeset_revisions( repository, repo, downloadable=True) if len(changeset_revisions) > 1: latest_downloadable_revision = changeset_revisions[-1] if changeset_revision != latest_downloadable_revision: return True return False
def get_previous_metadata_changeset_revision( repository, repo, before_changeset_revision, downloadable=True ): """ Return the changeset_revision in the repository changelog that has associated metadata prior to the changeset to which before_changeset_revision refers. If there isn't one, return the hash value of an empty repository changelog, hg_util.INITIAL_CHANGELOG_HASH. """ changeset_revisions = suc.get_ordered_metadata_changeset_revisions( repository, repo, downloadable=downloadable ) if len( changeset_revisions ) == 1: changeset_revision = changeset_revisions[ 0 ] if changeset_revision == before_changeset_revision: return hg_util.INITIAL_CHANGELOG_HASH return changeset_revision previous_changeset_revision = None for changeset_revision in changeset_revisions: if changeset_revision == before_changeset_revision: if previous_changeset_revision: return previous_changeset_revision else: # Return the hash value of an empty repository changelog - note that this will not be a valid changeset revision. return hg_util.INITIAL_CHANGELOG_HASH else: previous_changeset_revision = changeset_revision
def get_ordered_installable_revisions( self, trans, name, owner, **kwd ): """ GET /api/repositories/get_ordered_installable_revisions :param name: the name of the Repository :param owner: the owner of the Repository Returns the ordered list of changeset revision hash strings that are associated with installable revisions. As in the changelog, the list is ordered oldest to newest. """ # Example URL: http://localhost:9009/api/repositories/get_installable_revisions?name=add_column&owner=test try: # Get the repository information. repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) repo_dir = repository.repo_path( trans.app ) repo = hg.repository( suc.get_configured_ui(), repo_dir ) ordered_installable_revisions = suc.get_ordered_metadata_changeset_revisions( repository, repo, downloadable=True ) return ordered_installable_revisions except Exception, e: message = "Error in the Tool Shed repositories API in get_ordered_installable_revisions: %s" % str( e ) log.error( message, exc_info=True ) trans.response.status = 500 return message