LT 118: Rename to vcs (2/2)

Index: ChangeLog from Nicolas Pouillard <ertai@lrde.epita.fr> * vcs/src/rcs.rb: Rename to ... * vcs/src/vcs.rb: ... this. * vcs/bin/rcsw: Rename to ... * vcs/bin/vcs: ... this. Index: vcs/src/rcs.rb --- vcs/src/rcs.rb (revision 117) +++ vcs/src/rcs.rb (working copy) @@ -1,155 +0,0 @@ -# Author:: Nicolas Pouillard <ertai@lrde.epita.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 Vcs wrapper. -# Conventions: -# example: -# svn checkout http://foo.bar/proj # normal command -# xrcs checkout http://foo.bar/proj # normal -# -# checkout -# checkout_ -# checkout! -# checkout_! -# -class Vcs - - 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 Vcs - Index: vcs/bin/rcsw --- vcs/bin/rcsw (revision 117) +++ vcs/bin/rcsw (working copy) @@ -1,81 +0,0 @@ -#!/usr/bin/env ruby -# Author:: Nicolas Pouillard <ertai@lrde.epita.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' - -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}=#{VCS_PATH}" } - exit -end - -$debug = ENV['VCS_DEBUG'].to_i - -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? - 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.basename -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
participants (1)
-
Nicolas Pouillard