commit/galaxy-central: greg: Use the new hg_util.get_repo_for_repository() function to retrieve a mercurial repo for a repository.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/7eaa7e058c28/ Changeset: 7eaa7e058c28 User: greg Date: 2014-05-21 18:22:16 Summary: Use the new hg_util.get_repo_for_repository() function to retrieve a mercurial repo for a repository. Affected #: 23 files diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py --- a/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py +++ b/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py @@ -33,11 +33,6 @@ import pkg_resources -eggs.require( 'mercurial' ) -from mercurial import commands -from mercurial import hg -from mercurial import ui - pkg_resources.require( 'elementtree' ) from elementtree import ElementTree from elementtree.ElementTree import Element @@ -1865,7 +1860,10 @@ repo_files_dir = os.path.abspath( os.path.join( tool_path, relative_install_dir, name ) ) else: repo_files_dir = os.path.abspath( os.path.join( relative_install_dir, name ) ) - repo = hg.repository( hg_util.get_configured_ui(), path=repo_files_dir ) + repo = hg_util.get_repo_for_repository( trans.app, + repository=None, + repo_path=repo_files_dir, + create=False ) repository_clone_url = os.path.join( tool_shed_url, 'repos', owner, name ) repository_util.pull_repository( repo, repository_clone_url, latest_ctx_rev ) hg_util.update_repository( repo, latest_ctx_rev ) diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/galaxy/webapps/tool_shed/api/repositories.py --- a/lib/galaxy/webapps/tool_shed/api/repositories.py +++ b/lib/galaxy/webapps/tool_shed/api/repositories.py @@ -19,10 +19,6 @@ from tool_shed.util import repository_maintenance_util from tool_shed.util import tool_util -eggs.require( 'mercurial' ) - -from mercurial import hg - log = logging.getLogger( __name__ ) @@ -49,8 +45,7 @@ error_message += "cannot locate repository %s owned by %s." % ( str( name ), str( owner ) ) log.debug( error_message ) return [] - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + 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: @@ -133,8 +128,7 @@ if repository_metadata is None: # The changeset_revision column in the repository_metadata table has been updated with a new # value value, so find the changeset_revision to which we need to update. - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) new_changeset_revision = suc.get_next_downloadable_changeset_revision( repository, repo, changeset_revision ) repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans.app, encoded_repository_id, diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/galaxy/webapps/tool_shed/api/repository_revisions.py --- a/lib/galaxy/webapps/tool_shed/api/repository_revisions.py +++ b/lib/galaxy/webapps/tool_shed/api/repository_revisions.py @@ -9,11 +9,6 @@ from tool_shed.util import hg_util import tool_shed.util.shed_util_common as suc -from galaxy import eggs -eggs.require( 'mercurial' ) - -from mercurial import hg - log = logging.getLogger( __name__ ) @@ -168,8 +163,10 @@ if repository_dependency_repository_metadata is None: # The changeset_revision column in the repository_metadata table has been updated with a new # value value, so find the changeset_revision to which we need to update. - repo_dir = repository_dependency.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, + repository=repository_dependency, + repo_path=None, + create=False ) new_changeset_revision = suc.get_next_downloadable_changeset_revision( repository_dependency, repo, changeset_revision ) diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 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 @@ -41,10 +41,8 @@ eggs.require( 'mercurial' ) from mercurial import commands -from mercurial import hg from mercurial import mdiff from mercurial import patch -from mercurial import ui log = logging.getLogger( __name__ ) @@ -720,7 +718,7 @@ status = kwd.get( 'status', 'done' ) commit_message = kwd.get( 'commit_message', 'Deleted selected files' ) repository = suc.get_repository_in_tool_shed( trans, id ) - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) # Update repository files for browsing. hg_util.update_repository( repo ) changeset_revision = repository.tip( trans.app ) @@ -891,8 +889,7 @@ owner = kwd.get( 'owner', None ) changeset_revision = kwd.get( 'changeset_revision', None ) repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) # Default to the current changeset revision. update_to_ctx = hg_util.get_changectx_for_changeset( repo, changeset_revision ) latest_changeset_revision = changeset_revision @@ -1464,10 +1461,10 @@ includes_tools_for_display_in_tool_panel = has_galaxy_utilities_dict[ 'includes_tools_for_display_in_tool_panel' ] includes_tool_dependencies = has_galaxy_utilities_dict[ 'includes_tool_dependencies' ] has_repository_dependencies = has_galaxy_utilities_dict[ 'has_repository_dependencies' ] - has_repository_dependencies_only_if_compiling_contained_td = has_galaxy_utilities_dict[ 'has_repository_dependencies_only_if_compiling_contained_td' ] + has_repository_dependencies_only_if_compiling_contained_td = \ + has_galaxy_utilities_dict[ 'has_repository_dependencies_only_if_compiling_contained_td' ] includes_workflows = has_galaxy_utilities_dict[ 'includes_workflows' ] - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) # Default to the received changeset revision and ctx_rev. update_to_ctx = hg_util.get_changectx_for_changeset( repo, changeset_revision ) ctx_rev = str( update_to_ctx.rev() ) @@ -1544,8 +1541,7 @@ repository_owner = kwd[ 'owner' ] changeset_revision = kwd[ 'changeset_revision' ] repository = suc.get_repository_by_name_and_owner( trans.app, repository_name, repository_owner ) - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) ctx = hg_util.get_changectx_for_changeset( repo, changeset_revision ) if ctx: return str( ctx.rev() ) @@ -1558,14 +1554,6 @@ trans.response.headers['Expires'] = '0' return suc.get_repository_file_contents( file_path ) - def get_file_from_changeset_revision( self, repo_files_dir, changeset_revision, file_name, dir ): - """Return file_name from the received changeset_revision of the repository manifest.""" - stripped_file_name = suc.strip_path( file_name ) - repo = hg.repository( hg_util.get_configured_ui(), repo_files_dir ) - ctx = hg_util.get_changectx_for_changeset( repo, changeset_revision ) - named_tmp_file = suc.get_named_tmpfile_from_ctx( ctx, file_name, dir ) - return named_tmp_file - @web.expose def get_functional_test_rss( self, trans, **kwd ): '''Return an RSS feed of the functional test results for the provided user, optionally filtered by the 'status' parameter.''' @@ -1604,8 +1592,7 @@ trans.model.Repository.table.c.deprecated == False, trans.model.Repository.table.c.user_id == user.id ) ): repository = repository_metadata.repository - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) latest_downloadable_changeset_revsion = suc.get_latest_downloadable_changeset_revision( trans.app, repository, repo ) if repository_metadata.changeset_revision == latest_downloadable_changeset_revsion: # We'll display only the test run for the latest installable revision in the rss feed. @@ -1673,7 +1660,7 @@ if repository_name is not None and repository_owner is not None: repository = suc.get_repository_by_name_and_owner( trans.app, repository_name, repository_owner ) if repository: - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) return suc.get_latest_downloadable_changeset_revision( trans.app, repository, repo ) return suc.INITIAL_CHANGELOG_HASH @@ -1860,8 +1847,7 @@ owner = kwd[ 'owner' ] changeset_revision = kwd[ 'changeset_revision' ] repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) tool_version_dicts = [] for changeset in repo.changelog: current_changeset_revision = str( repo.changectx( changeset ) ) @@ -1885,8 +1871,7 @@ repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) repository_id = trans.security.encode_id( repository.id ) repository_clone_url = common_util.generate_clone_url_for_repository_in_tool_shed( trans, repository ) - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans.app, repository_id, changeset_revision ) if not repository_metadata: # The received changeset_revision is no longer associated with metadata, so get the next changeset_revision in the repository @@ -2171,7 +2156,7 @@ repository = suc.get_repository_in_tool_shed( trans, id ) repository_type = kwd.get( 'repository_type', str( repository.type ) ) repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False ) repo_name = kwd.get( 'repo_name', repository.name ) changeset_revision = kwd.get( 'changeset_revision', repository.tip( trans.app ) ) description = kwd.get( 'description', repository.description ) @@ -2450,8 +2435,7 @@ else: # There is no repository_metadata defined for the changeset_revision, so see if it was defined # in a previous changeset in the changelog. - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) previous_changeset_revision = \ suc.get_previous_metadata_changeset_revision( repository, repo, @@ -2527,8 +2511,7 @@ owner = kwd.get( 'owner', None ) changeset_revision = kwd.get( 'changeset_revision', None ) repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) # Get the next installable changeset_revision beyond the received changeset_revision. changeset_revision = suc.get_next_downloadable_changeset_revision( repository, repo, changeset_revision ) if changeset_revision: @@ -2547,8 +2530,7 @@ message = kwd.get( 'message', '' ) status = kwd.get( 'status', 'done' ) repository = suc.get_repository_in_tool_shed( trans, repository_id ) - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) changeset_revision = kwd.get( 'changeset_revision', repository.tip( trans.app ) ) repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans.app, repository_id, changeset_revision ) if repository_metadata: @@ -2614,8 +2596,7 @@ owner = kwd.get( 'owner', None ) changeset_revision = kwd.get( 'changeset_revision', None ) repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) # Get the lower bound changeset revision. lower_bound_changeset_revision = suc.get_previous_metadata_changeset_revision( repository, repo, changeset_revision, downloadable=True ) # Build the list of changeset revision hashes. @@ -2641,7 +2622,7 @@ status='error' ) ) repository = suc.get_repository_in_tool_shed( trans, id ) changeset_revision = repository.tip( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) if repository.user == trans.user: return trans.response.send_redirect( web.url_for( controller='repository', action='browse_repositories', @@ -2710,7 +2691,7 @@ commit_message = kwd.get( 'commit_message', 'Deleted selected files' ) repository = suc.get_repository_in_tool_shed( trans, id ) repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False ) selected_files_to_delete = kwd.get( 'selected_files_to_delete', '' ) if kwd.get( 'select_files_to_delete_button', False ): if selected_files_to_delete: @@ -2750,7 +2731,6 @@ # Update the repository files for browsing. hg_util.update_repository( repo ) # Get the new repository tip. - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) if tip == repository.tip( trans.app ): message += 'No changes to repository. ' kwd[ 'message' ] = message @@ -2935,15 +2915,18 @@ repository = None if repository: repository_id = trans.security.encode_id( repository.id ) - repository_metadata = metadata_util.get_repository_metadata_by_repository_id_changeset_revision( trans, repository_id, changeset_revision ) + repository_metadata = metadata_util.get_repository_metadata_by_repository_id_changeset_revision( trans, + repository_id, + changeset_revision ) if not repository_metadata: # Get updates to the received changeset_revision if any exist. - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) upper_bound_changeset_revision = suc.get_next_downloadable_changeset_revision( repository, repo, changeset_revision ) if upper_bound_changeset_revision: changeset_revision = upper_bound_changeset_revision - repository_metadata = metadata_util.get_repository_metadata_by_repository_id_changeset_revision( trans, repository_id, changeset_revision ) + repository_metadata = metadata_util.get_repository_metadata_by_repository_id_changeset_revision( trans, + repository_id, + changeset_revision ) if repository_metadata: return trans.response.send_redirect( web.url_for( controller='repository', action='index', @@ -2978,8 +2961,7 @@ repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans.app, trans.security.encode_id( repository.id ), changeset_revision ) - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) tool_shed_status_dict = {} # Handle repository deprecation. tool_shed_status_dict[ 'repository_deprecated' ] = str( repository.deprecated ) @@ -3071,7 +3053,7 @@ message = kwd.get( 'message', '' ) status = kwd.get( 'status', 'done' ) repository = suc.get_repository_in_tool_shed( trans, id ) - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) changesets = [] for changeset in repo.changelog: ctx = repo.changectx( changeset ) @@ -3106,7 +3088,7 @@ message = kwd.get( 'message', '' ) status = kwd.get( 'status', 'done' ) repository = suc.get_repository_in_tool_shed( trans, id ) - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) ctx = hg_util.get_changectx_for_changeset( repo, ctx_str ) if ctx is None: message = "Repository does not include changeset revision '%s'." % str( ctx_str ) @@ -3195,7 +3177,7 @@ message = kwd.get( 'message', '' ) status = kwd.get( 'status', 'done' ) repository = suc.get_repository_in_tool_shed( trans, id ) - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) avg_rating, num_ratings = self.get_ave_item_rating_data( trans.sa_session, repository, webapp_model=trans.model ) changeset_revision = kwd.get( 'changeset_revision', repository.tip( trans.app ) ) display_reviews = kwd.get( 'display_reviews', False ) @@ -3289,7 +3271,7 @@ render_repository_actions_for = kwd.get( 'render_repository_actions_for', 'tool_shed' ) repository = suc.get_repository_in_tool_shed( trans, repository_id ) repo_files_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_files_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_files_dir, create=False ) tool_metadata_dict = {} tool_lineage = [] tool = None diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/galaxy/webapps/tool_shed/controllers/repository_review.py --- a/lib/galaxy/webapps/tool_shed/controllers/repository_review.py +++ b/lib/galaxy/webapps/tool_shed/controllers/repository_review.py @@ -13,10 +13,6 @@ import tool_shed.grids.repository_review_grids as repository_review_grids import tool_shed.grids.util as grids_util -from galaxy import eggs -eggs.require('mercurial') -from mercurial import hg, ui, patch, commands - log = logging.getLogger( __name__ ) @@ -73,7 +69,7 @@ status = kwd.get( 'status', 'done' ) review = review_util.get_review( trans, kwd[ 'id' ] ) repository = review.repository - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) rev, changeset_revision_label = hg_util.get_rev_label_from_changeset_revision( repo, review.changeset_revision ) return trans.fill_template( '/webapps/tool_shed/repository_review/browse_review.mako', repository=repository, @@ -233,7 +229,7 @@ for component in review_util.get_components( trans ): components_dict[ component.name ] = dict( component=component, component_review=None ) repository = review.repository - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) for component_review in review.component_reviews: if component_review and component_review.component: component_name = component_review.component.name @@ -470,8 +466,7 @@ repository_id = kwd.get( 'id', None ) if repository_id: repository = suc.get_repository_in_tool_shed( trans, repository_id ) - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) metadata_revision_hashes = [ metadata_revision.changeset_revision for metadata_revision in repository.metadata_revisions ] reviewed_revision_hashes = [ review.changeset_revision for review in repository.reviews ] reviews_dict = odict() @@ -517,8 +512,7 @@ repository_id = kwd.get( 'id', None ) changeset_revision = kwd.get( 'changeset_revision', None ) repository = suc.get_repository_in_tool_shed( trans, repository_id ) - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) installable = changeset_revision in [ metadata_revision.changeset_revision for metadata_revision in repository.metadata_revisions ] rev, changeset_revision_label = hg_util.get_rev_label_from_changeset_revision( repo, changeset_revision ) reviews = review_util.get_reviews_by_repository_id_changeset_revision( trans, repository_id, changeset_revision ) @@ -583,7 +577,7 @@ status = kwd.get( 'status', 'done' ) repository = suc.get_repository_in_tool_shed( trans, kwd[ 'id' ] ) changeset_revision = kwd.get( 'changeset_revision', None ) - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) previous_reviews_dict = review_util.get_previous_repository_reviews( trans, repository, changeset_revision ) rev, changeset_revision_label = hg_util.get_rev_label_from_changeset_revision( repo, changeset_revision ) return trans.fill_template( '/webapps/tool_shed/repository_review/select_previous_review.mako', diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/galaxy/webapps/tool_shed/controllers/upload.py --- a/lib/galaxy/webapps/tool_shed/controllers/upload.py +++ b/lib/galaxy/webapps/tool_shed/controllers/upload.py @@ -21,8 +21,6 @@ from galaxy import eggs eggs.require( 'mercurial' ) from mercurial import commands -from mercurial import hg -from mercurial import ui log = logging.getLogger( __name__ ) @@ -40,7 +38,7 @@ repository_id = kwd.get( 'repository_id', '' ) repository = suc.get_repository_in_tool_shed( trans, repository_id ) repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False ) uncompress_file = util.string_as_bool( kwd.get( 'uncompress_file', 'true' ) ) remove_repo_files_not_in_tar = util.string_as_bool( kwd.get( 'remove_repo_files_not_in_tar', 'true' ) ) uploaded_file = None @@ -325,7 +323,7 @@ def upload_directory( self, trans, repository, uploaded_directory, upload_point, remove_repo_files_not_in_tar, commit_message, new_repo_alert ): repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False ) undesirable_dirs_removed = 0 undesirable_files_removed = 0 if upload_point is not None: @@ -389,7 +387,7 @@ def upload_tar( self, trans, repository, tar, uploaded_file, upload_point, remove_repo_files_not_in_tar, commit_message, new_repo_alert ): # Upload a tar archive of files. repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False ) undesirable_dirs_removed = 0 undesirable_files_removed = 0 ok, message = commit_util.check_archive( repository, tar ) diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/galaxy_install/repository_util.py --- a/lib/tool_shed/galaxy_install/repository_util.py +++ b/lib/tool_shed/galaxy_install/repository_util.py @@ -26,8 +26,6 @@ eggs.require( 'mercurial' ) from mercurial import commands -from mercurial import hg -from mercurial import ui log = logging.getLogger( __name__ ) @@ -186,8 +184,7 @@ def get_repo_info_dict( trans, repository_id, changeset_revision ): repository = suc.get_repository_in_tool_shed( trans, repository_id ) - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) repository_clone_url = common_util.generate_clone_url_for_repository_in_tool_shed( trans, repository ) repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans.app, repository_id, @@ -578,7 +575,10 @@ current_changeset_revision = changeset_revision_dict.get( 'changeset_revision', None ) current_ctx_rev = changeset_revision_dict.get( 'ctx_rev', None ) if current_ctx_rev != ctx_rev: - repo = hg.repository( hg_util.get_configured_ui(), path=os.path.abspath( install_dir ) ) + repo = hg_util.get_repo_for_repository( trans.app, + repository=None, + repo_path=os.path.abspath( install_dir ), + create=False ) pull_repository( repo, repository_clone_url, current_changeset_revision ) hg_util.update_repository( repo, ctx_rev=current_ctx_rev ) handle_repository_contents( trans, diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/grids/repository_grids.py --- a/lib/tool_shed/grids/repository_grids.py +++ b/lib/tool_shed/grids/repository_grids.py @@ -17,12 +17,6 @@ eggs.require('markupsafe') from markupsafe import escape as escape_html -eggs.require('mercurial') -from mercurial import commands -from mercurial import hg -from mercurial import patch -from mercurial import ui - log = logging.getLogger( __name__ ) class CategoryGrid( grids.Grid ): @@ -103,8 +97,7 @@ def get_value( self, trans, grid, repository ): """Display the current repository heads.""" - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) heads = suc.get_repository_heads( repo ) multiple_heads = len( heads ) > 1 if multiple_heads: @@ -1477,8 +1470,10 @@ required_repository_id, changeset_revision ) if not required_repository_metadata: - repo_dir = required_repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, + repository=required_repository, + repo_path=None, + create=False ) updated_changeset_revision = \ suc.get_next_downloadable_changeset_revision( required_repository, repo, diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/grids/repository_review_grids.py --- a/lib/tool_shed/grids/repository_review_grids.py +++ b/lib/tool_shed/grids/repository_review_grids.py @@ -9,13 +9,6 @@ from tool_shed.util import hg_util from tool_shed.util import metadata_util -from galaxy import eggs -eggs.require('mercurial') -from mercurial import commands -from mercurial import hg -from mercurial import patch -from mercurial import ui - log = logging.getLogger( __name__ ) @@ -67,7 +60,7 @@ # Restrict to revisions that have been reviewed. if repository.reviews: rval = '' - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) for review in repository.reviews: changeset_revision = review.changeset_revision rev, label = hg_util.get_rev_label_from_changeset_revision( repo, changeset_revision ) diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/grids/util.py --- a/lib/tool_shed/grids/util.py +++ b/lib/tool_shed/grids/util.py @@ -168,7 +168,7 @@ tool_dependency_definition. """ encoded_repository_id = trans.security.encode_id( repository.id ) - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) tip_ctx = str( repo.changectx( repo.changelog.tip() ) ) repository_metadata = None try: @@ -218,7 +218,7 @@ tool_dependency_definition. """ encoded_repository_id = trans.security.encode_id( repository.id ) - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) tip_ctx = str( repo.changectx( repo.changelog.tip() ) ) try: repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans.app, encoded_repository_id, tip_ctx ) diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/repository_registry.py --- a/lib/tool_shed/repository_registry.py +++ b/lib/tool_shed/repository_registry.py @@ -62,7 +62,7 @@ """ if repository.deleted: return ( None, False ) - repo = hg_util.get_repo_for_repository( self.app, repository ) + repo = hg_util.get_repo_for_repository( self.app, repository=repository, repo_path=None, create=False ) # Get the latest installable changeset revision since that is all that is currently configured for testing. latest_installable_changeset_revision = suc.get_latest_downloadable_changeset_revision( self.app, repository, repo ) if latest_installable_changeset_revision not in [ None, suc.INITIAL_CHANGELOG_HASH ]: diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/scripts/check_repositories_for_functional_tests.py --- a/lib/tool_shed/scripts/check_repositories_for_functional_tests.py +++ b/lib/tool_shed/scripts/check_repositories_for_functional_tests.py @@ -28,8 +28,6 @@ from galaxy.model.orm import not_ from galaxy.model.orm import select from galaxy.util import listify -from mercurial import hg -from mercurial import ui from mercurial import __version__ from optparse import OptionParser from time import strftime @@ -110,7 +108,7 @@ if tool_dicts is not None: # Clone the repository up to the changeset revision we're checking. repo_dir = repository.repo_path( app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( app, repository=None, repo_path=repo_dir, create=False ) work_dir = tempfile.mkdtemp( prefix="tmp-toolshed-cafr" ) cloned_ok, error_message = hg_util.clone_repository( repo_dir, work_dir, changeset_revision ) if cloned_ok: @@ -316,14 +314,6 @@ missing_test_files.append( required_file ) return missing_test_files -def get_repo_changelog_tuples( repo_path ): - repo = hg.repository( ui.ui(), repo_path ) - changelog_tuples = [] - for changeset in repo.changelog: - ctx = repo.changectx( changeset ) - changelog_tuples.append( ( ctx.rev(), str( ctx ) ) ) - return changelog_tuples - def main(): '''Script that checks repositories to see if the tools contained within them have functional tests defined.''' parser = OptionParser() @@ -368,8 +358,7 @@ would be redundant. """ if not testable_revision: - repo_dir = repository.repo_path( app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + 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 ] diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/util/commit_util.py --- a/lib/tool_shed/util/commit_util.py +++ b/lib/tool_shed/util/commit_util.py @@ -20,11 +20,8 @@ from galaxy import eggs eggs.require( 'mercurial' ) from mercurial import commands -from mercurial import hg -from mercurial import ui from mercurial.changegroup import readbundle from mercurial.changegroup import readexactly -from mercurial.changegroup import writebundle log = logging.getLogger( __name__ ) @@ -156,8 +153,7 @@ def handle_directory_changes( trans, repository, full_path, filenames_in_archive, remove_repo_files_not_in_tar, new_repo_alert, commit_message, undesirable_dirs_removed, undesirable_files_removed ): - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) content_alert_str = '' files_to_remove = [] filenames_in_archive = [ os.path.join( full_path, name ) for name in filenames_in_archive ] @@ -342,8 +338,7 @@ # revision are valid. repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) if repository: - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) lastest_installable_changeset_revision = suc.get_latest_downloadable_changeset_revision( trans.app, repository, repo ) if lastest_installable_changeset_revision != suc.INITIAL_CHANGELOG_HASH: elem.attrib[ 'changeset_revision' ] = lastest_installable_changeset_revision diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/util/export_util.py --- a/lib/tool_shed/util/export_util.py +++ b/lib/tool_shed/util/export_util.py @@ -21,10 +21,7 @@ eggs.require( 'mercurial' ) -import mercurial.util from mercurial import commands -from mercurial import hg -from mercurial import patch from mercurial import ui log = logging.getLogger( __name__ ) @@ -39,7 +36,7 @@ def archive_repository_revision( trans, ui, repository, archive_dir, changeset_revision ): '''Create an un-versioned archive of a repository.''' - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) options_dict = hg_util.get_mercurial_default_options_dict( 'archive' ) options_dict[ 'rev' ] = changeset_revision error_message = '' @@ -242,7 +239,7 @@ key_rd_dicts_to_be_processed=None, all_repository_dependencies=None, handled_key_rd_dicts=None ) - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) ctx = hg_util.get_changectx_for_changeset( repo, changeset_revision ) repo_info_dict = {} # Cast unicode to string. diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/util/hg_util.py --- a/lib/tool_shed/util/hg_util.py +++ b/lib/tool_shed/util/hg_util.py @@ -69,15 +69,18 @@ ctx_date = date.strftime( "%Y-%m-%d" ) return ctx_date -def get_repo_for_repository( app, repository ): - return hg.repository( get_configured_ui(), repository.repo_path( app ) ) +def get_repo_for_repository( app, repository=None, repo_path=None, create=False ): + if repository is not None: + return hg.repository( get_configured_ui(), repository.repo_path( app ), create=create ) + if repo_path is not None: + return hg.repository( get_configured_ui(), repo_path, create=create ) def get_revision_label( trans, repository, changeset_revision, include_date=True, include_hash=True ): """ Return a string consisting of the human read-able changeset rev and the changeset revision string which includes the revision date if the receive include_date is True. """ - repo = get_repo_for_repository( trans.app, repository ) + repo = get_repo_for_repository( trans.app, repository=repository, repo_path=None ) ctx = get_changectx_for_changeset( repo, changeset_revision ) if ctx: return get_revision_label_from_ctx( ctx, include_date=include_date, include_hash=include_hash ) diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/util/import_util.py --- a/lib/tool_shed/util/import_util.py +++ b/lib/tool_shed/util/import_util.py @@ -14,13 +14,6 @@ import tool_shed.util.shed_util_common as suc import tool_shed.repository_types.util as rt_util -from galaxy import eggs -eggs.require( 'mercurial' ) - -from mercurial import commands -from mercurial import hg -from mercurial import ui - log = logging.getLogger( __name__ ) def check_status_and_reset_downloadable( trans, import_results_tups ): @@ -214,7 +207,7 @@ archive_file_path = os.path.join( file_path, archive_file_name ) archive = tarfile.open( archive_file_path, 'r:*' ) repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False ) undesirable_dirs_removed = 0 undesirable_files_removed = 0 ok, error_message = commit_util.check_archive( repository, archive ) diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/util/metadata_util.py --- a/lib/tool_shed/util/metadata_util.py +++ b/lib/tool_shed/util/metadata_util.py @@ -1,7 +1,7 @@ import logging import os import tempfile -from galaxy import eggs + from galaxy import util from galaxy import web from galaxy.datatypes import checkers @@ -10,6 +10,7 @@ from galaxy.util import inflector from galaxy.util import json from galaxy.web import url_for + import tool_shed.util.shed_util_common as suc from tool_shed.repository_types.metadata import TipOnly from tool_shed.util import common_util @@ -23,12 +24,6 @@ from tool_shed.galaxy_install.tool_dependencies import td_common_util import tool_shed.repository_types.util as rt_util -eggs.require( 'mercurial' ) - -from mercurial import commands -from mercurial import hg -from mercurial import ui - log = logging.getLogger( __name__ ) # Repository metadata comparisons for changeset revisions. @@ -352,7 +347,7 @@ # changeset revision in the received repository's changelog (up to the received changeset revision) to see if it is contained in the # skip_tool_test table. If it is, but is not associated with a repository_metadata record, reset that skip_tool_test record to the # newly created repository_metadata record. - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) for changeset in repo.changelog: changeset_hash = str( repo.changectx( changeset ) ) skip_tool_test = suc.get_skip_tool_test_by_changeset_revision( trans, changeset_hash ) @@ -1051,7 +1046,7 @@ def get_latest_repository_metadata( trans, decoded_repository_id, downloadable=False ): """Get last metadata defined for a specified repository from the database.""" repository = trans.sa_session.query( trans.model.Repository ).get( decoded_repository_id ) - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) if downloadable: changeset_revision = suc.get_latest_downloadable_changeset_revision( trans.app, repository, @@ -1288,7 +1283,8 @@ log.debug( error_message ) is_valid = False return repository_dependency_tup, is_valid, error_message - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( app ) ) + repo = hg_util.get_repo_for_repository( app, repository=repository, repo_path=None, create=False ) + # The received changeset_revision may be None since defining it in the dependency definition is optional. # If this is the case, the default will be to set its value to the repository dependency tip revision. # This probably occurs only when handling circular dependency definitions. @@ -1734,7 +1730,7 @@ repository = suc.get_repository_in_tool_shed( trans, id ) log.debug( "Resetting all metadata on repository: %s" % repository.name ) repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False ) repository_clone_url = common_util.generate_clone_url_for_repository_in_tool_shed( trans, repository ) # The list of changeset_revisions refers to repository_metadata records that have been created or updated. When the following loop # completes, we'll delete all repository_metadata records for this repository that do not have a changeset_revision value in this list. @@ -1916,7 +1912,7 @@ encoded_id = trans.security.encode_id( repository.id ) repository_clone_url = common_util.generate_clone_url_for_repository_in_tool_shed( trans, repository ) repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_dir, create=False ) metadata_dict, invalid_file_tups = generate_metadata_for_changeset_revision( app=trans.app, repository=repository, changeset_revision=repository.tip( trans.app ), diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/util/readme_util.py --- a/lib/tool_shed/util/readme_util.py +++ b/lib/tool_shed/util/readme_util.py @@ -1,20 +1,18 @@ import logging import os import threading + from mako.template import Template -from galaxy import eggs + from galaxy import web from galaxy.util import json from galaxy.util import rst_to_html from galaxy.util import unicodify + import tool_shed.util.shed_util_common as suc from tool_shed.util import common_util from tool_shed.util import hg_util -eggs.require( 'mercurial' ) - -from mercurial import hg - log = logging.getLogger( __name__ ) def build_readme_files_dict( trans, repository, changeset_revision, metadata, tool_path=None ): @@ -26,7 +24,7 @@ if trans.webapp.name == 'galaxy': can_use_disk_files = True else: - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) latest_downloadable_changeset_revision = suc.get_latest_downloadable_changeset_revision( trans.app, repository, repo ) can_use_disk_files = changeset_revision == latest_downloadable_changeset_revision readme_files_dict = {} diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/util/repository_dependency_util.py --- a/lib/tool_shed/util/repository_dependency_util.py +++ b/lib/tool_shed/util/repository_dependency_util.py @@ -1,9 +1,10 @@ import logging import os -from galaxy import eggs + from galaxy.util import asbool from galaxy.util import json from galaxy.util import listify + import tool_shed.util.shed_util_common as suc from tool_shed.util import common_util from tool_shed.util import common_install_util @@ -13,12 +14,6 @@ from tool_shed.util import metadata_util from tool_shed.util import tool_util -eggs.require( 'mercurial' ) - -from mercurial import commands -from mercurial import hg -from mercurial import ui - log = logging.getLogger( __name__ ) def build_repository_dependency_relationships( trans, repo_info_dicts, tool_shed_repositories ): @@ -536,12 +531,12 @@ updated_key_rd_dicts.append( key_rd_dict ) else: # The repository changeset_revision is no longer installable, so see if there's been an update. - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) changeset_revision = suc.get_next_downloadable_changeset_revision( repository, repo, rd_changeset_revision ) - repository_metadata = metadata_util.get_repository_metadata_by_repository_id_changeset_revision( trans, - trans.security.encode_id( repository.id ), - changeset_revision ) + repository_metadata = \ + metadata_util.get_repository_metadata_by_repository_id_changeset_revision( trans, + trans.security.encode_id( repository.id ), + changeset_revision ) if repository_metadata: new_key_rd_dict = {} new_key_rd_dict[ key ] = \ diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/util/repository_maintenance_util.py --- a/lib/tool_shed/util/repository_maintenance_util.py +++ b/lib/tool_shed/util/repository_maintenance_util.py @@ -9,14 +9,6 @@ from galaxy.web.form_builder import build_select_field from galaxy.webapps.tool_shed.model import directory_hash_id -from galaxy import eggs -eggs.require( 'mercurial' ) - -from mercurial import commands -from mercurial import hg -from mercurial import patch -from mercurial import ui - log = logging.getLogger( __name__ ) VALID_REPOSITORYNAME_RE = re.compile( "^[a-z0-9\_]+$" ) @@ -48,7 +40,7 @@ # Since we support both http and https, we set push_ssl to False to override the default (which is True) in the mercurial api. The hg # purge extension purges all files and directories not being tracked by mercurial in the current repository. It'll remove unknown files # and empty directories. This is not currently used because it is not supported in the mercurial API. - repo = hg.repository( hg_util.get_configured_ui(), path=repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) fp = repo.opener( 'hgrc', 'wb' ) fp.write( '[paths]\n' ) fp.write( 'default = .\n' ) @@ -84,7 +76,7 @@ if not os.path.exists( repository_path ): os.makedirs( repository_path ) # Create the local repository. - repo = hg.repository( hg_util.get_configured_ui(), repository_path, create=True ) + repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repository_path, create=True ) # Add an entry in the hgweb.config file for the local repository. lhs = "repos/%s/%s" % ( repository.user.username, repository.name ) trans.app.hgweb_config_manager.add_entry( lhs, repository_path ) diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/util/review_util.py --- a/lib/tool_shed/util/review_util.py +++ b/lib/tool_shed/util/review_util.py @@ -1,17 +1,10 @@ import logging import os -from galaxy import eggs from galaxy.model.orm import and_ from galaxy.util.odict import odict from tool_shed.util import hg_util import tool_shed.util.shed_util_common as suc -eggs.require( 'mercurial' ) - -from mercurial import commands -from mercurial import hg -from mercurial import ui - log = logging.getLogger( __name__ ) def can_browse_repository_reviews( trans, repository ): @@ -59,7 +52,7 @@ def get_previous_repository_reviews( trans, repository, changeset_revision ): """Return an ordered dictionary of repository reviews up to and including the received changeset revision.""" - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) reviewed_revision_hashes = [ review.changeset_revision for review in repository.reviews ] previous_reviews_dict = odict() for changeset in suc.reversed_upper_bounded_changelog( repo, changeset_revision ): @@ -94,7 +87,7 @@ def has_previous_repository_reviews( trans, repository, changeset_revision ): """Determine if a repository has a changeset revision review prior to the received changeset revision.""" - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( trans.app ) ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) reviewed_revision_hashes = [ review.changeset_revision for review in repository.reviews ] for changeset in suc.reversed_upper_bounded_changelog( repo, changeset_revision ): previous_changeset_revision = str( repo.changectx( changeset ) ) diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 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 @@ -23,9 +23,6 @@ from urllib2 import HTTPError from galaxy import eggs -eggs.require( 'mercurial' ) - -from mercurial import hg eggs.require( 'markupsafe' ) import markupsafe @@ -474,7 +471,7 @@ return repository_metadata # The installable changeset_revision may have been changed because it was "moved ahead" # in the repository changelog. - repo = hg.repository( hg_util.get_configured_ui(), repository.repo_path( app ) ) + repo = hg_util.get_repo_for_repository( app, repository=repository, repo_path=None, create=False ) updated_changeset_revision = get_next_downloadable_changeset_revision( repository, repo, after_changeset_revision=changeset_revision ) @@ -528,8 +525,10 @@ # The defined changeset_revision is not associated with a repository_metadata # record, so updates must be necessary. defined_repository = get_repository_by_name_and_owner( trans.app, name, owner ) - defined_repo_dir = defined_repository.repo_path( trans.app ) - defined_repo = hg.repository( hg_util.get_configured_ui(), defined_repo_dir ) + defined_repo = hg_util.get_repo_for_repository( trans.app, + repository=defined_repository, + repo_path=None, + create=False ) updated_changeset_revision = \ get_next_downloadable_changeset_revision( defined_repository, defined_repo, @@ -1324,8 +1323,7 @@ revision for the repository defined by the received name and owner. """ repository = get_repository_by_name_and_owner( trans.app, name, owner ) - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) # Get the upper bound changeset revision. upper_bound_changeset_revision = get_next_downloadable_changeset_revision( repository, repo, changeset_revision ) # Build the list of changeset revision hashes defining each available update up to, but excluding, upper_bound_changeset_revision. @@ -1389,8 +1387,7 @@ user is not an admin user, the email will not include any information about both HTML and image content that was included in the change set. """ - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) sharable_link = generate_sharable_link_for_repository_in_tool_shed( repository, changeset_revision=None ) smtp_server = trans.app.config.smtp_server if smtp_server and ( new_repo_alert or repository.email_alerts ): diff -r df18a38465c2cd7d7e8014febc3d955758f84671 -r 7eaa7e058c2898b10674b4ca43a0a76e566517c3 lib/tool_shed/util/tool_util.py --- a/lib/tool_shed/util/tool_util.py +++ b/lib/tool_shed/util/tool_util.py @@ -4,7 +4,6 @@ import shutil import tempfile import galaxy.tools -from galaxy import eggs from galaxy import util from galaxy.datatypes import checkers from galaxy.model.orm import and_ @@ -20,12 +19,6 @@ import tool_shed.util.shed_util_common as suc from xml.etree import ElementTree as XmlET -eggs.require( 'mercurial' ) - -from mercurial import commands -from mercurial import hg -from mercurial import ui - log = logging.getLogger( __name__ ) def add_to_shed_tool_config( app, shed_tool_conf_dict, elem_list ): @@ -538,8 +531,7 @@ repsitory_metadata.tool_versions. """ repository = suc.get_repository_by_id( trans, repository_id ) - repo_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) # Initialize the tool lineage version_lineage = [ guid ] # Get all ancestor guids of the received guid. @@ -867,7 +859,7 @@ original_tool_data_path = trans.app.config.tool_data_path repository = suc.get_repository_in_tool_shed( trans, repository_id ) repo_files_dir = repository.repo_path( trans.app ) - repo = hg.repository( hg_util.get_configured_ui(), repo_files_dir ) + repo = hg_util.get_repo_for_repository( trans.app, repository=None, repo_path=repo_files_dir, create=False ) message = '' tool = None can_use_disk_file = False 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