[LrdeTools] 246: Make some generalizations with file categories.

https://svn.lrde.epita.fr/svn/lrdetools/trunk Index: ChangeLog from Nicolas Pouillard <ertai@lrde.epita.fr> Make some generalizations with file categories. * vcs/lib/vcs/vcs.rb: Add Vcs.categories and simplify classify. Some fixes for options. * vcs/lib/vcs/svn.rb: Little fix to make the option_controller make only once. svn.rb | 6 +++++- vcs.rb | 15 ++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) Index: vcs/lib/vcs/svn.rb --- vcs/lib/vcs/svn.rb (revision 245) +++ vcs/lib/vcs/svn.rb (working copy) @@ -10,6 +10,10 @@ def initialize ( aCmd='svn' ) super + @@svn_option_controller ||= + OptionController.new(Svn, @@options_specification + + Vcs.specific_options.join("\n")) + self.option_controller = @@svn_option_controller end %w[ blame cat cleanup copy export import list log merge mkdir move propedit @@ -17,7 +21,7 @@ add_basic_method(m) end - self.option_controller = OptionController.new Svn, " + @@options_specification ||= " --auto-props --config-dir DIR --diff-cmd CMD Index: vcs/lib/vcs/vcs.rb --- vcs/lib/vcs/vcs.rb (revision 245) +++ vcs/lib/vcs/vcs.rb (working copy) @@ -39,12 +39,16 @@ :sign => true ) @@output_io_methods ||= %w[ print puts putc ] # FIXME and so ... + @@specific_options ||= [] + @@categories ||= [:precious, :unmask, :exclude, :junk, :unrecognize, :normal] cattr_accessor :version cattr_accessor :default cattr_accessor :user_conf cattr_accessor :output_io_methods cattr_accessor :logger + cattr_accessor :specific_options + cattr_accessor :categories class_inheritable_accessor :option_controller @@ -109,7 +113,6 @@ begin @output.read rescue IOError => ex - Vcs.logger.debug { ex.long_pp } super end end @@ -147,6 +150,7 @@ (?:\sor\s(-(?:\?|\w)))? # Another one (-f or -o) \) )? + \s* (.*?) # An argument (--foo NUM) \s* (?:\{(.*)\})? # A type (--foo NUM {Integer}) @@ -165,7 +169,8 @@ end def to_a_for_option_parser - @shortcuts + ["--#@name#@argument", @type].compact + argument = (@argument.nil? || @argument.empty?)? '' : ' ' + @argument + @shortcuts + ["--#@name#{argument}", @type].compact end def to_sym @@ -370,7 +375,7 @@ meth.sub!(/([^!])$/, '\1!') if meth != 'script' end logger.debug { "meth: #{meth}, files: #{files.inspect}, options: #{options.inspect}" } - result = send(meth, files, options) + send(meth, files, options) end %w[ checkout delete diff status log add update commit ].each do |m| @@ -388,7 +393,7 @@ end else with_bang = meth + '!' - return run_missing!(meth, *args) unless respond_to? with_bang + return run_missing!(meth, meth, *args) unless respond_to? with_bang copy = sub_vcs_with_name(meth) copy.send(with_bang, *args) out = copy.cmd_data @@ -547,7 +552,7 @@ end def classify ( file ) - [:precious, :unmask, :exclude, :junk].each do |category| + Vcs.categories.each do |category| return category if Vcs.user_conf_match(category, file) end return :unrecognize
participants (1)
-
Nicolas Pouillard