module Hoe::MercurialHelpers
def delete_extra_files( filelist )
def delete_extra_files( filelist ) description = humanize_file_list( filelist, ' ' ) log "Files to delete:\n ", description ask_for_confirmation( "Really delete them?", false ) do filelist.each do |f| rm_rf( f, :verbose => true ) end end end
def edit_commit_log( logfile )
def edit_commit_log( logfile ) diff = make_commit_log() File.open( logfile, 'w' ) do |fh| fh.print( diff ) end edit( logfile ) end
def get_current_rev
def get_current_rev id = read_command_output( 'hg', '-q', 'identify' ) return id.chomp end
def get_manifest
def get_manifest raw = read_command_output( 'hg', 'manifest' ) return raw.split( $/ ) end
def get_numeric_rev
def get_numeric_rev id = read_command_output( 'hg', '-q', 'identify', '-n' ) return id.chomp[ /^(\d+)/, 1 ] || '0' end
def get_repo_paths
def get_repo_paths paths = {} pathspec = read_command_output( 'hg', 'paths' ) pathspec.split.each_slice( 3 ) do |name, _, url| paths[ name ] = url end return paths end
def get_tags
def get_tags taglist = read_command_output( 'hg', 'tags' ) return taglist.split( /\n/ ).collect {|tag| tag[/^\S+/] } end
def get_tip_info
def get_tip_info data = read_command_output( 'hg', 'tip' ) return YAML.load( data ) end
def get_uncommitted_files
def get_uncommitted_files list = read_command_output( 'hg', 'status', '-n', '--color', 'never' ) list = list.split( /\n/ ) trace "Changed files: %p" % [ list ] return list end
def get_unknown_files
def get_unknown_files list = read_command_output( 'hg', 'status', '-un', '--color', 'never' ) list = list.split( /\n/ ) trace "New files: %p" % [ list ] return list end
def hg_ignore_files( *pathnames )
def hg_ignore_files( *pathnames ) patterns = pathnames.flatten.collect do |path| '^' + Regexp.escape(path) + '$' end trace "Ignoring %d files." % [ pathnames.length ] IGNORE_FILE.open( File::CREAT|File::WRONLY|File::APPEND, 0644 ) do |fh| fh.puts( patterns ) end end
def make_changelog
def make_changelog log = read_command_output( 'hg', 'log', '--style', 'changelog' ) return log end
def make_commit_log
## Generate a commit log from a diff and return it as a String. At the moment it just
def make_commit_log diff = read_command_output( 'hg', 'diff' ) fail "No differences." if diff.empty? return diff end