def stage_release(): # LATER: check for uncommitted changes ui_ = ui.ui() repo = hg.repository(ui_, REPO_DIR) # Get current head. heads = [hexlify(repo[head].node())[:12] for head in repo.heads()] assert len(heads) == 1 # Don't try to handle multiple heads head = heads[0] jar_name = "jfniki.%s.jar" % head zip_name = "jfniki.%s.zip" % head export_dir_name = "jfniki.%s" % head zip_file_name = "%s/%s" % (STAGING_DIR, zip_name) jar_file_name = "%s/%s" % (STAGING_DIR, jar_name) # scrub staging directory try: shutil.rmtree(STAGING_DIR) except: pass os.makedirs(STAGING_DIR) # dump clean source to staging dest = "%s/%s" % (STAGING_DIR, export_dir_name) # TRICKY: Had to put a print in the implementation of command.archive to figure # out required default opts. # {'rev': '', 'no_decode': None, 'prefix': '', 'exclude': [], 'include': [], 'type': ''} commands.archive(ui_, repo, dest, rev='', no_decode=None, prefix='', exclude=[], include=[], type='') # remove origin tarballs to save space shutil.rmtree("%s/alien/origins/" % dest) # zip up the source. zip_source(STAGING_DIR, export_dir_name, zip_file_name) # cp freenet.jar required for build os.makedirs("%s/%s/%s" % (STAGING_DIR, export_dir_name, "alien/libs")) shutil.copyfile(FREENET_JAR, "%s/%s/%s" % (STAGING_DIR, export_dir_name, "alien/libs/freenet.jar")) # build jar result = subprocess.check_call(["/usr/bin/ant", "-buildfile", "%s/%s/build.xml" % (STAGING_DIR, export_dir_name)]) print "ant result code: %d" % result # copy jar with name including the hg rev. shutil.copyfile("%s/%s/%s" % (STAGING_DIR, export_dir_name, "build/jar/jfniki.jar"), jar_file_name) print print "SUCCESSFULLY STAGED:" print jar_file_name print zip_file_name print return (head, jar_file_name, zip_file_name)
def export_hg_repo(src_dir, dest_dir, target_rev): """ Export the files in the hg repo in src_dir to dest_dir. """ ui_ = ui.ui() repo = hg.repository(ui_, src_dir) commands.archive(ui_, repo, dest_dir, rev=target_rev, prefix='' # <- needs this to work. ) return repo['tip'].rev()
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 )
def archive_repository_revision(trans, ui, repository, archive_dir, changeset_revision): """Create an un-versioned archive of a repository.""" repo = hg.repository(suc.get_configured_ui(), repository.repo_path(trans.app)) options_dict = suc.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)