
https://svn.lrde.epita.fr/svn/lrdetools/trunk Index: ChangeLog from Nicolas Pouillard <ertai@lrde.epita.fr> More user conf, some bugs, and some cleanup. * vcs/lib/vcs/vcs.rb: Add some class attribute accessors. Adapt to Commands. Handle user configuration variables. * vcs/lib/vcs/changelog.rb: Use Vcs.full_email instead of FULL_EMAIL. * vcs/lib/vcs/edit.rb: Use Vcs.editor instead of EDITOR. * vcs/lib/vcs/news.rb: ... likewise with NNTPSERVER. * vcs/lib/vcs/environment.rb: Set the ENV with the default value. Check_env is now a instance method. * vcs/lib/vcs/mycommit.rb: Use commit_ and remove the useless alias. * vcs/lib/vcs/script.rb, * vcs/lib/vcs/opt_parse.rb, * vcs/lib/vcs/message.rb, * vcs/lib/vcs/last_changed_date.rb, * vcs/lib/vcs/cvs.rb, * vcs/lib/vcs/diffstat.rb, * vcs/lib/vcs/conflict.rb, * vcs/lib/vcs/mail.rb, * vcs/lib/vcs/app.rb: Update or add the license and remove some dead code. app.rb | 11 +---------- changelog.rb | 2 +- conflict.rb | 6 ++++++ cvs.rb | 11 ++++------- diffstat.rb | 2 +- edit.rb | 4 ++-- environment.rb | 9 +++++---- last_changed_date.rb | 8 ++++---- mail.rb | 7 +------ message.rb | 17 +++++++++-------- mycommit.rb | 15 ++++++--------- news.rb | 5 ++--- opt_parse.rb | 1 - script.rb | 2 +- vcs.rb | 46 +++++++++++++++++++++++++++++++++++----------- 15 files changed, 78 insertions(+), 68 deletions(-) Index: vcs/lib/vcs/diffstat.rb --- vcs/lib/vcs/diffstat.rb (revision 228) +++ vcs/lib/vcs/diffstat.rb (working copy) @@ -1,5 +1,5 @@ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. -# Copyright:: Copyright (c) 2004 LRDE. All rights reserved. +# Copyright:: Copyright (c) 2004, 2005 LRDE. All rights reserved. # License:: GNU General Public License (GPL). # Revision:: $Id$ Index: vcs/lib/vcs/script.rb --- vcs/lib/vcs/script.rb (revision 228) +++ vcs/lib/vcs/script.rb (working copy) @@ -16,4 +16,4 @@ end end -end # class Svn +end # class Vcs Index: vcs/lib/vcs/app.rb --- vcs/lib/vcs/app.rb (revision 228) +++ vcs/lib/vcs/app.rb (working copy) @@ -49,16 +49,7 @@ Pathname.glob("{#{@@vcs},#{vcs_dir}}/*.rb") do |file| next if file.to_s =~ /\/(app|opt_parse|vcs)\.rb$/ LOG.debug { file.basename.to_s } - # begin - # require "vcs/#{file.basename}" - # p "eheho" - # rescue LoadError - # begin require file.to_s - # rescue LoadError => ex - # raise ex - # end - # end end @@all_vcs ||= [] Index: vcs/lib/vcs/news.rb --- vcs/lib/vcs/news.rb (revision 228) +++ vcs/lib/vcs/news.rb (working copy) @@ -5,7 +5,6 @@ # $LastChangedBy: ertai $ # $Id: header 98 2004-09-29 12:07:43Z ertai $ -require 'vcs/tools' require 'vcs/message' class Vcs @@ -16,9 +15,9 @@ require 'optparse' result = { - :from => FULL_EMAIL, + :from => Vcs.full_email, :groups => [], - :server => ENV['NNTPSERVER'], + :server => Vcs.nntpserver, } if !args.nil? and !args.empty? and args[0].is_a?(Hash) return result.merge!(args[0]) Index: vcs/lib/vcs/mail.rb --- vcs/lib/vcs/mail.rb (revision 228) +++ vcs/lib/vcs/mail.rb (working copy) @@ -1,5 +1,5 @@ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. -# Copyright:: Copyright (c) 2004 LRDE. All rights reserved. +# Copyright:: Copyright (c) 2004, 2005 LRDE. All rights reserved. # License:: GNU General Public License (GPL). # Revision:: $Id: header 98 2004-09-29 12:07:43Z ertai $ @@ -33,11 +33,6 @@ end def mail_conf_checker - %w[ EMAIL FULLNAME SMTPSERVER ].each do |var| - if ENV[var].nil? or ENV[var].empty? - LOG.error "environment variable `#{var}' not set" - end - end unless `gpg --version` =~ /^gpg \(GnuPG\)/ LOG.error 'command not found: gpg' end Index: vcs/lib/vcs/last_changed_date.rb --- vcs/lib/vcs/last_changed_date.rb (revision 228) +++ vcs/lib/vcs/last_changed_date.rb (working copy) @@ -1,7 +1,7 @@ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. -# Copyright:: Copyright (c) 2004 LRDE. All rights reserved. +# Copyright:: Copyright (c) 2004, 2005 LRDE. All rights reserved. # License:: GNU General Public License (GPL). -# $Id$ +# Revision:: $Id$ require 'vcs/svn' Index: vcs/lib/vcs/edit.rb --- vcs/lib/vcs/edit.rb (revision 228) +++ vcs/lib/vcs/edit.rb (working copy) @@ -1,5 +1,5 @@ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. -# Copyright:: Copyright (c) 2004 LRDE. All rights reserved. +# Copyright:: Copyright (c) 2004, 2005 LRDE. All rights reserved. # License:: GNU General Public License (GPL). # Revision:: $Id$ @@ -9,7 +9,7 @@ def edit! ( *files ) # stringify - cmd = EDITOR + files.flatten.map { |x| x.to_s } > [STDOUT, STDERR] + cmd = Vcs.editor + files.flatten.map { |x| x.to_s } > [STDOUT, STDERR] cmd.run(@runner) end Index: vcs/lib/vcs/changelog.rb --- vcs/lib/vcs/changelog.rb (revision 228) +++ vcs/lib/vcs/changelog.rb (working copy) @@ -82,7 +82,7 @@ cl_add = mkchangelog_from_status(*args) LOG.info "Creating a new `#{cl}' file" cl.open('w') do |f| - head = Time.now.strftime("%Y-%m-%d #{FULL_EMAIL}") + head = Time.now.strftime("%Y-%m-%d #{Vcs.full_email}") f.puts " |--- | ########## Fill this file correctly and remove this line ########## | --- |title: Index: vcs/lib/vcs/conflict.rb --- vcs/lib/vcs/conflict.rb (revision 228) +++ vcs/lib/vcs/conflict.rb (working copy) @@ -1,3 +1,8 @@ +# Copyright:: Copyright (c) 2004, 2005 LRDE. All rights reserved. +# Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. +# License:: Gnu General Public License. +# Revision:: $Id$ + class Vcs def mk_conflicts_list @@ -5,6 +10,7 @@ raise "no conflicts" if ls.empty? ls end + protected :mk_conflicts_list def edit_conflicts! edit! mk_conflicts_list Index: vcs/lib/vcs/vcs.rb --- vcs/lib/vcs/vcs.rb (revision 228) +++ vcs/lib/vcs/vcs.rb (working copy) @@ -1,15 +1,18 @@ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. -# Copyright:: Copyright (c) 2004 LRDE. All rights reserved. +# Copyright:: Copyright (c) 2004, 2005 LRDE. All rights reserved. # License:: GNU General Public License (GPL). - -# $LastChangedBy: ertai $ -# $Id: header 98 2004-09-29 12:07:43Z ertai $ +# Revision:: $Id: header 98 2004-09-29 12:07:43Z ertai $ require 'rubygems' require_gem 'ruby_ex' require 'ruby_ex' Commands.import! Yaml::ChopHeader.import! +require 'logger' +require 'optparse' +require 'etc' +require 'ostruct' +ENV['LC_ALL'] = 'C' # The abstract class for a Vcs wrapper. # Conventions: @@ -25,6 +28,12 @@ # class Vcs + @@version ||= '0.3.0' + @@user_conf ||= OpenStruct.new + cattr_accessor :version + cattr_accessor :default + cattr_accessor :user_conf + class Failure < Exception end @@ -45,15 +54,13 @@ class VcsCmdDataFactory < Commands::Datas::Factory - alias :real_new_command_data :new_command_data - def initialize ( values ) super @command_data_class = VcsCmdData - @__instance = real_new_command_data end def new_command_data + @__instance ||= super @__instance.status = nil @__instance end @@ -276,4 +283,21 @@ @@checkers.each { |meth| send(meth) } end + def self.match ( regexps, file ) + regexps.each do |re| + return true if re.match(file) + end + return false + end + + def self.user_conf_global_ignore ( file ) + return false if user_conf.nil? or user_conf.global_ignore.nil? + match(user_conf.global_ignore, file) + end + + def self.user_conf_global_unmask ( file ) + return false if user_conf.nil? or user_conf.global_unmask.nil? + match(user_conf.global_unmask, file) + end + end # class Vcs Index: vcs/lib/vcs/mycommit.rb --- vcs/lib/vcs/mycommit.rb (revision 228) +++ vcs/lib/vcs/mycommit.rb (working copy) @@ -1,9 +1,7 @@ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. -# Copyright:: Copyright (c) 2004 LRDE. All rights reserved. +# Copyright:: Copyright (c) 2004, 2005 LRDE. All rights reserved. # License:: GNU General Public License (GPL). - -# $LastChangedBy: ertai $ -# $Id: header 98 2004-09-29 12:07:43Z ertai $ +# Revision:: $Id: header 98 2004-09-29 12:07:43Z ertai $ require 'vcs/vcs' @@ -45,7 +43,7 @@ # FIXME simplify cl_entry contents begin - commit!('--message', cl_entry, *(opts + args)) + commit_!('--message', cl_entry, *(opts + args)) ADD_CL.rename(COMMITED) TMP_CL.delete if TMP_CL.exist? rescue @@ -78,7 +76,6 @@ LOG.info "You can remove `#{message_rev}' if everything is ok." end - alias_command :cci, :common_commit def commit_failed LOG.info "#{COMMITED}: Contains your ChangeLog entry" if COMMITED.exist? Index: vcs/lib/vcs/environment.rb --- vcs/lib/vcs/environment.rb (revision 228) +++ vcs/lib/vcs/environment.rb (working copy) @@ -42,16 +42,17 @@ else default = block[] LOG.warn "Need #{name} in the environement (default: #{default})" + ENV[name] = default default end end + end # class << self + def check_env - %w[ email fullname editor pager ].each { |m| send(m) } + %w[ email fullname editor pager ].each { |m| Vcs.send(m) } end - end # class << self - add_conf_checker :check_env end # class Vcs Index: vcs/lib/vcs/opt_parse.rb --- vcs/lib/vcs/opt_parse.rb (revision 228) +++ vcs/lib/vcs/opt_parse.rb (working copy) @@ -26,7 +26,6 @@ o.separator '' o.on('-c', '--vcs TYPE', VcsApp.all_vcs, 'Set your vcs') do |aVcs| - p aVcs Vcs.default = aVcs end Index: vcs/lib/vcs/message.rb --- vcs/lib/vcs/message.rb (revision 228) +++ vcs/lib/vcs/message.rb (working copy) @@ -1,9 +1,7 @@ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. -# Copyright:: Copyright (c) 2004 LRDE. All rights reserved. +# Copyright:: Copyright (c) 2004, 2005 LRDE. All rights reserved. # License:: GNU General Public License (GPL). - -# $LastChangedBy: ertai $ -# $Id: header 98 2004-09-29 12:07:43Z ertai $ +# Revision:: $Id: header 98 2004-09-29 12:07:43Z ertai $ require 'vcs/vcs' require 'vcs/changelog' @@ -12,13 +10,15 @@ def diffw! ( *args ) diff!(*args) end -end +end # class Vcs + class Svn def diffw! ( *args ) diff! '--diff-cmd', 'diff', '-x', '-NPbuw', *args end -end +end # class Svn + class Vcs @@ -27,6 +27,7 @@ def print_body ( file, options ) LOG.info "Creating a new `#{file}' file" file.open('w') do |f| + #FIXME add --- f.puts options.to_yaml f.puts '---' f.puts Index: vcs/lib/vcs/cvs.rb --- vcs/lib/vcs/cvs.rb (revision 228) +++ vcs/lib/vcs/cvs.rb (working copy) @@ -1,9 +1,7 @@ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>. -# Copyright:: Copyright (c) 2004 LRDE. All rights reserved. +# Copyright:: Copyright (c) 2004, 2005 LRDE. All rights reserved. # License:: GNU General Public License (GPL). - -# $LastChangedBy: ertai $ -# $Id: header 98 2004-09-29 12:07:43Z ertai $ +# Revision:: $Id: header 98 2004-09-29 12:07:43Z ertai $ require 'vcs/vcs' @@ -18,4 +16,3 @@ end end # class Cvs -