https://svn.lrde.epita.fr/svn/lrdetools/trunk
Index: ChangeLog from Nicolas Pouillard ertai@lrde.epita.fr
Vcs now support ruby 1.8.3.
* vcs/lib/vcs/vcs.rb: Adapt to Logger 1.2.6. Fix the help command. Make Vcs works with the vendor dir. * vcs/lib/vcs/message.rb: Make print_body works with YAML of ruby 1.8.3.
message.rb | 10 +++++----- vcs.rb | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 10 deletions(-)
Index: vcs/lib/vcs/vcs.rb --- vcs/lib/vcs/vcs.rb (revision 257) +++ vcs/lib/vcs/vcs.rb (working copy) @@ -3,9 +3,23 @@ # License:: GNU General Public License (GPL). # Revision:: $Id: header 98 2004-09-29 12:07:43Z ertai $
+require 'pathname' +lib = Pathname.new(__FILE__).dirname.parent +vendor = lib.parent + 'vendor' +unless defined? RubyEx + $CORE_EX_VENDORS ||= [] + $CORE_EX_VENDORS << vendor + file = vendor + 'ruby_ex' + 'lib' + 'ruby_ex.rb' + if file.exist? + require file.to_s + else require 'rubygems' require_gem 'ruby_ex' require 'ruby_ex' + end +end +lib.load_path! +RubyEx.import! Commands.import! Yaml::ChopHeader.import! require 'logger' @@ -69,13 +83,23 @@ ].compact.map { |x| stylize x }.join end
- def format_message(severity, timestamp, msg, progname) + def mk_message ( severity, progname, msg ) progname += ': ' unless progname.nil? or progname.empty? msg.inject([]) do |accu, line| accu << header(progname, severity) << line.chomp << "\n" end.join end
+ if ::Logger.const_defined? :VERSION and ::Logger::VERSION >= '1.2.6' + def format_message(severity, timestamp, progname, msg) + mk_message(severity, progname, msg) + end + else + def format_message(severity, timestamp, msg, progname) + mk_message(severity, progname, msg) + end + end + @@headers ||= {}
@@style = @@ -376,10 +400,12 @@ run!(name, *args) end end + protected :run_missing!
def run_argv ( argv ) options, files = option_controller.parse(argv) - if files.empty? or options[:help] + if files.empty? + options.delete(:help) meth = :help! else meth = files.shift.dup @@ -440,13 +466,15 @@ end path.read end + protected :with_cache
def with_cache! ( *a, &b ) puts with_cache(*a, &b) end + protected :with_cache!
- def help! ( *args ) - return help_!(*args) unless args.empty? + def help! ( files=[], options={} ) + return help_!(files, options) unless files.empty? and options.empty? puts "usage: #{@cmd.command} <subcommand> [options] [args] |Type '#{@cmd.command} help <subcommand>' for help on a specific subcommand. | @@ -456,7 +484,7 @@ | |Available subcommands:".head_cut! cmds = [] - methods.each do |meth| + public_methods.each do |meth| next if meth =~ /_!?$/ next unless meth =~ /^(.+)!$/ cmd = $1 Index: vcs/lib/vcs/message.rb --- vcs/lib/vcs/message.rb (revision 257) +++ vcs/lib/vcs/message.rb (working copy) @@ -8,17 +8,17 @@ def print_body ( file, options, files=[] ) logger.info "Creating a new `#{file}' file" file.open('w') do |f| - #FIXME add --- - f.puts options.to_yaml + f.puts '---' + f.puts options.to_yaml.gsub(/---\s*/, '') f.puts '---' f.puts - with(f).message!(files) + with(f).mk_message!(files) end end private :print_body
- def message! ( files=[], options={} ) + def mk_message! ( files=[], options={} ) with_cache! Message, 'generated message (ChangeLog, diffstat, diff)' do url! if defined? COLLABOA @@ -42,7 +42,7 @@ end end end - alias_command :msg, :message + alias_command :msg, :mk_message Message = ',message'.to_path unless defined? Message