Class: Svn

Inherits:
Vcs
  • Object
show all
Defined in:
lib/vcs/svn.rb,
lib/vcs/diff.rb,
lib/vcs/list.rb,
lib/vcs/ignore.rb,
lib/vcs/status.rb,
lib/vcs/revision.rb

Overview

Author

Nicolas Pouillard <[email protected]>.

Copyright

Copyright © 2004, 2005 LRDE. All rights reserved.

License

GNU General Public License (GPL).

Revision

$Id: header 98 2004-09-29 12:07:43Z ertai $

Defined Under Namespace

Classes: Failure, StatusEntry

Constant Summary

Constants inherited from Vcs

Vcs::Form, Vcs::IForm, Vcs::LogEntry, Vcs::MAIL, Vcs::Message, Vcs::NEWS

Instance Method Summary collapse

Methods inherited from Vcs

#add!, #back!, #check_diffstat, #check_env, #check_gnu_diff, #commit_failed, #commited?, #concat_changelog!, #concat_changelog_failed, #delete!, #diffstat!, #edit!, #edit_conflicts!, #edit_form!, editor, env, full_email, fullname, #junk!, #last_changed_date!, #mail!, #mail_conf_checker, #mail_failed, method_missing, #mk_changelog_entry!, #mk_form!, #mk_iform!, #mk_log_entry!, #mk_message!, #mk_message_entry!, #news!, #news_conf_checker, #news_failed, pager, #resolve_conflicts!, #script, #script!, #url!

Constructor Details

#initialize(aCmd = 'svn') ⇒ Svn

Returns a new instance of Svn.



11
12
13
14
15
16
17
# File 'lib/vcs/svn.rb', line 11

def initialize ( aCmd='svn' )
  super
  @@svn_option_controller ||=
    OptionController.new(Svn, @@options_specification +
                              Vcs.specific_options.to_a.join("\n"))
  self.option_controller = @@svn_option_controller
end

Instance Method Details

#color_status!(*args) ⇒ Object



72
73
74
75
76
77
# File 'lib/vcs/status.rb', line 72

def color_status! ( *args )
  status(*args) do |status_entry|
    status_entry.colorize!
    puts status_entry.line
  end
end

#diffw!(files_orig = [], options = {}) ⇒ Object

A diff only for your eyes



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vcs/diff.rb', line 25

def diffw! ( files_orig=[], options={} )
  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 unless files.include? se.file
  end
  return if files.empty? and not files_orig.empty?
  diff_! files,
         options.merge(:diff_cmd => 'diff', :extensions => '-NPbuw')
end

#ignore!(files = [], options = {}) ⇒ Object

Add an ignore entry in the given path. Automatically determine the rep concerned with svn:ignore. Examples:

$ svn ignore my_subdir/'*.tex'
$ svn ignore ./foo.generated my_subdir/another/a_wrong_file


14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vcs/ignore.rb', line 14

def ignore! ( files=[], options={} )
  files.each do |file|
    dir, base = file.to_path.split
    logger.info { "Add `#{base}' to svn:ignore of `#{dir}'"}
    data = propget(['svn:ignore', dir], :strict => true)
    data.output.open('a') { |f| f.puts base }
    propset!(['svn:ignore', dir],
             options.merge(:quiet => true, :file => data.output))
    data.clean
  end
end

#list!(files = [], options = {}, &block) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/vcs/list.rb', line 15

def list! ( files=[], options={}, &block )
  if options.has_key?(:do) or block \
      or Vcs.categories.any? { |cat| options.has_key?(cat) }

    action = options[:do]
    options.delete(:do)
    categories = []
    Vcs.categories.each do |cat|
      if options.has_key? cat
        categories << cat
        options.delete(cat)
      end
    end
    inside_versioned = []
    outside_versioned = []
    if categories.empty?
      list_(files, options).output.read.each do |line|
        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$/
          if path.directory?
            if (path/'.svn').exist?
              inside_versioned << path
            else
              outside_versioned << path
              Find.prune
            end
          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
      block[path_list]
    else
      puts path_list
    end
  else
    list_!(files, options)
  end
end

#revision!(*args) ⇒ Object



12
13
14
# File 'lib/vcs/revision.rb', line 12

def revision! ( *args )
  puts info(*args).read[/^Revision:\s+(\d+)/, 1]
end

#status(*args, &block) ⇒ Object

class StatusEntry



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/vcs/status.rb', line 59

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
    result << status_entry
  end
  result.sort_with_regex_list! Vcs.regex_list
  result.each(&block)
end

#status!(*args) ⇒ Object



79
80
81
82
83
84
85
86
87
# File 'lib/vcs/status.rb', line 79

def status! ( *args )
  if color?
    color_status!(*args)
  else
    status(*args) do |status_entry|
      puts status_entry.line
    end
  end
end