[LrdeTools] 233: Generalize the use of diffw in Vcs.

https://svn.lrde.epita.fr/svn/lrdetools/trunk Index: ChangeLog from Nicolas Pouillard <ertai@lrde.epita.fr> Generalize the use of diffw in Vcs. * vcs/lib/vcs/message.rb, vcs/lib/vcs/diffstat.rb * vcs/lib/vcs/changelog.rb: Use diffw. * vcs/lib/vcs/diff.rb: Add a configuration checker for Gnu Diff. Merge diffw_from_status and diffw. Do not call the diff if the list of files become empty. changelog.rb | 2 +- diff.rb | 23 +++++++++++++++-------- diffstat.rb | 4 ++-- message.rb | 2 +- 4 files changed, 19 insertions(+), 12 deletions(-) Index: vcs/lib/vcs/diffstat.rb --- vcs/lib/vcs/diffstat.rb (revision 232) +++ vcs/lib/vcs/diffstat.rb (working copy) @@ -12,13 +12,13 @@ # display statitics on your patch. def diffstat! ( *a ) check_diffstat - (diff(*a) | @@diffstat).run(@runner) + (diffw(*a) | @@diffstat).run(@runner) end alias_command :ds, :diffstat def check_diffstat unless `diffstat -V` =~ /diffstat version/ - raise ArgumentError, 'The `diffstat\' tool is needed by Vcs.diffstat' + raise ArgumentError, 'The `diffstat\' tool is needed by Vcs#diffstat' end end Index: vcs/lib/vcs/changelog.rb --- vcs/lib/vcs/changelog.rb (revision 232) +++ vcs/lib/vcs/changelog.rb (working copy) @@ -112,7 +112,7 @@ |\t For example <%= status.read %> will include the `svn status' output. | |".head_cut! - with(f).diff!(*args) + with(f).diffw!(*args) end raise MustBeFilled, cl Index: vcs/lib/vcs/diff.rb --- vcs/lib/vcs/diff.rb (revision 232) +++ vcs/lib/vcs/diff.rb (working copy) @@ -4,9 +4,18 @@ # Revision:: $Id$ class Vcs + def diffw! ( *args ) - diff!(*args) + diff_!(*args) + end + + def check_gnu_diff + unless `diff --version` =~ /GNU/ + raise ArgumentError, 'Gnu diff is needed by Vcs#diffw' + end end + add_conf_checker :check_gnu_diff + end # class Vcs @@ -14,17 +23,15 @@ # A diff only for your eyes def diffw! ( *args ) - diff! '--diff-cmd', 'diff', '-x', '-NPbuw', *args - end - - def diffw_from_status! ( *args ) files = Set.new from_status(*args) do |line, file_st, prop_st, cpy, file| next if file_st =~ /[?X\\,D]/ - next if file == 'ChangeLog' - files << Pathname.new(file) + next if file.to_s == 'ChangeLog' + next if file.directory? + files << file end - diffw!(*files.delete_if { |f| f.directory? }) + return if files.empty? and not args.empty? + diff_! '--diff-cmd', 'diff', '-x', '-NPbuw', *files end end # class Svn Index: vcs/lib/vcs/message.rb --- vcs/lib/vcs/message.rb (revision 232) +++ vcs/lib/vcs/message.rb (working copy) @@ -44,7 +44,7 @@ f.puts with(f).diffstat!(*args) f.puts - diffw_from_status(*args).each_line do |line| + diffw(*args).each_line do |line| f.print line if line !~ /^=+$/ end end
participants (1)
-
Nicolas Pouillard