https://svn.lrde.epita.fr/svn/lrdetools/trunk
Index: ChangeLog from Nicolas Pouillard ertai@lrde.epita.fr
Vcs outputs can now be sorted!.
* vcs/NEWS: Explain the sorting feature. * vcs/lib/vcs/vcs.rb: Add sorting to the default configuration. Add Vcs.regex_list. * vcs/lib/vcs/svn.rb: Fix the --revision switch which does not takes just an integer. * vcs/lib/vcs/status.rb: Add a comment attribute to StatusEntry. Add a color for the X status. Call the sort_with_regex_list in the status method. * vcs/lib/vcs/diff.rb: Remove the set which lose the order. * vcs/lib/vcs/changelog.rb: Adapt.
NEWS | 38 ++++++++++++++++++++++++++++++++++++++ lib/vcs/changelog.rb | 7 ++++--- lib/vcs/diff.rb | 7 ++++--- lib/vcs/status.rb | 12 ++++++++++-- lib/vcs/svn.rb | 2 +- lib/vcs/vcs.rb | 5 +++++ 6 files changed, 62 insertions(+), 9 deletions(-)
Index: vcs/NEWS --- vcs/NEWS (revision 253) +++ vcs/NEWS (working copy) @@ -59,6 +59,44 @@
- svn junk: This command use `list' to remove all junk files.
+ * Sorted outputs: + - Vcs now support sorting!!! + In a .vcs configuration file you can add a `sorting' key which + contains a list of regular expressions. + For example: + >>>> ~/.vcs <<<< + --- + sorting: + - !re (NEWS|README|TODO) # These files in first + - !re src/ # Then the src directory + - !re test/ # Then the test directory + - !re parse/ # parse and ast are subdirectories + - !re ast/ # present in both src and test + - !re .cc$ # directories. Thus you will get + - !re .hh$ # something like: + # - NEWS + # - src/parse/a.hh + # - src/parse/b.hh + # - src/parse/a.cc + # - src/parse/b.cc + # - src/ast/a.hh + # - src/ast/b.hh + # - src/ast/a.cc + # - src/ast/b.cc + # - test/parse/a.hh + # - test/parse/a.cc + # - test/ast/a.hh + # - test/ast/a.cc + - Affected commands: + - status + - diffw (a more human readable diff) + - mk_log_entry + - mk_changelog_entry + - mk_message_entry + - diffstat + - message + - mk_form + New in 0.3 2005-09-16:
* The help command now show all commands including vcs ones. Index: vcs/lib/vcs/vcs.rb --- vcs/lib/vcs/vcs.rb (revision 253) +++ vcs/lib/vcs/vcs.rb (working copy) @@ -36,6 +36,7 @@ :junk => [/^,/], :precious => [/^(+|.vcs)/], :color => :auto, + :sorting => [], :sign => true ) @@output_io_methods ||= %w[ print puts putc ] # FIXME and so ... @@ -576,6 +577,10 @@ end end
+ def regex_list + @@regex_list ||= RegexList.new(user_conf.sorting) + end + def merge_user_conf ( conf ) conf = YAML.load(conf.read) if conf.is_a? Pathname conf.each do |k, v| Index: vcs/lib/vcs/svn.rb --- vcs/lib/vcs/svn.rb (revision 253) +++ vcs/lib/vcs/svn.rb (working copy) @@ -54,7 +54,7 @@ --quiet (-q) --recursive (-R) --relocate FROM TO [PATH...] - --revision (-r) REV {Integer} + --revision (-r) REV --revprop --show-updates (-u) --stop-on-copy Index: vcs/lib/vcs/status.rb --- vcs/lib/vcs/status.rb (revision 253) +++ vcs/lib/vcs/status.rb (working copy) @@ -8,7 +8,7 @@ class Svn
class StatusEntry - attr_accessor :line, :file_st, :prop_st, :cpy, :file, :category + attr_accessor :line, :file_st, :prop_st, :cpy, :file, :category, :comment
def initialize ( high_line, aString ) @high_line = high_line @@ -29,6 +29,10 @@ @line[0] = @high_line.color(@file_st.chr, *@@style[@file_st]) end
+ def to_s + @file.to_s + end + @@category_symbol ||= { :precious => ?+, @@ -44,6 +48,7 @@ ?, => [:YELLOW], ?+ => [:YELLOW], ?G => [:BLUE], + ?X => [:BLUE], ?D => [:MAGENTA], ?R => [:MAGENTA], ?~ => [:RED], @@ -55,12 +60,15 @@
def status ( *args, &block ) return status_(*args) if block.nil? + result = PathList.new status_(*args).each_line do |line| next unless line =~ /^.{5} / status_entry = StatusEntry.new(@h, line) next if status_entry.category == :exclude - block[status_entry] + result << status_entry end + result.sort_with_regex_list! Vcs.regex_list + result.each(&block) end
def color_status! ( *args ) Index: vcs/lib/vcs/diff.rb --- vcs/lib/vcs/diff.rb (revision 253) +++ vcs/lib/vcs/diff.rb (working copy) @@ -23,15 +23,16 @@
# A diff only for your eyes def diffw! ( files_orig=[], options={} ) - files = Set.new + files = [] status(files_orig) do |se| next if se.file_st.chr =~ /[?X\,+D]/ next if se.file.to_s == 'ChangeLog' next if se.file.directory? - files << se.file + files << se.file unless files.include? se.file end return if files.empty? and not files_orig.empty? - diff_! files.to_a, options.merge(:diff_cmd => 'diff', :extensions => '-NPbuw') + diff_! files, + options.merge(:diff_cmd => 'diff', :extensions => '-NPbuw') end
end # class Svn Index: vcs/lib/vcs/changelog.rb --- vcs/lib/vcs/changelog.rb (revision 253) +++ vcs/lib/vcs/changelog.rb (working copy) @@ -27,7 +27,8 @@ next if se.file.to_s == 'ChangeLog' ls = [@@file_st[se.file_st], @@prop_st[se.prop_st]].compact! ls.first.capitalize! unless ls.empty? - result << [se.file, ls.join(', ')] + se.comment = ls.join(', ') + result << se end raise Failure, 'No changes, so no ChangeLog entry.' if result.empty? result @@ -38,8 +39,8 @@ # Same switches as status def mk_log_entry! ( *args ) with_cache! LogEntry, 'Log entry' do - mk_log_entry_contents(*args).each do |file, comments| - puts "- #{file}: #{comments}." + mk_log_entry_contents(*args).each do |se| + puts "- #{se.file}: #{se.comment}." end end end