https://svn.lrde.epita.fr/svn/lrdetools/trunk
Index: ChangeLog
from Nicolas Pouillard <ertai(a)lrde.epita.fr>
More categories, improve status and list.
* vcs/lib/vcs/vcs.rb: More categories better classify.
* vcs/lib/vcs/status.rb: Simplify.
* vcs/lib/vcs/list.rb: Perform a status on the list of versioned files
in order to classify them.
list.rb | 25 ++++++++++++++++++++-----
status.rb | 4 +---
vcs.rb | 30 ++++++++++++++++++++++++++----
3 files changed, 47 insertions(+), 12 deletions(-)
Index: vcs/lib/vcs/vcs.rb
--- vcs/lib/vcs/vcs.rb (revision 261)
+++ vcs/lib/vcs/vcs.rb (working copy)
@@ -55,7 +55,24 @@
)
@@output_io_methods ||= %w[ print puts putc ] # FIXME and so ...
@@specific_options ||= []
- @@categories ||= [:precious, :unmask, :exclude, :junk, :unrecognize, :normal]
+
+ @@user_defined_categories ||= [:precious, :unmask, :exclude, :junk]
+ @@symbol_category ||=
+ {
+ ?A => :add,
+ ?C => :conflict,
+ ?D => :delete,
+ ?G => :merge,
+ ?I => :ignore,
+ ?M => :modify,
+ ?R => :replace,
+ ?X => :external,
+ ?? => :unrecognize,
+ ?! => :missing,
+ ?~ => :obstruct,
+ }
+ @@categories ||= @@user_defined_categories + @@symbol_category.values
+
cattr_accessor :version
cattr_accessor :default
@@ -63,6 +80,8 @@
cattr_accessor :output_io_methods
cattr_accessor :logger
cattr_accessor :specific_options
+ cattr_accessor :user_defined_categories
+ cattr_accessor :symbol_category
cattr_accessor :categories
class_inheritable_accessor :option_controller
@@ -358,7 +377,7 @@
def run! ( command, files=[], options={} )
flush
cmd_options = option_controller.to_strings(options)
- (@cmd + command + cmd_options + files).run(@runner)
+ (@cmd + command + cmd_options + '--' + files).run(@runner)
end
def sub_vcs ( out, err, &block )
@@ -590,8 +609,11 @@
return false
end
- def classify ( file )
- Vcs.categories.each do |category|
+ def classify ( file, status=nil )
+ if status and category = Vcs.symbol_category[status]
+ return category unless category == :unrecognize
+ end
+ Vcs.user_defined_categories.each do |category|
return category if Vcs.user_conf_match(category, file)
end
return :unrecognize
Index: vcs/lib/vcs/status.rb
--- vcs/lib/vcs/status.rb (revision 261)
+++ vcs/lib/vcs/status.rb (working copy)
@@ -16,11 +16,9 @@
line, file_st, bl1, prop_st, cpy, bl2, file = m.to_a
@file = file.to_path
@file_st, @prop_st, @cpy = file_st[0], prop_st[0], cpy[0]
+ @category = Vcs.classify(@file, @file_st)
if @file_st == ??
- @category = Vcs.classify(@file)
@file_st = @@category_symbol[@category] || @file_st
- else
- @category = :normal
end
@line = "#{(a)file_st.chr}#{bl1}#{prop_st}#{cpy}#{bl2}#{file}"
end
Index: vcs/lib/vcs/list.rb
--- vcs/lib/vcs/list.rb (revision 261)
+++ vcs/lib/vcs/list.rb (working copy)
@@ -25,21 +25,36 @@
options.delete(cat)
end
end
- path_list = PathList.new
+ inside_versioned = []
+ outside_versioned = []
if categories.empty?
list_(files, options).output.read.each do |line|
- path_list << line.chomp.to_path
+ inside_versioned << line.chomp
end
else
files << '.' if files.empty?
files.each do |file|
file.to_path.find do |path|
- Find.prune if path.to_s =~ /(\/|^)\.svn$/
- next if path.to_s == '.'
- path_list << path if categories.include? Vcs.classify(path)
+ if path.to_s =~ /(\/|^)\.svn$/
+ is_versioned << path.dirname
+ Find.prune
+ end
+ next if path.directory?
+ if (path.dirname + '.svn').exist?
+ inside_versioned << path.to_s
+ else
+ outside_versioned << path
+ end
end
end
end
+ path_list = PathList.new
+ status(inside_versioned) do |se|
+ path_list << se.file if categories.include? se.category
+ end
+ outside_versioned.each do |path|
+ path_list << path if categories.include? Vcs.classify(path)
+ end
if action
system "#{action} #{path_list}"
elsif block