https://svn.lrde.epita.fr/svn/lrdetools/trunk
Index: ChangeLog
from Nicolas Pouillard <ertai(a)lrde.epita.fr>
Generalize the color usage.
* vcs/lib/vcs/vcs.rb: Add Vcs#color? and Vcs#color, remove Vcs.color.
* vcs/lib/vcs/status.rb: Simplify using the generalized version.
status.rb | 10 ++++------
vcs.rb | 21 +++++++++++++++++----
2 files changed, 21 insertions(+), 10 deletions(-)
Index: vcs/lib/vcs/vcs.rb
--- vcs/lib/vcs/vcs.rb (revision 240)
+++ vcs/lib/vcs/vcs.rb (working copy)
@@ -293,6 +293,23 @@
end
end
+ def color?
+ case Vcs.user_conf.color
+ when :never then return false
+ when :auto then return output.tty?
+ when :always then return true
+ else raise ArgumentError, "Bad value for Vcs.color: #{Vcs.color}"
+ end
+ end
+
+ def color ( aString, *someStyles )
+ if color?
+ @h.color(aString, *someStyles)
+ else
+ aString
+ end
+ end
+
CL = Pathname.new('ChangeLog') unless defined? CL
TMP_CL = Pathname.new(',,ChangeLog') unless defined? TMP_CL
@@ -383,10 +400,6 @@
end
end
- def color
- user_conf.color
- end
-
# Here we can handle version conflicts with vcs extensions
def protocol_version ( aVersion )
if aVersion != '0.1'
Index: vcs/lib/vcs/status.rb
--- vcs/lib/vcs/status.rb (revision 240)
+++ vcs/lib/vcs/status.rb (working copy)
@@ -40,16 +40,14 @@
end
def status! ( *args )
- case Vcs.color
- when :never
- when :auto then return color_status!(*args) if output.tty?
- when :always then return color_status!(*args)
- else raise ArgumentError, "Bad value for Vcs.color: #{Vcs.color}"
- end
+ if color?
+ color_status!(*args)
+ else
from_status(*args) do |line, file_st, prop_st, cpy, file|
puts line
end
end
+ end
@@style ||=
{