commit/galaxy-central: greg: Add tool shed features for displaying repository heads and alerting users if a repository has multiple heads that require merging.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/56b61e7d5bbc/ Changeset: 56b61e7d5bbc User: greg Date: 2014-01-10 22:30:45 Summary: Add tool shed features for displaying repository heads and alerting users if a repository has multiple heads that require merging. Affected #: 6 files diff -r 4ab2017348e25958bcd8babd8e110f574dff24df -r 56b61e7d5bbcea1dff823cf78229289480ee15e7 lib/galaxy/webapps/tool_shed/controllers/repository.py --- a/lib/galaxy/webapps/tool_shed/controllers/repository.py +++ b/lib/galaxy/webapps/tool_shed/controllers/repository.py @@ -2255,6 +2255,7 @@ categories = suc.get_categories( trans ) selected_categories = [ rca.category_id for rca in repository.categories ] containers_dict = container_util.build_repository_containers_for_tool_shed( trans, repository, changeset_revision, repository_dependencies, repository_metadata ) + heads = suc.get_repository_heads( repo ) return trans.fill_template( '/webapps/tool_shed/repository/manage_repository.mako', repo_name=repo_name, description=description, @@ -2262,6 +2263,7 @@ current_allow_push_list=current_allow_push_list, allow_push_select_field=allow_push_select_field, repo=repo, + heads=heads, repository=repository, containers_dict=containers_dict, repository_metadata=repository_metadata, @@ -3043,8 +3045,10 @@ status = 'error' containers_dict = container_util.build_repository_containers_for_tool_shed( trans, repository, changeset_revision, repository_dependencies, repository_metadata ) repository_type_select_field = rt_util.build_repository_type_select_field( trans, repository=repository ) + heads = suc.get_repository_heads( repo ) return trans.fill_template( '/webapps/tool_shed/repository/view_repository.mako', repo=repo, + heads=heads, repository=repository, repository_metadata=repository_metadata, metadata=metadata, diff -r 4ab2017348e25958bcd8babd8e110f574dff24df -r 56b61e7d5bbcea1dff823cf78229289480ee15e7 lib/tool_shed/grids/admin_grids.py --- a/lib/tool_shed/grids/admin_grids.py +++ b/lib/tool_shed/grids/admin_grids.py @@ -365,6 +365,7 @@ key="name", link=( lambda item: dict( operation="view_or_manage_repository", id=item.id ) ), attach_popup=True ), + RepositoryGrid.HeadsColumn( "Heads" ), RepositoryGrid.UserColumn( "Owner", model_class=model.User, link=( lambda item: dict( operation="repositories_by_user", id=item.id ) ), diff -r 4ab2017348e25958bcd8babd8e110f574dff24df -r 56b61e7d5bbcea1dff823cf78229289480ee15e7 lib/tool_shed/grids/repository_grids.py --- a/lib/tool_shed/grids/repository_grids.py +++ b/lib/tool_shed/grids/repository_grids.py @@ -89,6 +89,29 @@ return escape_html( type_class.label ) + class HeadsColumn( grids.GridColumn ): + + def __init__( self, col_name ): + grids.GridColumn.__init__( self, col_name ) + + def get_value( self, trans, grid, repository ): + """Display the current repository heads.""" + repo_dir = repository.repo_path( trans.app ) + repo = hg.repository( suc.get_configured_ui(), repo_dir ) + heads = suc.get_repository_heads( repo ) + multiple_heads = len( heads ) > 1 + if multiple_heads: + heads_str = '<font color="red">' + else: + heads_str = '' + for ctx in heads: + heads_str += '%s<br/>' % suc.get_revision_label_from_ctx( ctx ) + heads_str.rstrip( '<br/>' ) + if multiple_heads: + heads_str += '</font>' + return heads_str + + class MetadataRevisionColumn( grids.GridColumn ): def __init__( self, col_name ): diff -r 4ab2017348e25958bcd8babd8e110f574dff24df -r 56b61e7d5bbcea1dff823cf78229289480ee15e7 lib/tool_shed/util/shed_util_common.py --- a/lib/tool_shed/util/shed_util_common.py +++ b/lib/tool_shed/util/shed_util_common.py @@ -1108,6 +1108,11 @@ # This should never be reached - raise an exception? return v, None +def get_repository_heads( repo ): + """Return current repository heads, which are changesets with no child changesets.""" + heads = [ repo[ h ] for h in repo.heads( None ) ] + return heads + def get_repository_ids_requiring_prior_import_or_install( trans, tsr_ids, repository_dependencies ): """ This method is used in the Tool Shed when exporting a repository and it's dependencies, and in Galaxy when a repository and it's dependencies @@ -1213,18 +1218,20 @@ repo = hg.repository( get_configured_ui(), repository.repo_path( trans.app ) ) ctx = get_changectx_for_changeset( repo, changeset_revision ) if ctx: - return '%s:%s <i><font color="#666666">(%s)</font></i>' % \ - ( str( ctx.rev() ), changeset_revision, str( get_readable_ctx_date( ctx ) ) ) + return get_revision_label_from_ctx( ctx ) else: return "-1:%s" % changeset_revision +def get_revision_label_from_ctx( ctx ): + return '%s:%s <i><font color="#666666">(%s)</font></i>' % \ + ( str( ctx.rev() ), str( ctx ), str( get_readable_ctx_date( ctx ) ) ) + def get_rev_label_from_changeset_revision( repo, changeset_revision ): """Given a changeset revision hash, return two strings, the changeset rev and the changeset revision hash.""" ctx = get_changectx_for_changeset( repo, changeset_revision ) if ctx: rev = '%04d' % ctx.rev() - label = '%s:%s <i><font color="#666666">(%s)</font></i>' % \ - ( str( ctx.rev() ), changeset_revision, str( get_readable_ctx_date( ctx ) ) ) + label = get_revision_label_from_ctx( ctx ) else: rev = '-1' label = "-1:%s" % changeset_revision diff -r 4ab2017348e25958bcd8babd8e110f574dff24df -r 56b61e7d5bbcea1dff823cf78229289480ee15e7 templates/webapps/tool_shed/repository/manage_repository.mako --- a/templates/webapps/tool_shed/repository/manage_repository.mako +++ b/templates/webapps/tool_shed/repository/manage_repository.mako @@ -83,6 +83,10 @@ can_render_skip_tool_test_section = True else: can_render_skip_tool_test_section = False + if heads: + multiple_heads = len( heads ) > 1 + else: + multiple_heads = False %><%! @@ -115,6 +119,18 @@ <div class="warningmessage"> This repository has been marked as deprecated, so some tool shed features may be restricted. </div> +%elif multiple_heads: + <div class="warningmessage"> + <% + from tool_shed.util.shed_util_common import get_revision_label_from_ctx + heads_str = '' + for ctx in heads: + heads_str += get_revision_label_from_ctx( ctx ) + %> + Contact the administrator of this Tool Shed as soon as possible and let them know that + this repository has the following multiple heads which must be merged.<br/> + ${heads_str} + </div> %endif %if len( changeset_revision_select_field.options ) > 1: diff -r 4ab2017348e25958bcd8babd8e110f574dff24df -r 56b61e7d5bbcea1dff823cf78229289480ee15e7 templates/webapps/tool_shed/repository/view_repository.mako --- a/templates/webapps/tool_shed/repository/view_repository.mako +++ b/templates/webapps/tool_shed/repository/view_repository.mako @@ -25,6 +25,11 @@ tip_str = '' sharable_link_label = 'Sharable link to this repository revision:' sharable_link_changeset_revision = changeset_revision + + if heads: + multiple_heads = len( heads ) > 1 + else: + multiple_heads = False %><%! @@ -61,6 +66,18 @@ <div class="warningmessage"> This repository has been marked as deprecated, so some tool shed features may be restricted. </div> +%elif multiple_heads: + <div class="warningmessage"> + <% + from tool_shed.util.shed_util_common import get_revision_label_from_ctx + heads_str = '' + for ctx in heads: + heads_str += get_revision_label_from_ctx( ctx ) + %> + Contact the administrator of this Tool Shed as soon as possible and let them know that + this repository has the following multiple heads which must be merged.<br/> + ${heads_str} + </div> %endif %if len( changeset_revision_select_field.options ) > 1: Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org