Skip to content

Commit

Permalink
Merge pull request #2753 from martenson/disable_hg_middleware
Browse files Browse the repository at this point in the history
remove TS hg middleware
  • Loading branch information
dannon committed Aug 8, 2016
2 parents 0e9c044 + 9618386 commit 580ace1
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 406 deletions.
3 changes: 0 additions & 3 deletions config/tool_shed.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ database_file = database/community.sqlite
# The default is the Galaxy installation directory.
#hgweb_config_dir = None

# Disable Mercurial pushing to repositories.
#disable_push = True

# Where tool shed repositories are stored.
file_path = database/community_files
# Temporary storage for additional datasets,
Expand Down
5 changes: 1 addition & 4 deletions lib/galaxy/webapps/tool_shed/buildapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import galaxy.webapps.tool_shed.model.mapping
import galaxy.web.framework.webapp
from galaxy.webapps.util import build_template_error_formatters
from galaxy.webapps.tool_shed.framework.middleware import hg
from galaxy import util
from galaxy.config import process_is_uwsgi
from galaxy.util.properties import load_app_properties
Expand Down Expand Up @@ -80,6 +79,7 @@ def app_factory( global_conf, **kwargs ):
image_file=None )
webapp.add_route( '/{controller}/{action}', action='index' )
webapp.add_route( '/{action}', controller='repository', action='index' )
# Enable 'hg clone' functionality on repos by letting hgwebapp handle the request
webapp.add_route( '/repos/*path_info', controller='hg', action='handle_request', path_info='/' )
# Add the web API. # A good resource for RESTful services - http://routes.readthedocs.org/en/latest/restful.html
webapp.add_api_controllers( 'galaxy.webapps.tool_shed.api', app )
Expand Down Expand Up @@ -204,9 +204,6 @@ def wrap_in_middleware( app, global_conf, **local_conf ):
# other middleware):
app = httpexceptions.make_middleware( app, conf )
log.debug( "Enabling 'httpexceptions' middleware" )
# Then load the Hg middleware.
app = hg.Hg( app, conf )
log.debug( "Enabling 'hg' middleware" )
# If we're using remote_user authentication, add middleware that
# protects Galaxy from improperly configured authentication in the
# upstream server
Expand Down
1 change: 0 additions & 1 deletion lib/galaxy/webapps/tool_shed/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def __init__( self, **kwargs ):
self.sentry_dsn = kwargs.get( 'sentry_dsn', None )
# Where the tool shed hgweb.config file is stored - the default is the Galaxy installation directory.
self.hgweb_config_dir = resolve_path( kwargs.get( 'hgweb_config_dir', '' ), self.root )
self.disable_push = string_as_bool( kwargs.get( "disable_push", "True" ) )
# Proxy features
self.apache_xsendfile = kwargs.get( 'apache_xsendfile', False )
self.nginx_x_accel_redirect_base = kwargs.get( 'nginx_x_accel_redirect_base', False )
Expand Down
54 changes: 3 additions & 51 deletions lib/galaxy/webapps/tool_shed/controllers/hg.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import logging
from galaxy import web
from galaxy.web.base.controller import BaseUIController

from tool_shed.util.common_util import generate_clone_url_for_repository_in_tool_shed
from tool_shed.util.repository_util import get_repository_by_name_and_owner
from tool_shed.util.hg_util import update_repository
from tool_shed.metadata import repository_metadata_manager

import mercurial.__version__
from mercurial.hgweb.hgwebdir_mod import hgwebdir
from mercurial.hgweb.request import wsgiapplication
from mercurial import hg
from mercurial import ui

from galaxy import web
from galaxy.web.base.controller import BaseUIController

log = logging.getLogger(__name__)

Expand All @@ -21,51 +14,10 @@ class HgController( BaseUIController ):
def handle_request( self, trans, **kwd ):
# The os command that results in this method being called will look something like:
# hg clone http://test@127.0.0.1:9009/repos/test/convert_characters1
hg_version = mercurial.__version__.version
cmd = kwd.get( 'cmd', None )
hgweb_config = trans.app.hgweb_config_manager.hgweb_config

def make_web_app():
hgwebapp = hgwebdir( hgweb_config )
return hgwebapp
wsgi_app = wsgiapplication( make_web_app )
if hg_version >= '2.2.3' and cmd == 'pushkey':
# When doing an "hg push" from the command line, the following commands, in order, will be
# retrieved from environ, depending upon the mercurial version being used. In mercurial
# version 2.2.3, section 15.2. Command changes includes a new feature:
# pushkey: add hooks for pushkey/listkeys
# (see http://mercurial.selenic.com/wiki/WhatsNew#Mercurial_2.2.3_.282012-07-01.29).
# We require version 2.2.3 since the pushkey hook was added in that version.
# If mercurial version >= '2.2.3': capabilities -> batch -> branchmap -> unbundle -> listkeys -> pushkey
path_info = kwd.get( 'path_info', None )
if path_info:
owner, name = path_info.split( '/' )
repository = get_repository_by_name_and_owner( trans.app, name, owner )
if repository:
if hg_version >= '2.2.3':
# Update the repository on disk to the tip revision, because the web upload
# form uses the on-disk working directory. If the repository is not updated
# on disk, pushing from the command line and then uploading via the web
# interface will result in a new head being created.
repo = hg.repository( ui.ui(), repository.repo_path( trans.app ) )
update_repository( repo, ctx_rev=None )
repository_clone_url = generate_clone_url_for_repository_in_tool_shed( trans.user, repository )
# Set metadata using the repository files on disk.
rmm = repository_metadata_manager.RepositoryMetadataManager( app=trans.app,
user=trans.user,
repository=repository,
changeset_revision=repository.tip( trans.app ),
repository_clone_url=repository_clone_url,
relative_install_dir=repository.repo_path( trans.app ),
repository_files_dir=None,
resetting_all_metadata_on_repository=False,
updating_installed_repository=False,
persist=False )
error_message, status = rmm.set_repository_metadata( trans.request.host )
if status == 'ok' and error_message:
log.debug( "Successfully reset metadata on repository %s owned by %s, but encountered problem: %s" %
( str( repository.name ), str( repository.user.username ), error_message ) )
elif status != 'ok' and error_message:
log.debug( "Error resetting metadata on repository %s owned by %s: %s" %
( str( repository.name ), str( repository.user.username ), error_message ) )
return wsgi_app

0 comments on commit 580ace1

Please sign in to comment.