1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/344e84a6554a/ Changeset: 344e84a6554a User: greg Date: 2014-06-23 00:25:22 Summary: Eliminate the use of trans when exporting repository capsules from the Tool SHed and move the new tag_attribute_haldler.py module where it was meant to be located. Affected #: 7 files diff -r ae53980fad820db494c67ddb5ad0ad5f9deb9dd1 -r 344e84a6554ae94604f32e8f62feebd65a6ac358 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 @@ -53,7 +53,8 @@ log.debug( error_message ) return None, error_message repository_id = trans.security.encode_id( repository.id ) - return export_util.export_repository( trans, + return export_util.export_repository( trans.app, + trans.user, tool_shed_url, repository_id, str( repository.name ), diff -r ae53980fad820db494c67ddb5ad0ad5f9deb9dd1 -r 344e84a6554ae94604f32e8f62feebd65a6ac358 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 @@ -1172,7 +1172,8 @@ file_type = 'gz' export_repository_dependencies = CheckboxField.is_checked( export_repository_dependencies ) tool_shed_url = web.url_for( '/', qualified=True ) - repositories_archive, error_message = export_util.export_repository( trans, + repositories_archive, error_message = export_util.export_repository( trans.app, + trans.user, tool_shed_url, repository_id, str( repository.name ), diff -r ae53980fad820db494c67ddb5ad0ad5f9deb9dd1 -r 344e84a6554ae94604f32e8f62feebd65a6ac358 lib/tool_shed/dependencies/dependency_manager.py --- a/lib/tool_shed/dependencies/dependency_manager.py +++ b/lib/tool_shed/dependencies/dependency_manager.py @@ -5,7 +5,7 @@ from galaxy.util.odict import odict from galaxy.web import url_for -from tool_shed.dependencies import tag_attribute_handler +from tool_shed.dependencies.tool import tag_attribute_handler from tool_shed.repository_types.util import REPOSITORY_DEPENDENCY_DEFINITION_FILENAME from tool_shed.repository_types.util import TOOL_DEPENDENCY_DEFINITION_FILENAME from tool_shed.util import hg_util diff -r ae53980fad820db494c67ddb5ad0ad5f9deb9dd1 -r 344e84a6554ae94604f32e8f62feebd65a6ac358 lib/tool_shed/dependencies/tag_attribute_handler.py --- a/lib/tool_shed/dependencies/tag_attribute_handler.py +++ /dev/null @@ -1,199 +0,0 @@ -import copy -import logging - -log = logging.getLogger( __name__ ) - - -class TagAttributeHandler( object ): - - def __init__( self, app, rdd, unpopulate ): - self.app = app - self.altered = False - self.rdd = rdd - self.unpopulate = unpopulate - - def process_action_tag_set( self, elem, message ): - # Here we're inside of an <actions> tag set. See http://localhost:9009/view/devteam/package_r_2_11_0 . - # <action> - # <repository name="package_readline_6_2" owner="devteam"> - # <package name="readline" version="6.2" /> - # </repository> - # </action> - elem_altered = False - new_elem = copy.deepcopy( elem ) - for sub_index, sub_elem in enumerate( elem ): - altered = False - error_message = '' - if sub_elem.tag == 'repository': - altered, new_sub_elem, error_message = \ - self.process_repository_tag_set( parent_elem=elem, - elem_index=sub_index, - elem=sub_elem, - message=message ) - if error_message: - message += error_message - if altered: - if not self.altered: - self.altered = True - if not elem_altered: - elem_altered = True - new_elem[ sub_index ] = new_sub_elem - return elem_altered, new_elem, message - - def process_actions_tag_set( self, elem, message ): - # <actions> - # <package name="libgtextutils" version="0.6"> - # <repository name="package_libgtextutils_0_6" owner="test" prior_installation_required="True" /> - # </package> - from tool_shed.util import xml_util - elem_altered = False - new_elem = copy.deepcopy( elem ) - for sub_index, sub_elem in enumerate( elem ): - altered = False - error_message = '' - if sub_elem.tag == 'package': - altered, new_sub_elem, error_message = self.process_package_tag_set( elem=sub_elem, - message=message ) - elif sub_elem.tag == 'action': - # <action type="set_environment_for_install"> - # <repository name="package_readline_6_2" owner="devteam""> - # <package name="readline" version="6.2" /> - # </repository> - # </action> - altered, new_sub_elem, error_message = self.process_action_tag_set( elem=sub_elem, - message=message ) - else: - # Inspect the sub elements of elem to locate all <repository> tags and - # populate them with toolshed and changeset_revision attributes if necessary. - altered, new_sub_elem, error_message = self.rdd.handle_sub_elem( parent_elem=elem, - elem_index=sub_index, - elem=sub_elem ) - if error_message: - message += error_message - if altered: - if not self.altered: - self.altered = True - if not elem_altered: - elem_altered = True - new_elem[ sub_index ] = new_sub_elem - return elem_altered, new_elem, message - - def process_actions_group_tag_set( self, elem, message, skip_actions_tags=False ): - # Inspect all entries in the <actions_group> tag set, skipping <actions> - # tag sets that define os and architecture attributes. We want to inspect - # only the last <actions> tag set contained within the <actions_group> tag - # set to see if a complex repository dependency is defined. - elem_altered = False - new_elem = copy.deepcopy( elem ) - for sub_index, sub_elem in enumerate( elem ): - altered = False - error_message = '' - if sub_elem.tag == 'actions': - if skip_actions_tags: - # Skip all actions tags that include os or architecture attributes. - system = sub_elem.get( 'os' ) - architecture = sub_elem.get( 'architecture' ) - if system or architecture: - continue - altered, new_sub_elem, error_message = \ - self.process_actions_tag_set( elem=sub_elem, - message=message ) - if error_message: - message += error_message - if altered: - if not self.altered: - self.altered = True - if not elem_altered: - elem_altered = True - new_elem[ sub_index ] = new_sub_elem - return elem_altered, new_elem, message - - def process_config( self, root ): - error_message = '' - new_root = copy.deepcopy( root ) - if root.tag == 'tool_dependency': - for elem_index, elem in enumerate( root ): - altered = False - if elem.tag == 'package': - # <package name="eigen" version="2.0.17"> - altered, new_elem, error_message = \ - self.process_package_tag_set( elem=elem, - message=error_message ) - if altered: - if not self.altered: - self.altered = True - new_root[ elem_index ] = new_elem - else: - error_message = "Invalid tool_dependencies.xml file." - return self.altered, new_root, error_message - - def process_install_tag_set( self, elem, message ): - # <install version="1.0"> - elem_altered = False - new_elem = copy.deepcopy( elem ) - for sub_index, sub_elem in enumerate( elem ): - altered = False - error_message = '' - if sub_elem.tag == 'actions_group': - altered, new_sub_elem, error_message = \ - self.process_actions_group_tag_set( elem=sub_elem, - message=message, - skip_actions_tags=True ) - elif sub_elem.tag == 'actions': - altered, new_sub_elem, error_message = \ - self.process_actions_tag_set( elem=sub_elem, - message=message ) - else: - package_name = elem.get( 'name', '' ) - package_version = elem.get( 'version', '' ) - error_message += 'Version %s of the %s package cannot be installed because ' % \ - ( str( package_version ), str( package_name ) ) - error_message += 'the recipe for installing the package is missing either an ' - error_message += '<actions> tag set or an <actions_group> tag set.' - if error_message: - message += error_message - if altered: - if not self.altered: - self.altered = True - if not elem_altered: - elem_altered = True - new_elem[ sub_index ] = new_sub_elem - return elem_altered, new_elem, message - - def process_package_tag_set( self, elem, message ): - elem_altered = False - new_elem = copy.deepcopy( elem ) - for sub_index, sub_elem in enumerate( elem ): - altered = False - error_message = '' - if sub_elem.tag == 'install': - altered, new_sub_elem, error_message = \ - self.process_install_tag_set( elem=sub_elem, - message=message ) - elif sub_elem.tag == 'repository': - altered, new_sub_elem, error_message = \ - self.process_repository_tag_set( parent_elem=elem, - elem_index=sub_index, - elem=sub_elem, - message=message ) - if error_message: - message += error_message - if altered: - if not self.altered: - self.altered = True - if not elem_altered: - elem_altered = True - new_elem[ sub_index ] = new_sub_elem - return elem_altered, new_elem, message - - def process_repository_tag_set( self, parent_elem, elem_index, elem, message ): - # We have a complex repository dependency. - altered, new_elem, error_message = self.rdd.handle_complex_dependency_elem( parent_elem=parent_elem, - elem_index=elem_index, - elem=elem ) - if error_message: - message += error_message - if altered: - if not self.altered: - self.altered = True - return altered, new_elem, message diff -r ae53980fad820db494c67ddb5ad0ad5f9deb9dd1 -r 344e84a6554ae94604f32e8f62feebd65a6ac358 lib/tool_shed/dependencies/tool/tag_attribute_handler.py --- /dev/null +++ b/lib/tool_shed/dependencies/tool/tag_attribute_handler.py @@ -0,0 +1,199 @@ +import copy +import logging + +log = logging.getLogger( __name__ ) + + +class TagAttributeHandler( object ): + + def __init__( self, app, rdd, unpopulate ): + self.app = app + self.altered = False + self.rdd = rdd + self.unpopulate = unpopulate + + def process_action_tag_set( self, elem, message ): + # Here we're inside of an <actions> tag set. See http://localhost:9009/view/devteam/package_r_2_11_0 . + # <action> + # <repository name="package_readline_6_2" owner="devteam"> + # <package name="readline" version="6.2" /> + # </repository> + # </action> + elem_altered = False + new_elem = copy.deepcopy( elem ) + for sub_index, sub_elem in enumerate( elem ): + altered = False + error_message = '' + if sub_elem.tag == 'repository': + altered, new_sub_elem, error_message = \ + self.process_repository_tag_set( parent_elem=elem, + elem_index=sub_index, + elem=sub_elem, + message=message ) + if error_message: + message += error_message + if altered: + if not self.altered: + self.altered = True + if not elem_altered: + elem_altered = True + new_elem[ sub_index ] = new_sub_elem + return elem_altered, new_elem, message + + def process_actions_tag_set( self, elem, message ): + # <actions> + # <package name="libgtextutils" version="0.6"> + # <repository name="package_libgtextutils_0_6" owner="test" prior_installation_required="True" /> + # </package> + from tool_shed.util import xml_util + elem_altered = False + new_elem = copy.deepcopy( elem ) + for sub_index, sub_elem in enumerate( elem ): + altered = False + error_message = '' + if sub_elem.tag == 'package': + altered, new_sub_elem, error_message = self.process_package_tag_set( elem=sub_elem, + message=message ) + elif sub_elem.tag == 'action': + # <action type="set_environment_for_install"> + # <repository name="package_readline_6_2" owner="devteam""> + # <package name="readline" version="6.2" /> + # </repository> + # </action> + altered, new_sub_elem, error_message = self.process_action_tag_set( elem=sub_elem, + message=message ) + else: + # Inspect the sub elements of elem to locate all <repository> tags and + # populate them with toolshed and changeset_revision attributes if necessary. + altered, new_sub_elem, error_message = self.rdd.handle_sub_elem( parent_elem=elem, + elem_index=sub_index, + elem=sub_elem ) + if error_message: + message += error_message + if altered: + if not self.altered: + self.altered = True + if not elem_altered: + elem_altered = True + new_elem[ sub_index ] = new_sub_elem + return elem_altered, new_elem, message + + def process_actions_group_tag_set( self, elem, message, skip_actions_tags=False ): + # Inspect all entries in the <actions_group> tag set, skipping <actions> + # tag sets that define os and architecture attributes. We want to inspect + # only the last <actions> tag set contained within the <actions_group> tag + # set to see if a complex repository dependency is defined. + elem_altered = False + new_elem = copy.deepcopy( elem ) + for sub_index, sub_elem in enumerate( elem ): + altered = False + error_message = '' + if sub_elem.tag == 'actions': + if skip_actions_tags: + # Skip all actions tags that include os or architecture attributes. + system = sub_elem.get( 'os' ) + architecture = sub_elem.get( 'architecture' ) + if system or architecture: + continue + altered, new_sub_elem, error_message = \ + self.process_actions_tag_set( elem=sub_elem, + message=message ) + if error_message: + message += error_message + if altered: + if not self.altered: + self.altered = True + if not elem_altered: + elem_altered = True + new_elem[ sub_index ] = new_sub_elem + return elem_altered, new_elem, message + + def process_config( self, root ): + error_message = '' + new_root = copy.deepcopy( root ) + if root.tag == 'tool_dependency': + for elem_index, elem in enumerate( root ): + altered = False + if elem.tag == 'package': + # <package name="eigen" version="2.0.17"> + altered, new_elem, error_message = \ + self.process_package_tag_set( elem=elem, + message=error_message ) + if altered: + if not self.altered: + self.altered = True + new_root[ elem_index ] = new_elem + else: + error_message = "Invalid tool_dependencies.xml file." + return self.altered, new_root, error_message + + def process_install_tag_set( self, elem, message ): + # <install version="1.0"> + elem_altered = False + new_elem = copy.deepcopy( elem ) + for sub_index, sub_elem in enumerate( elem ): + altered = False + error_message = '' + if sub_elem.tag == 'actions_group': + altered, new_sub_elem, error_message = \ + self.process_actions_group_tag_set( elem=sub_elem, + message=message, + skip_actions_tags=True ) + elif sub_elem.tag == 'actions': + altered, new_sub_elem, error_message = \ + self.process_actions_tag_set( elem=sub_elem, + message=message ) + else: + package_name = elem.get( 'name', '' ) + package_version = elem.get( 'version', '' ) + error_message += 'Version %s of the %s package cannot be installed because ' % \ + ( str( package_version ), str( package_name ) ) + error_message += 'the recipe for installing the package is missing either an ' + error_message += '<actions> tag set or an <actions_group> tag set.' + if error_message: + message += error_message + if altered: + if not self.altered: + self.altered = True + if not elem_altered: + elem_altered = True + new_elem[ sub_index ] = new_sub_elem + return elem_altered, new_elem, message + + def process_package_tag_set( self, elem, message ): + elem_altered = False + new_elem = copy.deepcopy( elem ) + for sub_index, sub_elem in enumerate( elem ): + altered = False + error_message = '' + if sub_elem.tag == 'install': + altered, new_sub_elem, error_message = \ + self.process_install_tag_set( elem=sub_elem, + message=message ) + elif sub_elem.tag == 'repository': + altered, new_sub_elem, error_message = \ + self.process_repository_tag_set( parent_elem=elem, + elem_index=sub_index, + elem=sub_elem, + message=message ) + if error_message: + message += error_message + if altered: + if not self.altered: + self.altered = True + if not elem_altered: + elem_altered = True + new_elem[ sub_index ] = new_sub_elem + return elem_altered, new_elem, message + + def process_repository_tag_set( self, parent_elem, elem_index, elem, message ): + # We have a complex repository dependency. + altered, new_elem, error_message = self.rdd.handle_complex_dependency_elem( parent_elem=parent_elem, + elem_index=elem_index, + elem=elem ) + if error_message: + message += error_message + if altered: + if not self.altered: + self.altered = True + return altered, new_elem, message diff -r ae53980fad820db494c67ddb5ad0ad5f9deb9dd1 -r 344e84a6554ae94604f32e8f62feebd65a6ac358 lib/tool_shed/util/export_util.py --- a/lib/tool_shed/util/export_util.py +++ b/lib/tool_shed/util/export_util.py @@ -7,7 +7,6 @@ from time import gmtime from time import strftime import tool_shed.repository_types.util as rt_util -from galaxy import eggs from galaxy import web from galaxy.util.odict import odict from tool_shed.dependencies import dependency_manager @@ -21,11 +20,6 @@ from tool_shed.util import xml_util from tool_shed.galaxy_install.repository_dependencies.repository_dependency_manager import RepositoryDependencyManager -eggs.require( 'mercurial' ) - -from mercurial import commands -from mercurial import ui - log = logging.getLogger( __name__ ) CAPSULE_FILENAME = 'capsule' @@ -36,24 +30,9 @@ def __init__( self ): self.exported_repository_elems = [] -def archive_repository_revision( trans, ui, repository, archive_dir, changeset_revision ): - '''Create an un-versioned archive of a repository.''' - 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 = '' - return_code = None - try: - return_code = commands.archive( ui, repo, archive_dir, **options_dict ) - except Exception, e: - error_message = "Error attempting to archive revision <b>%s</b> of repository %s: %s\nReturn code: %s\n" % \ - ( str( changeset_revision ), str( repository.name ), str( e ), str( return_code ) ) - log.exception( error_message ) - return return_code, error_message - -def export_repository( trans, tool_shed_url, repository_id, repository_name, changeset_revision, file_type, +def export_repository( app, user, tool_shed_url, repository_id, repository_name, changeset_revision, file_type, export_repository_dependencies, api=False ): - repository = suc.get_repository_in_tool_shed( trans.app, repository_id ) + repository = suc.get_repository_in_tool_shed( app, repository_id ) repositories_archive_filename = generate_repository_archive_filename( tool_shed_url, str( repository.name ), str( repository.user.username ), @@ -62,16 +41,16 @@ export_repository_dependencies=export_repository_dependencies, use_tmp_archive_dir=True ) if export_repository_dependencies: - repo_info_dicts = get_repo_info_dicts( trans, tool_shed_url, repository_id, changeset_revision ) - repository_ids = get_repository_ids( trans, repo_info_dicts ) + repo_info_dicts = get_repo_info_dicts( app, user, tool_shed_url, repository_id, changeset_revision ) + repository_ids = get_repository_ids( app, repo_info_dicts ) ordered_repository_ids, ordered_repositories, ordered_changeset_revisions = \ - order_components_for_import( trans, repository_id, repository_ids, repo_info_dicts ) + order_components_for_import( app, repository_id, repository_ids, repo_info_dicts ) else: ordered_repository_ids = [] ordered_repositories = [] ordered_changeset_revisions = [] if repository: - repository_metadata = suc.get_current_repository_metadata_for_changeset_revision( trans.app, + repository_metadata = suc.get_current_repository_metadata_for_changeset_revision( app, repository, changeset_revision ) if repository_metadata: @@ -89,7 +68,7 @@ work_dir = tempfile.mkdtemp( prefix="tmp-toolshed-export-er" ) ordered_repository = ordered_repositories[ index ] ordered_changeset_revision = ordered_changeset_revisions[ index ] - repository_archive, error_message = generate_repository_archive( trans, + repository_archive, error_message = generate_repository_archive( app, work_dir, tool_shed_url, ordered_repository, @@ -128,12 +107,15 @@ return dict( download_url=download_url, error_messages=error_messages ) return repositories_archive, error_messages -def generate_repository_archive( trans, work_dir, tool_shed_url, repository, changeset_revision, file_type ): - rdah = dependency_manager.RepositoryDependencyAttributeHandler( trans.app, unpopulate=True ) - tdah = dependency_manager.ToolDependencyAttributeHandler( trans.app, unpopulate=True ) +def generate_repository_archive( app, work_dir, tool_shed_url, repository, changeset_revision, file_type ): + rdah = dependency_manager.RepositoryDependencyAttributeHandler( app, unpopulate=True ) + tdah = dependency_manager.ToolDependencyAttributeHandler( app, unpopulate=True ) file_type_str = get_file_type_str( changeset_revision, file_type ) file_name = '%s-%s' % ( repository.name, file_type_str ) - return_code, error_message = archive_repository_revision( trans, ui, repository, work_dir, changeset_revision ) + return_code, error_message = hg_util.archive_repository_revision( app, + repository, + work_dir, + changeset_revision ) if return_code: return None, error_message repository_archive_name = os.path.join( work_dir, file_name ) @@ -195,7 +177,7 @@ sub_elements[ 'exported_via_api' ] = str( api ) return sub_elements -def get_components_from_repo_info_dict( trans, repo_info_dict ): +def get_components_from_repo_info_dict( app, repo_info_dict ): """ Return the repository and the associated latest installable changeset_revision (including updates) for the repository defined by the received repo_info_dict. @@ -204,8 +186,8 @@ # There should only be one entry in the received repo_info_dict. description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, repository_dependencies, tool_dependencies = \ suc.get_repo_info_tuple_contents( repo_info_tup ) - repository = suc.get_repository_by_name_and_owner( trans.app, repository_name, repository_owner ) - repository_metadata = suc.get_current_repository_metadata_for_changeset_revision( trans.app, + repository = suc.get_repository_by_name_and_owner( app, repository_name, repository_owner ) + repository_metadata = suc.get_current_repository_metadata_for_changeset_revision( app, repository, changeset_revision ) if repository_metadata: @@ -235,30 +217,30 @@ return repo_info_dict return None -def get_repo_info_dicts( trans, tool_shed_url, repository_id, changeset_revision ): +def get_repo_info_dicts( app, user, tool_shed_url, repository_id, changeset_revision ): """ Return a list of dictionaries defining repositories that are required by the repository associated with the received repository_id. """ - rdm = RepositoryDependencyManager( trans.app ) - repository = suc.get_repository_in_tool_shed( trans.app, repository_id ) - repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans.app, repository_id, changeset_revision ) + rdm = RepositoryDependencyManager( app ) + repository = suc.get_repository_in_tool_shed( app, repository_id ) + repository_metadata = suc.get_repository_metadata_by_changeset_revision( app, repository_id, changeset_revision ) # Get a dictionary of all repositories upon which the contents of the current repository_metadata record depend. toolshed_base_url = str( web.url_for( '/', qualified=True ) ).rstrip( '/' ) repository_dependencies = \ - repository_dependency_util.get_repository_dependencies_for_changeset_revision( app=trans.app, + repository_dependency_util.get_repository_dependencies_for_changeset_revision( app=app, repository=repository, repository_metadata=repository_metadata, toolshed_base_url=toolshed_base_url, key_rd_dicts_to_be_processed=None, all_repository_dependencies=None, handled_key_rd_dicts=None ) - repo = hg_util.get_repo_for_repository( trans.app, repository=repository, repo_path=None, create=False ) + repo = hg_util.get_repo_for_repository( 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. repo_info_dict[ str( repository.name ) ] = ( str( repository.description ), - common_util.generate_clone_url_for_repository_in_tool_shed( trans.user, repository ), + common_util.generate_clone_url_for_repository_in_tool_shed( user, repository ), str( changeset_revision ), str( ctx.rev() ), str( repository.user.username ), @@ -292,18 +274,24 @@ sub_elements[ 'categories' ] = categories return attributes, sub_elements -def get_repository_ids( trans, repo_info_dicts ): +def get_repository_ids( app, repo_info_dicts ): """Return a list of repository ids associated with each dictionary in the received repo_info_dicts.""" repository_ids = [] for repo_info_dict in repo_info_dicts: for repository_name, repo_info_tup in repo_info_dict.items(): - description, repository_clone_url, changeset_revision, ctx_rev, repository_owner, repository_dependencies, tool_dependencies = \ - suc.get_repo_info_tuple_contents( repo_info_tup ) - repository = suc.get_repository_by_name_and_owner( trans.app, repository_name, repository_owner ) - repository_ids.append( trans.security.encode_id( repository.id ) ) + description, \ + repository_clone_url, \ + changeset_revision, \ + ctx_rev, \ + repository_owner, \ + repository_dependencies, \ + tool_dependencies = \ + suc.get_repo_info_tuple_contents( repo_info_tup ) + repository = suc.get_repository_by_name_and_owner( app, repository_name, repository_owner ) + repository_ids.append( app.security.encode_id( repository.id ) ) return repository_ids -def order_components_for_import( trans, primary_repository_id, repository_ids, repo_info_dicts ): +def order_components_for_import( app, primary_repository_id, repository_ids, repo_info_dicts ): """ Some repositories may have repository dependencies that must be imported and have metadata set on them before the dependent repository is imported. This method will inspect the list of repositories @@ -322,7 +310,7 @@ # Create a dictionary whose keys are the received repository_ids and whose values are a list of # repository_ids, each of which is contained in the received list of repository_ids and whose associated # repository must be imported prior to the repository associated with the repository_id key. - prior_import_required_dict = suc.get_prior_import_or_install_required_dict( trans.app, repository_ids, repo_info_dicts ) + prior_import_required_dict = suc.get_prior_import_or_install_required_dict( app, repository_ids, repo_info_dicts ) processed_repository_ids = [] # Process the list of repository dependencies defined for the repository associated with the received # primary_repository_id. @@ -340,20 +328,20 @@ if prior_import_required_id not in ordered_repository_ids: # Import the associated repository dependency first. prior_repo_info_dict = get_repo_info_dict_for_import( prior_import_required_id, repository_ids, repo_info_dicts ) - prior_repository, prior_import_changeset_revision = get_components_from_repo_info_dict( trans, prior_repo_info_dict ) + prior_repository, prior_import_changeset_revision = get_components_from_repo_info_dict( app, prior_repo_info_dict ) if prior_repository and prior_import_changeset_revision: ordered_repository_ids.append( prior_import_required_id ) ordered_repositories.append( prior_repository ) ordered_changeset_revisions.append( prior_import_changeset_revision ) repo_info_dict = get_repo_info_dict_for_import( repository_id, repository_ids, repo_info_dicts ) - repository, changeset_revision = get_components_from_repo_info_dict( trans, repo_info_dict ) + repository, changeset_revision = get_components_from_repo_info_dict( app, repo_info_dict ) if repository and changeset_revision: ordered_repository_ids.append( repository_id ) ordered_repositories.append( repository ) ordered_changeset_revisions.append( changeset_revision ) # Process the repository associated with the received primary_repository_id last. repo_info_dict = get_repo_info_dict_for_import( primary_repository_id, repository_ids, repo_info_dicts ) - repository, changeset_revision = get_components_from_repo_info_dict( trans, repo_info_dict ) + repository, changeset_revision = get_components_from_repo_info_dict( app, repo_info_dict ) if repository and changeset_revision: ordered_repository_ids.append( repository_id ) ordered_repositories.append( repository ) diff -r ae53980fad820db494c67ddb5ad0ad5f9deb9dd1 -r 344e84a6554ae94604f32e8f62feebd65a6ac358 lib/tool_shed/util/hg_util.py --- a/lib/tool_shed/util/hg_util.py +++ b/lib/tool_shed/util/hg_util.py @@ -28,6 +28,21 @@ def add_changeset( repo_ui, repo, path_to_filename_in_archive ): commands.add( repo_ui, repo, path_to_filename_in_archive ) +def archive_repository_revision( app, repository, archive_dir, changeset_revision ): + '''Create an un-versioned archive of a repository.''' + repo = get_repo_for_repository( app, repository=repository, repo_path=None, create=False ) + options_dict = get_mercurial_default_options_dict( 'archive' ) + options_dict[ 'rev' ] = changeset_revision + error_message = '' + return_code = None + try: + return_code = commands.archive( get_configured_ui, repo, archive_dir, **options_dict ) + except Exception, e: + error_message = "Error attempting to archive revision <b>%s</b> of repository %s: %s\nReturn code: %s\n" % \ + ( str( changeset_revision ), str( repository.name ), str( e ), str( return_code ) ) + log.exception( error_message ) + return return_code, error_message + def bundle_to_json( fh ): """ Convert the received HG10xx data stream (a mercurial 1.0 bundle created using hg push from the 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.