Index: ChangeLog
from Nicolas Pouillard <ertai(a)lrde.epita.fr>
* rcs-wrapper/bin/rcsw: Rename to ...
* vcs/bin/rcsw: ... this, and fix a bug with Etc.
* rcs-wrapper/src/mycommit.rb: Rename to ...
* vcs/src/mycommit.rb: ... this, and force an update after the commit.
* rcs-wrapper/src/cvs.rb: Rename to ...
* vcs/src/cvs.rb: ... this.
* rcs-wrapper/src/message.rb: Rename to ...
* vcs/src/message.rb: ... this.
* rcs-wrapper/src/mail.rb: Rename to ...
* vcs/src/mail.rb: ... this.
* rcs-wrapper/src/tools.rb: Rename to ...
* vcs/src/tools.rb: ... this.
* rcs-wrapper/src/prcs.rb: Rename to ...
* vcs/src/prcs.rb: ... this.
* rcs-wrapper/src/news.rb: Rename to ...
* vcs/src/news.rb: ... this.
* rcs-wrapper/src/changelog.rb: Rename to ...
* vcs/src/changelog.rb: ... this.
* rcs-wrapper/src/revision.rb: Rename to ...
* vcs/src/revision.rb: ... this.
* rcs-wrapper/src/rcs.rb: Rename to ...
* vcs/src/rcs.rb: ... this.
* rcs-wrapper/src/svn.rb: Rename to ...
* vcs/src/svn.rb: ... this.
* rcs-wrapper/README: Rename to ...
* vcs/README: ... this.
Index: vcs/src/mycommit.rb
--- vcs/src/mycommit.rb (revision 114)
+++ vcs/src/mycommit.rb (working copy)
@@ -5,12 +5,12 @@
# $LastChangedBy: ertai $
# $Id: header 98 2004-09-29 12:07:43Z ertai $
-require 'rcs'
+require 'vcs'
-class Rcs
+class Vcs
def edit! ( *files )
- system(ENV['EDITOR'], *files)
+ system(ENV['EDITOR'], *files.map { |x| x.to_s })
end
def common_commit! ( *args )
@@ -34,6 +34,8 @@
commit!(*args)
+ update!
+
return self.revision.readline.to_i
end
@@ -66,4 +68,4 @@
end
-end # class Rcs
+end # class Vcs
Index: vcs/src/tools.rb
--- vcs/src/tools.rb (revision 114)
+++ vcs/src/tools.rb (working copy)
@@ -9,15 +9,15 @@
module WarnAndError
def warn ( aString )
- print "#{RCSW}: warning: ", aString, "\n"
+ print "#{VCS}: warning: ", aString, "\n"
end
def error ( aString )
- print "#{RCSW}: error: ", aString, "\n"
+ print "#{VCS}: error: ", aString, "\n"
end
def debug ( aString )
- print "#{RCSW}: debug: ", aString, "\n"
+ print "#{VCS}: debug: ", aString, "\n"
end
end # module WarnAndError
Index: vcs/src/mail.rb
--- vcs/src/mail.rb (revision 115)
+++ vcs/src/mail.rb (working copy)
@@ -5,10 +5,10 @@
# $LastChangedBy: ertai $
# $Id: header 98 2004-09-29 12:07:43Z ertai $
-require 'rcs'
+require 'vcs'
require 'tools'
-class Rcs
+class Vcs
@@mail = Pathname.new(',mail')
@@ -74,4 +74,4 @@
StringIO.new('Mail: Sent.')
end
-end # class Rcs
+end # class Vcs
Index: vcs/src/message.rb
--- vcs/src/message.rb (revision 115)
+++ vcs/src/message.rb (working copy)
@@ -5,10 +5,10 @@
# $LastChangedBy: ertai $
# $Id: header 98 2004-09-29 12:07:43Z ertai $
-require 'rcs'
+require 'vcs'
require 'changelog'
-class Rcs
+class Vcs
@@message = Pathname.new(',message')
@@ -41,4 +41,4 @@
alias_command :msg, :message
-end # class Rcs
+end # class Vcs
Index: vcs/src/svn.rb
--- vcs/src/svn.rb (revision 114)
+++ vcs/src/svn.rb (working copy)
@@ -5,12 +5,16 @@
# $LastChangedBy: ertai $
# $Id: header 98 2004-09-29 12:07:43Z ertai $
-require 'rcs'
+require 'vcs'
require 'tools'
-class Svn < Rcs
+CL = Pathname.new('ChangeLog')
+ADD_CL = Pathname.new(',ChangeLog')
+TMP_CL = Pathname.new(',,ChangeLog')
- class Failure < Rcs::Failure
+class Svn < Vcs
+
+ class Failure < Vcs::Failure
end
def initialize ( aCmd='svn' )
@@ -28,10 +32,10 @@
changelog!
- if run!('commit', '--non-interactive', '-F', @@add_cl,
*args)
+ if run!('commit', '--non-interactive', '-F', ADD_CL, *args)
STDERR.puts "Deleting junk files..."
- @@add_cl.delete
- @@tmp_cl.delete if @@tmp_cl.exist?
+ ADD_CL.delete
+ TMP_CL.delete if TMP_CL.exist?
else
raise Failure, 'commit failed'
end
Index: vcs/src/changelog.rb
--- vcs/src/changelog.rb (revision 114)
+++ vcs/src/changelog.rb (working copy)
@@ -5,7 +5,7 @@
# $LastChangedBy: ertai $
# $Id: header 98 2004-09-29 12:07:43Z ertai $
-require 'rcs'
+require 'vcs'
require 'svn'
class Svn
@@ -41,11 +41,8 @@
end # class Svn
-class Rcs
- @@cl = Pathname.new('ChangeLog')
- @@add_cl = Pathname.new(',ChangeLog')
- @@tmp_cl = Pathname.new(',,ChangeLog')
+class Vcs
class MustBeFilled < Exception
attr_reader :file
@@ -56,7 +53,7 @@
end
def mkchangelog ( *args )
- cl = @@add_cl
+ cl = ADD_CL
if cl.exist?
f = cl.open('r')
@@ -82,21 +79,21 @@
end
def changelog! ( *args )
- unless @@cl.exist?
+ unless CL.exist?
raise Failure, 'No ChangeLog, you are probably not in a valid directory.'
end
if cl = mkchangelog(*args)
- unless @@tmp_cl.exist?
- STDERR.warn "Move ChangeLog to `#{@@tmp_cl}'"
- @@cl.rename(@@tmp_cl)
+ unless TMP_CL.exist?
+ STDERR.warn "Move ChangeLog to `#{TMP_CL}'"
+ CL.rename(TMP_CL)
end
- @@cl.open('w') do |file|
+ CL.open('w') do |file|
cl.each { |line| file.print line }
file.puts
- IO.foreach(@@tmp_cl) { |line| file.print line }
+ IO.foreach(TMP_CL) { |line| file.print line }
end
end
@@ -105,4 +102,5 @@
alias_command :mkcl, :mkchangelog
alias_command :cl, :changelog
-end # class Rcs
+end # class Vcs
+
Index: vcs/src/prcs.rb
--- vcs/src/prcs.rb (revision 114)
+++ vcs/src/prcs.rb (working copy)
@@ -5,9 +5,9 @@
# $LastChangedBy: ertai $
# $Id: header 98 2004-09-29 12:07:43Z ertai $
-require 'rcs'
+require 'vcs'
-class Prcs < Rcs
+class Prcs < Vcs
def initialize ( aCmd='prcs' )
super
Index: vcs/src/rcs.rb
--- vcs/src/rcs.rb (revision 114)
+++ vcs/src/rcs.rb (working copy)
@@ -48,7 +48,7 @@
end # class Class
-# The abstract class for a Rcs wrapper.
+# The abstract class for a Vcs wrapper.
# Conventions:
# example:
# svn checkout
http://foo.bar/proj # normal command
@@ -59,7 +59,7 @@
# checkout!
# checkout_!
#
-class Rcs
+class Vcs
class Failure < Exception
end
@@ -151,5 +151,5 @@
alias_command :checkin, :commit
alias_command :populate, :add
-end # class Rcs
+end # class Vcs
Index: vcs/src/cvs.rb
--- vcs/src/cvs.rb (revision 114)
+++ vcs/src/cvs.rb (working copy)
@@ -5,9 +5,9 @@
# $LastChangedBy: ertai $
# $Id: header 98 2004-09-29 12:07:43Z ertai $
-require 'rcs'
+require 'vcs'
-class Cvs < Rcs
+class Cvs < Vcs
def initialize ( aCmd='cvs' )
super
Index: vcs/src/news.rb
--- vcs/src/news.rb (revision 114)
+++ vcs/src/news.rb (working copy)
@@ -8,7 +8,7 @@
require 'tools'
require 'message'
-class Rcs
+class Vcs
@@news = Pathname.new(',news')
@@ -76,4 +76,4 @@
StringIO.new('News: Sent.')
end
-end # class Rcs
+end # class Vcs
Index: vcs/bin/rcsw
--- vcs/bin/rcsw (revision 114)
+++ vcs/bin/rcsw (working copy)
@@ -13,20 +13,26 @@
require 'pathname'
-RCSW_PATH = Pathname.new(__FILE__).expand_path
-RCSW_DIR, RCSW = RCSW_PATH.split
-SRC = RCSW_DIR + '..' + 'src'
+VCS_PATH = Pathname.new(__FILE__).expand_path
+VCS_DIR, VCS = VCS_PATH.split
+SRC = VCS_DIR + '..' + 'src'
$: << SRC
if ARGV == ['--mk-alias']
- %w[ svn cvs prcs ].each { |x| puts "alias #{x}=#{RCSW_PATH}" }
+ %w[ svn cvs prcs ].each { |x| puts "alias #{x}=#{VCS_PATH}" }
exit
end
-$debug = ENV['RCSW_DEBUG'].to_i
+$debug = ENV['VCS_DEBUG'].to_i
-FULLNAME = ENV['FULLNAME'] || (Etc.getpwnam ENV['USER']).gecos
+if ENV.has_key? 'FULLNAME'
+ FULLNAME = ENV['FULLNAME']
+else
+ require 'etc'
+ FULLNAME = (Etc.getpwnam ENV['USER']).gecos
+ STDERR.warn "Need FULLNAME in the environement (default: #{FULLNAME})"
+end
EMAIL = ENV['EMAIL']
FULL_EMAIL = "#{FULLNAME} <#{EMAIL}>"
if FULLNAME.nil? or EMAIL.nil?
@@ -36,7 +42,7 @@
Pathname.glob(SRC + '*.rb') do |file|
puts file.basename if $debug > 4
- require file
+ require file.basename
end
def guess_rcs
Index: rcs-wrapper/src/revision.rb
--- rcs-wrapper/src/revision.rb (revision 113)
+++ rcs-wrapper/src/revision.rb (working copy)
@@ -1,19 +0,0 @@
-# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>fr>.
-# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
-# License:: GNU General Public License (GPL).
-
-# $LastChangedBy: ertai $
-# $Id: header 98 2004-09-29 12:07:43Z ertai $
-
-require 'svn'
-require 'stringio'
-
-class Svn
-
- def revision ( *args )
- StringIO.new(info.readlines.grep(/^Revision:/)[0].sub(/^Revision: /, ''))
- end
-
- alias_command :rev, :revision
-
-end # class Svn
Index: rcs-wrapper/src/mycommit.rb
--- rcs-wrapper/src/mycommit.rb (revision 113)
+++ rcs-wrapper/src/mycommit.rb (working copy)
@@ -1,69 +0,0 @@
-# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>fr>.
-# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
-# License:: GNU General Public License (GPL).
-
-# $LastChangedBy: ertai $
-# $Id: header 98 2004-09-29 12:07:43Z ertai $
-
-require 'rcs'
-
-class Rcs
-
- def edit! ( *files )
- system(ENV['EDITOR'], *files)
- end
-
- def common_commit! ( *args )
-
- begin
- changelog!(*args)
- rescue MustBeFilled => ex
- edit! ex.file
- end
-
- message!(*args)
-
- edit! @@message
-
- changelog!(*args)
-
- #pager! diff
- #pager! status
-
- args << 'ChangeLog' unless args.grep(/^[^-]/).empty?
-
- commit!(*args)
-
- return self.revision.readline.to_i
-
- end
- protected :common_commit!
-
-
- def lrdetools_commit! ( s, *args )
-
- rev = common_commit!(*args)
-
- s = "LT #{rev}: #{s}"
-
- news(:groups => ['lrde.proj'], :subject => s)
-
- @@message.delete
-
- end
- alias_command :ltci, :lrdetools_commit
-
- def test_commit! ( s, *args )
-
- rev = common_commit!(*args)
-
- s = "Test #{rev}: #{s}"
-
-# news(:groups => ['local.test'], :subject => s)
- mail(:to => ['ertai(a)lrde.epita.fr']fr'], :subject => s)
-
- @@message.delete
-
- end
-
-end # class Rcs
Index: rcs-wrapper/src/tools.rb
--- rcs-wrapper/src/tools.rb (revision 113)
+++ rcs-wrapper/src/tools.rb (working copy)
@@ -1,51 +0,0 @@
-# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>fr>.
-# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
-# License:: GNU General Public License (GPL).
-
-# $LastChangedBy: ertai $
-# $Id: header 98 2004-09-29 12:07:43Z ertai $
-
-
-module WarnAndError
-
- def warn ( aString )
- print "#{RCSW}: warning: ", aString, "\n"
- end
-
- def error ( aString )
- print "#{RCSW}: error: ", aString, "\n"
- end
-
- def debug ( aString )
- print "#{RCSW}: debug: ", aString, "\n"
- end
-
-end # module WarnAndError
-
-
-class IO
- include WarnAndError
-end # class IO
-
-
-require 'stringio'
-class StringIO
- include WarnAndError
-end # class StringIO
-
-
-require 'yaml'
-module YAML
-
- def self.chop_header ( io )
- aStr = io.gets
- raise Exception, "First line is not valid: `#{aLine}'" unless aStr =~
/^---/
- io.each do |aLine|
- break if aLine =~ /^---/
- aStr += aLine
- end
- YAML::load(aStr)
- end
-
-end # module YAML
-
Index: rcs-wrapper/src/mail.rb
--- rcs-wrapper/src/mail.rb (revision 113)
+++ rcs-wrapper/src/mail.rb (working copy)
@@ -1,77 +0,0 @@
-# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>fr>.
-# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
-# License:: GNU General Public License (GPL).
-
-# $LastChangedBy: ertai $
-# $Id: header 98 2004-09-29 12:07:43Z ertai $
-
-require 'rcs'
-require 'tools'
-
-class Rcs
-
- @@mail = Pathname.new(',mail')
-
- def parse_mail_options ( *args )
- require 'optparse'
- result =
- {
- :from => FULL_EMAIL,
- :to => [],
- :server => ENV['SMTPSERVER'] || 'localhost',
- }
- if !args.nil? and !args.empty? and args[0].is_a?(Hash)
- args[0].each do |k,v|
- result[k] = v
- end
- return result
- end
- OptionParser.new do |opts|
- opts.separator ''
- opts.on('-t', '--mail-to NAME', 'Choose a recipient') do
|aString|
- result[:to] << aString
- end
- opts.on('-s', '--server NAME', 'Choose a mail server') do
|aString|
- result[:server] = aString
- end
- opts.on('-S', '--subject NAME', 'Choose your mail subject')
do |aString|
- result[:subject] = aString.sub(/\.?$/, '.')
- end
- opts.on_tail('-h', '--help', 'Show this message') do
- puts opts
- exit
- end
- end.parse!(args)
- raise Failure, 'No recipents' if result[:to].empty?
- raise Failure, 'No mail server' if result[:server].nil?
- raise Failure, 'No mail subject' if result[:subject].nil?
- result
- end
- protected :parse_mail_options
-
- #
- # Mail.
- #
- def mail ( *args )
-
- print_body(@@mail, parse_mail_options(*args)) unless @@mail.exist?
-
- @@mail.open('r') do |file|
- opt = YAML::chop_header(file)
- STDERR.puts "Smtp Server: #{opt[:server]}"
- require 'net/smtp'
- Net::SMTP.start(opt[:server], 25) do |smtp|
- smtp.open_message_stream(EMAIL, opt[:to]) do |f|
- f.print "From: #{opt[:from]}\n"
- f.print "Subject: #{opt[:subject]}\n"
- f.print "To: #{opt[:to].join(', ')}\n"
- f.print "\n"
- file.each { |line| f.print line }
- end
- end
- end
- @@mail.delete
- StringIO.new('Mail: Sent.')
- end
-
-end # class Rcs
Index: rcs-wrapper/src/message.rb
--- rcs-wrapper/src/message.rb (revision 113)
+++ rcs-wrapper/src/message.rb (working copy)
@@ -1,44 +0,0 @@
-# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>fr>.
-# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
-# License:: GNU General Public License (GPL).
-
-# $LastChangedBy: ertai $
-# $Id: header 98 2004-09-29 12:07:43Z ertai $
-
-require 'rcs'
-require 'changelog'
-
-class Rcs
-
- @@message = Pathname.new(',message')
-
- def print_body ( file, options )
- STDERR.warn "Creating a new `#{file}' file"
- file.open('w') do |f|
- f.puts options.to_yaml
- f.puts '---'
- f.puts
- message.each do |line|
- f.print line
- end
- end
- end
- private :print_body
-
- def message ( *args )
- unless @@message.exist?
- cl = mkchangelog(*args)
- @@message.open('w') do |f|
- f.puts 'Index: ChangeLog'
- cl.each { |line| f.print line.sub(/^\d+-\d+-\d+/, 'from') }
- f.puts
- # FIXME: need to remove the ChangeLog entry in diff.
- diff(*args).each { |line| f.print line unless line =~ /^=+$/ }
- end
- end
- @@message.open('r')
- end
-
- alias_command :msg, :message
-
-end # class Rcs
Index: rcs-wrapper/src/svn.rb
--- rcs-wrapper/src/svn.rb (revision 113)
+++ rcs-wrapper/src/svn.rb (working copy)
@@ -1,41 +0,0 @@
-# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>fr>.
-# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
-# License:: GNU General Public License (GPL).
-
-# $LastChangedBy: ertai $
-# $Id: header 98 2004-09-29 12:07:43Z ertai $
-
-require 'rcs'
-require 'tools'
-
-class Svn < Rcs
-
- class Failure < Rcs::Failure
- end
-
- def initialize ( aCmd='svn' )
- super
- end
-
- %w[ blame copy list move switch revert info
- propdel propget proplist propset mkdir ].each do |m|
- add_basic_method(m)
- end
-
- add_basic_method!(:propedit)
-
- def commit! ( *args )
-
- changelog!
-
- if run!('commit', '--non-interactive', '-F', @@add_cl,
*args)
- STDERR.puts "Deleting junk files..."
- @@add_cl.delete
- @@tmp_cl.delete if @@tmp_cl.exist?
- else
- raise Failure, 'commit failed'
- end
-
- end
-
-end # class Svn
Index: rcs-wrapper/src/changelog.rb
--- rcs-wrapper/src/changelog.rb (revision 113)
+++ rcs-wrapper/src/changelog.rb (working copy)
@@ -1,108 +0,0 @@
-# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>fr>.
-# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
-# License:: GNU General Public License (GPL).
-
-# $LastChangedBy: ertai $
-# $Id: header 98 2004-09-29 12:07:43Z ertai $
-
-require 'rcs'
-require 'svn'
-
-class Svn
-
- @@file_st =
- {
- 'A' => 'New',
- 'D' => 'Remove',
- 'M' => ''
- }
-
- @@prop_st =
- {
- 'M' => 'Changed property'
- }
-
- def mkchangelog_from_status ( *args )
- result = {}
- status(*args).each do |line|
- line =~ /^(.)(.).(.).\s*(.*)$/
- if $1 != '?'
- file_st, prop_st, copy_st, file = @@file_st[$1], @@prop_st[$2], $3, $4
- str = ''
- str += file_st if file_st
- str += (file_st.nil?) ? prop_st : (', ' + prop_st.downcase) if prop_st
- result[file] = str
- end
- end
- raise Failure, 'No changes, so no ChangeLog entry.' if result.empty?
- result
- end
- private :mkchangelog_from_status
-
-end # class Svn
-
-class Rcs
-
- @@cl = Pathname.new('ChangeLog')
- @@add_cl = Pathname.new(',ChangeLog')
- @@tmp_cl = Pathname.new(',,ChangeLog')
-
- class MustBeFilled < Exception
- attr_reader :file
- def initialize ( file )
- @file = file
- super("You must fill this file: `#{file.to_s}'")
- end
- end
-
- def mkchangelog ( *args )
- cl = @@add_cl
-
- if cl.exist?
- f = cl.open('r')
- if f.readline !~ /^===/
- f.rewind
- return f
- end
- f.close
- else
- cl_add = mkchangelog_from_status(*args)
- STDERR.warn "Creating a new `#{cl}' file"
- cl.open('w') do |f|
- f.puts '=== Fill this file correctly and remove this line ==='
- f.puts `date +"%Y-%m-%d #{FULL_EMAIL}"`
- f.puts
- cl_add.each do |file, str|
- f.puts "\t* #{file}: #{str}."
- end
- end
- end
-
- raise MustBeFilled, cl
- end
-
- def changelog! ( *args )
- unless @@cl.exist?
- raise Failure, 'No ChangeLog, you are probably not in a valid directory.'
- end
-
- if cl = mkchangelog(*args)
-
- unless @@tmp_cl.exist?
- STDERR.warn "Move ChangeLog to `#{@@tmp_cl}'"
- @@cl.rename(@@tmp_cl)
- end
-
- @@cl.open('w') do |file|
- cl.each { |line| file.print line }
- file.puts
- IO.foreach(@@tmp_cl) { |line| file.print line }
- end
-
- end
- end
-
- alias_command :mkcl, :mkchangelog
- alias_command :cl, :changelog
-
-end # class Rcs
Index: rcs-wrapper/src/prcs.rb
--- rcs-wrapper/src/prcs.rb (revision 113)
+++ rcs-wrapper/src/prcs.rb (working copy)
@@ -1,21 +0,0 @@
-# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>fr>.
-# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
-# License:: GNU General Public License (GPL).
-
-# $LastChangedBy: ertai $
-# $Id: header 98 2004-09-29 12:07:43Z ertai $
-
-require 'rcs'
-
-class Prcs < Rcs
-
- def initialize ( aCmd='prcs' )
- super
- end
-
- %w[ admin ].each do |m|
- add_basic_method(m)
- end
-
-end # class Prcs
-
Index: rcs-wrapper/src/rcs.rb
--- rcs-wrapper/src/rcs.rb (revision 113)
+++ rcs-wrapper/src/rcs.rb (working copy)
@@ -1,155 +0,0 @@
-# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>fr>.
-# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
-# License:: GNU General Public License (GPL).
-
-# $LastChangedBy: ertai $
-# $Id: header 98 2004-09-29 12:07:43Z ertai $
-
-class Class # :nodoc:
-
- def add_basic_method ( meth )
- class_eval <<-end_eval
- def #{meth} ( *args )
- run("#{meth}", *args)
- end
- def #{meth}_ ( *args )
- run("#{meth}", *args)
- end
- end_eval
- end
-
- def add_basic_method! ( meth )
- class_eval <<-end_eval
- def #{meth}! ( *args )
- run!("#{meth}", *args)
- end
- def #{meth}_! ( *args )
- run!("#{meth}", *args)
- end
- end_eval
- end
-
- def alias_command ( m1, m2 )
- class_eval <<-end_eval
- def #{m1} ( *args )
- #{m2}(*args)
- end
- def #{m1}_ ( *args )
- #{m2}_(*args)
- end
- def #{m1}! ( *args )
- #{m2}!(*args)
- end
- def #{m1}_! ( *args )
- #{m2}_!(*args)
- end
- end_eval
- end
-
-end # class Class
-
-# The abstract class for a Rcs wrapper.
-# Conventions:
-# example:
-# svn checkout
http://foo.bar/proj # normal command
-# xrcs checkout
http://foo.bar/proj # normal
-#
-# checkout
-# checkout_
-# checkout!
-# checkout_!
-#
-class Rcs
-
- class Failure < Exception
- end
-
- def initialize ( aCmd )
- @cmd = aCmd
- end
-
- def common_run ( args )
- cmd = @cmd + ' ' + args.join(' ')
- STDERR.debug "running: #{cmd}" if $debug > 1
- cmd
- end
- private :common_run
-
- def run ( *args )
- IO.popen(common_run(args))
- end
-
- def run! ( *args )
- system(common_run(args))
- end
-
- %w[ checkout delete diff help status log add update ].each do |m|
- add_basic_method(m)
- end
-
- add_basic_method!(:commit)
-
- def method_missing ( meth, *args )
- meth = meth.to_s
- if meth =~ /^(.*)!$/
- if respond_to? $1
- send($1, *args).each do |line|
- puts line
- end
- else
- STDERR.warn "unknown method #{meth}"
- run!($1.sub(/_$/, ''), *args)
- end
- else
- STDERR.warn "unknown method #{meth}"
- run(meth.sub(/_$/, ''), *args)
- end
- end
-
- alias_command :ann, :blame
- alias_command :annotate, :blame
- alias_command :praise, :blame
- alias_command :co, :checkout
- alias_command :ci, :commit
- alias_command :cp, :copy
- alias_command :del, :delete
- alias_command :remove, :delete
- alias_command :rm, :delete
- alias_command :di, :diff
- alias_command :h, :help
- alias_command :ls, :list
- alias_command :mv, :move
- alias_command :rename, :move
- alias_command :ren, :move
- alias_command :pdel, :propdel
- alias_command :pd, :propdel
- alias_command :pedit, :propedit
- alias_command :pe, :propedit
- alias_command :pget, :propget
- alias_command :pg, :propget
- alias_command :plist, :proplist
- alias_command :pl, :proplist
- alias_command :pset, :propset
- alias_command :ps, :propset
- alias_command :st, :status
- alias_command :stat, :status
- alias_command :sw, :switch
- alias_command :up, :update
-
- # Cvs Alias
- alias_command :new, :add
- alias_command :rcs, :admin
- alias_command :get, :checkout
- alias_command :rlog, :log
- alias_command :patch, :rdiff
- alias_command :remove, :delete
- alias_command :rm, :delete
- alias_command :rfreeze, :rtag
- alias_command :freeze, :tag
-
- # Prcs Alias
- alias_command :checkin, :commit
- alias_command :populate, :add
-
-end # class Rcs
-
Index: rcs-wrapper/src/cvs.rb
--- rcs-wrapper/src/cvs.rb (revision 113)
+++ rcs-wrapper/src/cvs.rb (working copy)
@@ -1,21 +0,0 @@
-# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>fr>.
-# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
-# License:: GNU General Public License (GPL).
-
-# $LastChangedBy: ertai $
-# $Id: header 98 2004-09-29 12:07:43Z ertai $
-
-require 'rcs'
-
-class Cvs < Rcs
-
- def initialize ( aCmd='cvs' )
- super
- end
-
- %w[ rdiff rtag tag ].each do |m|
- add_basic_method(m)
- end
-
-end # class Cvs
-
Index: rcs-wrapper/src/news.rb
--- rcs-wrapper/src/news.rb (revision 113)
+++ rcs-wrapper/src/news.rb (working copy)
@@ -1,79 +0,0 @@
-# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>fr>.
-# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
-# License:: GNU General Public License (GPL).
-
-# $LastChangedBy: ertai $
-# $Id: header 98 2004-09-29 12:07:43Z ertai $
-
-require 'tools'
-require 'message'
-
-class Rcs
-
- @@news = Pathname.new(',news')
-
- def parse_news_options ( *args )
- require 'optparse'
- result =
- {
- :from => FULL_EMAIL,
- :groups => [],
- :server => ENV['NNTPSERVER'],
- }
- if !args.nil? and !args.empty? and args[0].is_a?(Hash)
- args[0].each do |k,v|
- result[k] = v
- end
- return result
- end
- OptionParser.new do |opts|
- opts.separator ''
- opts.on('-g', '--group NAME', 'Choose a news group') do
|aString|
- result[:groups] << aString
- end
- opts.on('-s', '--server NAME', 'Choose a news server') do
|aString|
- result[:server] = aString
- end
- opts.on('-S', '--subject NAME', 'Choose your news subject')
do |aString|
- result[:subject] = aString
- end
- opts.on_tail('-h', '--help', 'Show this message') do
- puts opts
- exit
- end
- end.parse!(args)
- raise Failure, 'No news group' if result[:groups].empty?
- raise Failure, 'No news server' if result[:server].nil?
- raise Failure, 'No news subject' if result[:subject].nil?
- result
- end
- protected :parse_news_options
-
- #
- # Post the news.
- #
- def news ( *args )
- print_body(@@news, parse_news_options(*args)) unless @@news.exist?
-
- @@news.open('r') do |file|
- opt = YAML::chop_header(file)
- STDERR.puts "Nntp Server: #{opt[:server]}"
- require 'socket'
- TCPSocket.open(opt[:server], 119) do |f|
- f.puts 'post'
- f.puts "Newsgroups: #{opt[:groups].join(', ')}"
- f.puts "From: #{opt[:from]}"
- f.puts "Subject: #{opt[:subject]}"
- f.puts
- file.each do |line|
- f.print line.gsub(/^\./, ' .')
- end
- f.puts '.'
- f.puts 'quit'
- end
- end
- @@news.delete
- StringIO.new('News: Sent.')
- end
-
-end # class Rcs
Index: rcs-wrapper/bin/rcsw
--- rcs-wrapper/bin/rcsw (revision 113)
+++ rcs-wrapper/bin/rcsw (working copy)
@@ -1,75 +0,0 @@
-#!/usr/bin/env ruby
-# Author:: Nicolas Pouillard <ertai(a)lrde.epita.fr>fr>.
-# Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
-# License:: GNU General Public License (GPL).
-
-# $LastChangedBy: ertai $
-# $Id: header 98 2004-09-29 12:07:43Z ertai $
-
-
-# rcsw : The rcs wrapper.
-#
-# rcsw is a wrapper over any revision control system.
-
-require 'pathname'
-
-RCSW_PATH = Pathname.new(__FILE__).expand_path
-RCSW_DIR, RCSW = RCSW_PATH.split
-SRC = RCSW_DIR + '..' + 'src'
-$: << SRC
-
-
-if ARGV == ['--mk-alias']
- %w[ svn cvs prcs ].each { |x| puts "alias #{x}=#{RCSW_PATH}" }
- exit
-end
-
-$debug = ENV['RCSW_DEBUG'].to_i
-
-FULLNAME = ENV['FULLNAME'] || (Etc.getpwnam ENV['USER']).gecos
-EMAIL = ENV['EMAIL']
-FULL_EMAIL = "#{FULLNAME} <#{EMAIL}>"
-if FULLNAME.nil? or EMAIL.nil?
- STDERR.error 'Need FULLNAME and EMAIL in the environement'
- exit
-end
-
-Pathname.glob(SRC + '*.rb') do |file|
- puts file.basename if $debug > 4
- require file
-end
-
-def guess_rcs
- if Pathname.new('CVS').directory?
- Cvs
- elsif Pathname.new('.svn').directory?
- Svn
- elsif Pathname.new('prj').exist?
- Prcs
- else
- raise ArgumentError, 'Can\'t guess your RCS system'
- end
-end
-
-def main
- rcs = guess_rcs().new
-
- if ARGV.empty?
- meth = :help!
- else
- meth = ARGV.shift.sub(/([^!])$/, '\1!')
- end
-
- begin
- rcs.send(meth, *ARGV)
- rescue Exception
- raise if $debug > 0
- STDERR.error $!.to_s.sub(/\.$/, '') unless $!.to_s == 'exit'
- end
-end
-
-if __FILE__ == $0
-
- main()
-
-end
Index: rcs-wrapper/README
--- rcs-wrapper/README (revision 113)
+++ rcs-wrapper/README (working copy)
@@ -1,100 +0,0 @@
----
-
-Intro: >
- Bon voilà je n'ai pas trop le temps en ce moment de m'occuper de cet outil.
- Il est bien commencé et à mon goût déjà utilisable.
-
- Je vais continuer à le debugger, mais en attendant vous pouvez vous amuser
- avec.
-
- C'est un wrapper pour les systèmes de versions comme Svn, Cvs, Prcs, Arch...
-
- Il permet donc au minimum de faire tout ce que le système sous-jacent propose,
- mais l'avantage est de pouvoir l'étendre facilement.
-
-Exemples d'utilisation:
-
- - Pour plus de transparence on va faire des alias:
- genre: alias svn=...../rcsw, idem pour cvs, prcs...
- pour cela taper simplement: >
- `le_chemin_vers_rcsw/bin/rcsw --mk-alias`
-
- - Les commandes de svn fonctionnent toujours: >
- placez vous dans un répertoire svn.
-
- ex: svn status
-
- - Les commandes de base peuvent être surchargées: >
- par exemple `svn commit' a un comportement non interactif par défaut.
-
- Mais l'on peut tout de même appeler le véritable `svn commit'.
-
- Pour cela il y a une convention: toutes les méthodes terminant par `_'
- sont directement celles du système.
-
- Avec cela on peut vérifier que l'outil est bien devant le vrai svn:
- svn status_
-
- - Quelques fonctionnalités:
-
- - Un des principaux avantages est la gestion des erreurs: >
-
- Par exemple on utilise une commande qui commit puis poste une news.
- Si le commit réussit et que la news ne passe pas, il suffit de
- relancer l'envoi de la news: svn news
-
- En effet chaque méthode peut conserver des fichiers, ces fichiers
- commencent par `,'.
-
- - Les alias de méthodes: >
-
- Tout comme svn et cvs il existe des raccourcis pour certaines méthodes
- et bien sûr lorsque l'on surcharge une méthode, le raccourci pointe
- vers la nouvelle méthode.
-
- - Quelques nouvelles méthodes:
-
- - svn revision: Renvoie le numéro de révision courante
- alias: rev
-
- - svn mkchangelog: Génère une entrée de ChangeLog à partir de `status'
- alias: mkcl
-
- - svn changelog: Concatène la nouvelle entrée au véritable ChangeLog
- alias: cl
-
- - svn message: Crée le contenu du message du mail ou de la news
- alias: msg
-
- - svn mail: Envoie un mail.
-
- - svn news: Poste une news.
-
- - Plus facile d'écrire des scripts: >
-
- Lorsque l'on veut automatiser un traitement fait avec un Rcs,
- il est généralement plus simple de le faire en script shell
- lorsque cela n'excède pas une dixaine de lignes. Après cela certains
- avantages des langages de script évolués nous manquent.
- Pourtant certaines choses très faciles peuvent devenir plus lourdes:
- svn commit => system("svn commit")
-
- Heureusement avec le modèle objet déjà posé cela devient plus
- raisonnable, comparez par exemple:
-
- svn commit => svn.commit
-
- svn info | grep '^Revision' | sed s/^Revision: //
-
- =>
-
- svn.info.readlines.grep(/^Revision/)[0].sub(/^Revision: /, '').to_i
-
- - Exemple final: commit complet pour les lrde tools.
-
- commande: svn lrdetools_commit 'votre sujet pour la news'
-
- ensuite: laissez vous guider.
-
- - S'il y a des questions il y aura des réponses.
-