1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/f9ef2aecaecd/ changeset: f9ef2aecaecd user: greg date: 2011-07-19 19:48:42 summary: Add exception handling around all mercurial api commit calls. On Linux, the mercurial api's commit seems to bump into issues intermittently, throws an exception, and rolls back the transaction. Although I can reproduce it on Linux, I cannot produce this behavior on a Mac. The exception handler uses a different approach to committing the changes. I've also added this code to the update_for_browsing method. affected #: 3 files (1.9 KB) --- a/lib/galaxy/webapps/community/controllers/common.py Tue Jul 19 11:27:16 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/common.py Tue Jul 19 13:48:42 2011 -0400 @@ -297,7 +297,7 @@ util.send_mail( frm, to, subject, body, trans.app.config ) except Exception, e: log.exception( "An error occurred sending a tool shed repository update alert by email." ) -def update_for_browsing( repository, current_working_dir ): +def update_for_browsing( repository, current_working_dir, commit_message='' ): # Make a copy of a repository's files for browsing. repo_dir = repository.repo_path repo = hg.repository( ui.ui(), repo_dir ) @@ -316,12 +316,15 @@ # ! = deleted, but still tracked # ? = not tracked # I = ignored - # We'll remove all files that are not tracked or ignored. files_to_remove_from_disk = [] + files_to_commit = [] for status_and_file_name in status_and_file_names: if status_and_file_name.startswith( '?' ) or status_and_file_name.startswith( 'I' ): files_to_remove_from_disk.append( os.path.abspath( os.path.join( repo_dir, status_and_file_name.split()[1] ) ) ) + elif status_and_file_name.startswith( 'M' ) or status_and_file_name.startswith( 'A' ) or status_and_file_name.startswith( 'R' ): + files_to_commit.append( os.path.abspath( os.path.join( repo_dir, status_and_file_name.split()[1] ) ) ) for full_path in files_to_remove_from_disk: + # We'll remove all files that are not tracked or ignored. if os.path.isdir( full_path ): try: os.rmdir( full_path ) @@ -336,6 +339,11 @@ except OSError, e: # The directory is not empty pass + if files_to_commit: + if not commit_message: + commit_message = 'Committed changes to: %s' % ', '.join( files_to_commit ) + repo.dirstate.write() + repo.commit( text=commit_message ) os.chdir( repo_dir ) os.system( 'hg update > /dev/null 2>&1' ) os.chdir( current_working_dir ) --- a/lib/galaxy/webapps/community/controllers/repository.py Tue Jul 19 11:27:16 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/repository.py Tue Jul 19 13:48:42 2011 -0400 @@ -425,7 +425,7 @@ repository = get_repository( trans, id ) repo = hg.repository( ui.ui(), repository.repo_path ) current_working_dir = os.getcwd() - update_for_browsing( repository, current_working_dir ) + update_for_browsing( repository, current_working_dir, commit_message=commit_message ) return trans.fill_template( '/webapps/community/repository/browse_repository.mako', repo=repo, repository=repository, @@ -454,11 +454,17 @@ # Commit the change set. if not commit_message: commit_message = 'Deleted selected files' - # Commit the changes. - commands.commit( repo.ui, repo, repo_dir, user=trans.user.username, message=commit_message ) + try: + commands.commit( repo.ui, repo, repo_dir, user=trans.user.username, message=commit_message ) + except Exception, e: + # I never have a problem with commands.commit on a Mac, but in the test/production + # tool shed environment, it occasionally throws a "TypeError: array item must be char" + # exception. If this happens, we'll try the following. + repo.dirstate.write() + repo.commit( text=commit_message ) handle_email_alerts( trans, repository ) # Update the repository files for browsing. - update_for_browsing( repository, current_working_dir ) + update_for_browsing( repository, current_working_dir, commit_message=commit_message ) # Get the new repository tip. repo = hg.repository( ui.ui(), repo_dir ) if tip != repository.tip: --- a/lib/galaxy/webapps/community/controllers/upload.py Tue Jul 19 11:27:16 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/upload.py Tue Jul 19 13:48:42 2011 -0400 @@ -87,7 +87,16 @@ # Move the uploaded file to the load_point within the repository hierarchy. shutil.move( uploaded_file_name, full_path ) commands.add( repo.ui, repo, full_path ) - commands.commit( repo.ui, repo, full_path, user=trans.user.username, message=commit_message ) + """ + try: + commands.commit( repo.ui, repo, full_path, user=trans.user.username, message=commit_message ) + except Exception, e: + # I never have a problem with commands.commit on a Mac, but in the test/production + # tool shed environment, it occasionally throws a "TypeError: array item must be char" + # exception. If this happens, we'll try the following. + repo.dirstate.write() + repo.commit( text=commit_message ) + """ if full_path.endswith( '.loc.sample' ): # Handle the special case where a xxx.loc.sample file is # being uploaded by copying it to ~/tool-data/xxx.loc. @@ -96,7 +105,7 @@ if ok: # Update the repository files for browsing, a by-product of doing this # is eliminating unwanted files from the repository directory. - update_for_browsing( repository, current_working_dir ) + update_for_browsing( repository, current_working_dir, commit_message=commit_message ) # Get the new repository tip. if tip != repository.tip: if ( isgzip or isbz2 ) and uncompress_file: @@ -183,8 +192,14 @@ # Handle the special case where a xxx.loc.sample file is # being uploaded by copying it to ~/tool-data/xxx.loc. copy_sample_loc_file( trans, filename_in_archive ) - # Commit the changes. - commands.commit( repo.ui, repo, full_path, user=trans.user.username, message=commit_message ) + try: + commands.commit( repo.ui, repo, full_path, user=trans.user.username, message=commit_message ) + except Exception, e: + # I never have a problem with commands.commit on a Mac, but in the test/production + # tool shed environment, it occasionally throws a "TypeError: array item must be char" + # exception. If this happens, we'll try the following. + repo.dirstate.write() + repo.commit( text=commit_message ) handle_email_alerts( trans, repository ) return True, '', files_to_remove def uncompress( self, repository, uploaded_file_name, uploaded_file_filename, isgzip, isbz2 ): 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.