module Hoe::MercurialHelpers
Mercurial
command wrapper functions.
Constants
- IGNORE_FILE
The name of the ignore file
Public Instance Methods
delete_extra_files( filelist )
click to toggle source
Delete the files in the given filelist
after confirming with the user.
# File lib/hoe/mercurial.rb, line 423 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
edit_commit_log( logfile )
click to toggle source
Generate a commit log and invoke the user's editor on it.
# File lib/hoe/mercurial.rb, line 326 def edit_commit_log( logfile ) diff = make_commit_log() File.open( logfile, 'w' ) do |fh| fh.print( diff ) end edit( logfile ) end
get_current_rev()
click to toggle source
Return the ID for the current rev
# File lib/hoe/mercurial.rb, line 358 def get_current_rev id = read_command_output( 'hg', '-q', 'identify' ) return id.chomp end
get_manifest()
click to toggle source
# File lib/hoe/mercurial.rb, line 344 def get_manifest raw = read_command_output( 'hg', 'manifest' ) return raw.split( $/ ) end
get_numeric_rev()
click to toggle source
Return the current numeric (local) rev number
# File lib/hoe/mercurial.rb, line 365 def get_numeric_rev id = read_command_output( 'hg', '-q', 'identify', '-n' ) return id.chomp[ /^(\d+)/, 1 ] || '0' end
get_repo_paths()
click to toggle source
Read any remote repo paths known by the current repo and return them as a hash.
# File lib/hoe/mercurial.rb, line 379 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
get_tip_info()
click to toggle source
Get the 'tip' info and return it as a Hash
# File lib/hoe/mercurial.rb, line 351 def get_tip_info data = read_command_output( 'hg', 'tip' ) return YAML.load( data ) end
get_uncommitted_files()
click to toggle source
Return the list of files which are not of status 'clean'
# File lib/hoe/mercurial.rb, line 390 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
get_unknown_files()
click to toggle source
Return the list of files which are of status 'unknown'
# File lib/hoe/mercurial.rb, line 400 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
hg_ignore_files( *pathnames )
click to toggle source
Add the list of pathnames
to the .hgignore list.
# File lib/hoe/mercurial.rb, line 410 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
make_changelog()
click to toggle source
Generate a changelog.
# File lib/hoe/mercurial.rb, line 338 def make_changelog log = read_command_output( 'hg', 'log', '--style', 'changelog' ) return log end
make_commit_log()
click to toggle source
Generate a commit log from a diff and return it as a String. At the moment it just returns the diff as-is, but will (someday) do something better.
# File lib/hoe/mercurial.rb, line 317 def make_commit_log diff = read_command_output( 'hg', 'diff' ) fail "No differences." if diff.empty? return diff end