vcs 0.1 → 0.2.148

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/Rakefile +17 -3
  2. data/bin/vcs +57 -34
  3. data/doc/jamis.rb +564 -0
  4. data/ruby_ex/abstract.rb +254 -0
  5. data/ruby_ex/abstract_node.rb +85 -0
  6. data/ruby_ex/algorithms/simulated_annealing.rb +140 -0
  7. data/ruby_ex/array_each_pair.rb +18 -0
  8. data/ruby_ex/ask.rb +101 -0
  9. data/ruby_ex/attributed_class.rb +302 -0
  10. data/ruby_ex/cache.rb +373 -0
  11. data/ruby_ex/checkout.rb +12 -0
  12. data/ruby_ex/choose.rb +271 -0
  13. data/ruby_ex/commands.rb +18 -0
  14. data/ruby_ex/commands/command.rb +401 -0
  15. data/ruby_ex/commands/datas.rb +16 -0
  16. data/ruby_ex/commands/datas/data.rb +33 -0
  17. data/ruby_ex/commands/datas/factory.rb +66 -0
  18. data/ruby_ex/commands/factory.rb +66 -0
  19. data/ruby_ex/commands/helpers.rb +67 -0
  20. data/ruby_ex/commands/pipe.rb +64 -0
  21. data/ruby_ex/commands/runners.rb +17 -0
  22. data/ruby_ex/commands/runners/exec.rb +49 -0
  23. data/ruby_ex/commands/runners/fork.rb +97 -0
  24. data/ruby_ex/commands/runners/runner.rb +107 -0
  25. data/ruby_ex/commands/seq.rb +27 -0
  26. data/ruby_ex/config_file.rb +96 -0
  27. data/ruby_ex/const_regexp.rb +59 -0
  28. data/ruby_ex/daemon.rb +134 -0
  29. data/ruby_ex/diff.rb +667 -0
  30. data/ruby_ex/dlogger.rb +62 -0
  31. data/ruby_ex/drb/dispatcher.rb +252 -0
  32. data/ruby_ex/drb/dispatcher_server_test.rb +29 -0
  33. data/ruby_ex/drb/drb_observable.rb +97 -0
  34. data/ruby_ex/drb/drb_observable_pool.rb +27 -0
  35. data/ruby_ex/drb/drb_service.rb +43 -0
  36. data/ruby_ex/drb/drb_undumped_attributes.rb +55 -0
  37. data/ruby_ex/drb/drb_undumped_indexed_object.rb +54 -0
  38. data/ruby_ex/drb/insecure_protected_methods.rb +103 -0
  39. data/ruby_ex/drb/session_client_test.rb +40 -0
  40. data/ruby_ex/drb/session_manager.rb +246 -0
  41. data/ruby_ex/drb/session_server.rb +53 -0
  42. data/ruby_ex/dtime.rb +143 -0
  43. data/ruby_ex/dumpable_proc.rb +63 -0
  44. data/ruby_ex/exception.rb +32 -0
  45. data/ruby_ex/filetype.rb +229 -0
  46. data/ruby_ex/fileutils_ex.rb +44 -0
  47. data/ruby_ex/fold.rb +58 -0
  48. data/ruby_ex/generate_id.rb +44 -0
  49. data/ruby_ex/hookable.rb +262 -0
  50. data/ruby_ex/hooker.rb +54 -0
  51. data/ruby_ex/inactive_timeout.rb +137 -0
  52. data/ruby_ex/indexed_node.rb +66 -0
  53. data/ruby_ex/io_marshal.rb +100 -0
  54. data/ruby_ex/ioo.rb +194 -0
  55. data/ruby_ex/labeled_node.rb +63 -0
  56. data/ruby_ex/logger_observer.rb +23 -0
  57. data/ruby_ex/md5sum.rb +66 -0
  58. data/ruby_ex/mktemp.rb +208 -0
  59. data/ruby_ex/module/attr_once.rb +36 -0
  60. data/ruby_ex/module/autoload_tree.rb +75 -0
  61. data/ruby_ex/module/hierarchy.rb +335 -0
  62. data/ruby_ex/module/instance_method_visibility.rb +73 -0
  63. data/ruby_ex/module_ex.rb +11 -0
  64. data/ruby_ex/node.rb +80 -0
  65. data/ruby_ex/object_monitor.rb +145 -0
  66. data/ruby_ex/object_monitor_activity.rb +33 -0
  67. data/ruby_ex/observable.rb +140 -0
  68. data/ruby_ex/observable_pool.rb +293 -0
  69. data/ruby_ex/orderedhash.rb +252 -0
  70. data/ruby_ex/pathname_ex.rb +152 -0
  71. data/ruby_ex/pp_hierarchy.rb +29 -0
  72. data/ruby_ex/pseudo_cache.rb +190 -0
  73. data/ruby_ex/queue.rb +56 -0
  74. data/ruby_ex/random_generators.rb +25 -0
  75. data/ruby_ex/random_generators/random_generator.rb +31 -0
  76. data/ruby_ex/random_generators/ruby.rb +23 -0
  77. data/ruby_ex/safe_eval.rb +348 -0
  78. data/ruby_ex/sendmail.rb +215 -0
  79. data/ruby_ex/service_manager.rb +121 -0
  80. data/ruby_ex/session/administrable.rb +120 -0
  81. data/ruby_ex/session/client.rb +153 -0
  82. data/ruby_ex/session/const.rb +18 -0
  83. data/ruby_ex/session/dispatcher.rb +184 -0
  84. data/ruby_ex/session/error.rb +21 -0
  85. data/ruby_ex/session/fetchable.rb +57 -0
  86. data/ruby_ex/session/fetcher.rb +62 -0
  87. data/ruby_ex/session/hookable.rb +26 -0
  88. data/ruby_ex/session/profile.rb +110 -0
  89. data/ruby_ex/session/server.rb +582 -0
  90. data/ruby_ex/session/test/administrable_test.rb +337 -0
  91. data/ruby_ex/session/test/basic_test.rb +523 -0
  92. data/ruby_ex/session/test/dispatcher_test.rb +409 -0
  93. data/ruby_ex/session/test/fetchable_test.rb +119 -0
  94. data/ruby_ex/session/test/sub_server_test.rb +188 -0
  95. data/ruby_ex/shuffle.rb +30 -0
  96. data/ruby_ex/spring.rb +136 -0
  97. data/ruby_ex/spring_set.rb +137 -0
  98. data/ruby_ex/string_ex.rb +28 -0
  99. data/ruby_ex/symtbl.rb +106 -0
  100. data/ruby_ex/synflow.rb +474 -0
  101. data/ruby_ex/test/unit/ui/yaml/testrunner.rb +164 -0
  102. data/ruby_ex/thread_mutex.rb +10 -0
  103. data/ruby_ex/timeout_ex.rb +81 -0
  104. data/ruby_ex/top_down.rb +73 -0
  105. data/ruby_ex/trace.rb +26 -0
  106. data/ruby_ex/uri/druby.rb +81 -0
  107. data/ruby_ex/uri/file.rb +65 -0
  108. data/ruby_ex/uri/ftp_ex.rb +37 -0
  109. data/ruby_ex/uri/http_ex.rb +43 -0
  110. data/ruby_ex/uri/ssh.rb +92 -0
  111. data/ruby_ex/uri/svn.rb +118 -0
  112. data/ruby_ex/uri_ex.rb +45 -0
  113. data/ruby_ex/verbose_object.rb +30 -0
  114. data/ruby_ex/version.rb +66 -0
  115. data/ruby_ex/yaml/basenode_ext.rb +63 -0
  116. data/ruby_ex/yaml/chop_header.rb +23 -0
  117. data/ruby_ex/yaml/transform.rb +449 -0
  118. data/ruby_ex/yaml/yregexpath.rb +76 -0
  119. data/src/changelog.rb +28 -18
  120. data/src/conflict.rb +20 -0
  121. data/src/diff.rb +18 -0
  122. data/src/diffstat.rb +9 -3
  123. data/src/last_changed_date.rb +18 -0
  124. data/src/mail.rb +33 -65
  125. data/src/message.rb +15 -9
  126. data/src/mycommit.rb +29 -14
  127. data/src/news.rb +24 -3
  128. data/src/status.rb +17 -0
  129. data/src/svn.rb +2 -2
  130. data/src/vcs.rb +24 -3
  131. metadata +124 -5
  132. data/lrdetools.rb +0 -12
@@ -0,0 +1,76 @@
1
+ # Author:: Marco Tessari <marco.tessari@epita.fr>.
2
+ # Copyright:: Copyright (c) 2004 TTK Team. All rights reserved.
3
+ # License:: Ruby license.
4
+
5
+ # $LastChangedBy: polrop $
6
+ # $Id: yregexpath.rb 159 2005-02-18 12:07:23Z polrop $
7
+
8
+ module YAML
9
+
10
+ class YRegexPath
11
+ attr_reader :segments, :root, :wanted_node_index
12
+
13
+ def initialize ( str )
14
+ raise ArgumentError, 'Argument must be a string' unless str.is_a?(String)
15
+ @segments = []
16
+ @wanted_node_index = nil
17
+ @root = (str[0] == ?/)
18
+ while str =~ /^(\/|#)?((?:(?:\\.)|[^\\=\/#])+)(?:=((?:(?:\\.)|[^\\\/#])*))?/
19
+ if ($1 == "#")
20
+ if (@wanted_node_index.nil?)
21
+ @wanted_node_index = @segments.length
22
+ else
23
+ raise ArgumentError, 'More than a "#" given.'
24
+ end
25
+ end
26
+ if ($3.nil?)
27
+ @segments << Regexp.new($2)
28
+ else
29
+ @segments << [ Regexp.new($2), Regexp.new($3) ]
30
+ end
31
+ str = $'
32
+ end
33
+ @wanted_node_index = @segments.length if @wanted_node_index.nil?
34
+ end
35
+ end
36
+
37
+ end # module YAML
38
+
39
+ if defined? TEST_MODE or $0 == __FILE__
40
+
41
+ require 'test/unit'
42
+
43
+ class YRegexPathTest < Test::Unit::TestCase
44
+ def compare(str, tab)
45
+ tab.collect! do |e|
46
+ if (e.is_a?(Array))
47
+ e.collect! { |s| Regexp.new(s) unless s.nil? }
48
+ else
49
+ Regexp.new(e)
50
+ end
51
+ end
52
+ desc = "Compare #{str} with #{tab}."
53
+ assert_equal(tab, YAML::YRegexPath.new(str).segments, desc)
54
+ end
55
+
56
+ def testit
57
+ compare('mho', [ 'mho' ])
58
+ compare('mho\\', [ 'mho' ])
59
+ compare('/mho', [ 'mho' ])
60
+ compare('/mho=42', [ [ 'mho', '42'] ])
61
+ compare('/mho=[0-9]+', [ [ 'mho', '[0-9]+' ] ])
62
+ compare('m\/ho', [ 'm\/ho' ])
63
+ compare('mho/foo', [ 'mho', 'foo' ])
64
+ compare('mho=35/foo=test', [ [ 'mho' , '35' ], [ 'foo' , 'test' ] ])
65
+ compare('test#status=PASS', [ 'test' , [ 'status' , 'PASS' ] ])
66
+ compare('mho#', [ 'mho' ])
67
+ end
68
+
69
+ def test_errors
70
+ # Build with something else than a String.
71
+ assert_raise(ArgumentError) { YAML::YRegexPath.new(42) }
72
+ # Two '#'.
73
+ assert_raise(ArgumentError) { YAML::YRegexPath.new('1#2#3') }
74
+ end
75
+ end
76
+ end
@@ -14,8 +14,8 @@ class Svn
14
14
  {
15
15
  'A' => 'New',
16
16
  'D' => 'Remove',
17
- 'M' => ''
18
17
  }
18
+ @@file_st.default = ''
19
19
 
20
20
  @@prop_st =
21
21
  {
@@ -24,16 +24,13 @@ class Svn
24
24
 
25
25
  def mkchangelog_from_status ( *args )
26
26
  result = []
27
- status(*args).each do |line|
28
- next unless line =~ /^.{5} /
29
- line =~ /^(.)(.).(.).\s*(.*)$/
30
- if $1 != '?'
31
- file_st, prop_st, copy_st, file = @@file_st[$1], @@prop_st[$2], $3, $4
32
- str = ''
33
- str += file_st if file_st
34
- str += (file_st.nil?) ? prop_st : (', ' + prop_st.downcase) if prop_st
35
- result << [file, str]
36
- end
27
+ from_status(*args) do |line, file_st, prop_st, copy_st, file|
28
+ next if file_st =~ /[?X]/
29
+ next if file == 'ChangeLog'
30
+ ls = []
31
+ ls << @@file_st[file_st] if @@file_st.has_key? file_st
32
+ ls << @@prop_st[prop_st].downcase if @@prop_st.has_key? prop_st
33
+ result << [file, ls.join(', ')]
37
34
  end
38
35
  raise Failure, 'No changes, so no ChangeLog entry.' if result.empty?
39
36
  result
@@ -54,6 +51,8 @@ class Vcs
54
51
  end
55
52
 
56
53
  def mkchangelog ( *args )
54
+ error_handling :changelog_failed
55
+
57
56
  cl = ADD_CL
58
57
 
59
58
  if cl.exist?
@@ -68,7 +67,7 @@ class Vcs
68
67
  LOG.warn "Creating a new `#{cl}' file"
69
68
  cl.open('w') do |f|
70
69
  f.puts '=== Fill this file correctly and remove this line ==='
71
- f.puts `date +"%Y-%m-%d #{FULL_EMAIL}"`
70
+ f.puts Time.now.strftime("%Y-%m-%d #{FULL_EMAIL}")
72
71
  f.puts
73
72
  cl_add.each do |file, str|
74
73
  f.puts "\t* #{file}: #{str}."
@@ -79,29 +78,40 @@ class Vcs
79
78
  raise MustBeFilled, cl
80
79
  end
81
80
 
82
- def changelog! ( *args )
81
+ def concat_changelog! ( *args )
82
+ error_handling :changelog_failed
83
+
83
84
  unless CL.exist?
84
- raise Failure, 'No ChangeLog, you are probably not in a valid directory.'
85
+ raise Failure, "No `#{CL}', you are probably not in a valid directory."
85
86
  end
86
87
 
87
88
  if cl = mkchangelog(*args)
88
89
 
89
90
  unless TMP_CL.exist?
90
- LOG.warn "Moving #{CL} to `#{TMP_CL}'"
91
+ LOG.info "Moving `#{CL}' to `#{TMP_CL}' ..."
91
92
  CL.rename(TMP_CL)
92
93
  end
93
94
 
94
95
  CL.open('w') do |file|
95
- cl.each { |line| file.print line }
96
+ LOG.info "Prepending `#{ADD_CL}' to `#{CL}' ..."
97
+ file.print cl.read
96
98
  file.puts
97
- IO.foreach(TMP_CL) { |line| file.print line }
99
+ file.print TMP_CL.read
98
100
  end
99
101
 
100
102
  end
101
103
  end
102
104
 
105
+ def changelog_failed
106
+ if TMP_CL.exist?
107
+ LOG.info "Restoring `#{CL}' from `#{TMP_CL}' ..."
108
+ TMP_CL.rename(CL)
109
+ end
110
+ LOG.info "#{ADD_CL}: Contains your ChangeLog entry" if ADD_CL.exist?
111
+ end
112
+
103
113
  alias_command :mkcl, :mkchangelog
104
- alias_command :cl, :changelog
114
+ alias_command :ctcl, :concat_changelog
105
115
 
106
116
  end # class Vcs
107
117
 
@@ -0,0 +1,20 @@
1
+ class Vcs
2
+
3
+ def mk_conflicts_list
4
+ status.grep(/^C/).each { |s| s.sub!(/^C\s+(.*)\n/, '\1') }
5
+ end
6
+
7
+ def edit_conflicts
8
+ system("#{EDITOR} #{mk_conflicts_list}")
9
+ end
10
+
11
+ def resolve_conflicts
12
+ conflicts = mk_conflicts_list
13
+ question = "Resolve these conflicts: \n - #{conflicts.join("\n - ")}\n"
14
+ if ask(question, :n) == :y
15
+ return resolved(conflicts)
16
+ end
17
+ []
18
+ end
19
+
20
+ end # class Vcs
@@ -0,0 +1,18 @@
1
+ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
2
+ # Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
3
+ # License:: GNU General Public License (GPL).
4
+ # Revision:: $Id$
5
+
6
+ class Svn
7
+
8
+ def diffw_from_status ( *args )
9
+ files = Set.new
10
+ from_status(*args) do |line, file_st, prop_st, cpy, file|
11
+ next if file_st =~ /[?X]/
12
+ next if file == 'ChangeLog'
13
+ files << Pathname.new(file)
14
+ end
15
+ diffw(*files.delete_if { |f| f.directory? })
16
+ end
17
+
18
+ end # class Svn
@@ -12,9 +12,7 @@ class Vcs
12
12
  # Use the diffstat command to
13
13
  # display statitics on your patch.
14
14
  def diffstat ( *a )
15
- unless `diffstat -V` =~ /diffstat version/
16
- raise ArgumentError, 'The `diffstat\' tool is needed by Vcs.diffstat'
17
- end
15
+ check_diffstat
18
16
  patch = diff(*a)
19
17
  rd, wr = IO.pipe
20
18
  pid = fork do
@@ -32,5 +30,13 @@ class Vcs
32
30
  end
33
31
  alias_command :ds, :diffstat
34
32
 
33
+ def check_diffstat
34
+ unless `diffstat -V` =~ /diffstat version/
35
+ raise ArgumentError, 'The `diffstat\' tool is needed by Vcs.diffstat'
36
+ end
37
+ end
38
+
39
+ add_conf_checker :check_diffstat
40
+
35
41
  end # class Vcs
36
42
 
@@ -0,0 +1,18 @@
1
+ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
2
+ # Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
3
+ # License:: GNU General Public License (GPL).
4
+ # $Id$
5
+
6
+ require 'svn'
7
+ require 'stringio'
8
+
9
+ class Svn
10
+
11
+ def last_changed_date ( *args )
12
+ re = /^Last Changed Date:.*?\(([^)]*)\).*$/
13
+ StringIO.new(info.readlines.grep(/^Last Changed Date:/).first.sub(re, '\1'))
14
+ end
15
+
16
+ alias_command :date, :last_changed_date
17
+
18
+ end # class Svn
@@ -1,83 +1,51 @@
1
- # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
1
+ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
2
2
  # Copyright:: Copyright (c) 2004 LRDE. All rights reserved.
3
- # License:: GNU General Public License (GPL).
4
-
5
- # $LastChangedBy: ertai $
6
- # $Id: header 98 2004-09-29 12:07:43Z ertai $
3
+ # License:: GNU General Public License (GPL).
4
+ # Revision:: $Id: header 98 2004-09-29 12:07:43Z ertai $
7
5
 
8
6
  require 'vcs'
9
- require 'tools'
7
+ require 'sendmail'
10
8
 
11
9
  class Vcs
12
10
 
13
- MAIL = Pathname.new(',mail')
14
-
15
- def parse_mail_options ( *args )
16
- require 'optparse'
17
- result =
18
- {
19
- :from => FULL_EMAIL,
20
- :to => [],
21
- :server => ENV['SMTPSERVER'] || 'localhost',
22
- }
23
- if !args.nil? and !args.empty? and args[0].is_a?(Hash)
24
- args[0].each do |k,v|
25
- result[k] = v
26
- end
27
- return result
28
- end
29
- OptionParser.new do |opts|
30
- opts.separator ''
31
- opts.on('-t', '--mail-to NAME', 'Choose a recipient') do |aString|
32
- result[:to] << aString
33
- end
34
- opts.on('-s', '--server NAME', 'Choose a mail server') do |aString|
35
- result[:server] = aString
36
- end
37
- opts.on('-S', '--subject NAME', 'Choose your mail subject') do |aString|
38
- result[:subject] = aString.sub(/\.?$/, '.')
39
- end
40
- opts.on_tail('-h', '--help', 'Show this message') do
41
- puts opts
42
- exit
43
- end
44
- end.parse!(args)
45
- raise Failure, 'No recipents' if result[:to].empty?
46
- raise Failure, 'No mail server' if result[:server].nil?
47
- raise Failure, 'No mail subject' if result[:subject].nil?
48
- result
49
- end
50
- protected :parse_mail_options
11
+ MAIL = Sendmail::MAIL_FILE
12
+ MAILER = Sendmail.new
13
+ DEFAULT_OPTIONS = %w[ --ask --sign --mime ]
51
14
 
52
15
  #
53
16
  # Mail.
54
17
  #
55
18
  def mail ( *args )
19
+ error_handling :mail_failed
20
+ unless MAIL.exist?
21
+ print_body(MAIL, MAILER.parse_mail_options(*(DEFAULT_OPTIONS + args)))
22
+ end
23
+ MAILER.sendmail
24
+ MAIL.delete
25
+ StringIO.new('Mail: Sent.')
26
+ end
56
27
 
57
- print_body(MAIL, parse_mail_options(*args)) unless MAIL.exist?
28
+ def mail_failed
29
+ if defined? MAIL and MAIL.exist?
30
+ LOG.info "#{MAIL}: Contains the generated mail " +
31
+ "(generated from #{@@message})"
32
+ end
33
+ end
58
34
 
59
- MAIL.open('r') do |file|
60
- opt = YAML::chop_header(file)
61
- STDERR.puts "Smtp Server: #{opt[:server]}"
62
- if ask("Send a mail, with this subject: #{opt[:subject]}\n" +
63
- " to #{opt[:to].join(', ')}\n from #{opt[:from]}\n" +
64
- 'Are you sure?', :y) == :n
65
- LOG.error 'Aborting'
66
- exit
67
- end
68
- require 'net/smtp'
69
- Net::SMTP.start(opt[:server], 25) do |smtp|
70
- smtp.open_message_stream(EMAIL, opt[:to]) do |f|
71
- f.print "From: #{opt[:from]}\n"
72
- f.print "Subject: #{opt[:subject]}\n"
73
- f.print "To: #{opt[:to].join(', ')}\n"
74
- f.print "\n"
75
- file.each { |line| f.print line }
76
- end
35
+ def mail_conf_checker
36
+ %w[ EMAIL FULLNAME SMTPSERVER ].each do |var|
37
+ if ENV[var].nil? or ENV[var].empty?
38
+ LOG.error "environment variable `#{var}' not set"
77
39
  end
78
40
  end
79
- MAIL.delete
80
- StringIO.new('Mail: Sent.')
41
+ unless `gpg --version` =~ /^gpg \(GnuPG\)/
42
+ LOG.error 'command not found: gpg'
43
+ end
44
+ unless File.exist?("#{ENV['HOME']}/.gnupg/secring.gpg")
45
+ LOG.error 'no private key: in your ~/.gnupg'
46
+ end
81
47
  end
82
48
 
49
+ add_conf_checker :mail_conf_checker
50
+
83
51
  end # class Vcs
@@ -30,24 +30,23 @@ class Vcs
30
30
  f.puts options.to_yaml
31
31
  f.puts '---'
32
32
  f.puts
33
- message.each do |line|
34
- f.print line
35
- end
33
+ f.print message.read
36
34
  end
37
35
  end
38
36
  private :print_body
39
37
 
40
38
  def message ( *args )
39
+ error_handling :message_failed
40
+
41
41
  unless @@message.exist?
42
42
  cl = mkchangelog(*args)
43
43
  @@message.open('w') do |f|
44
- f.puts 'Index: ChangeLog'
45
- cl.each { |line| f.print line.sub(/^\d+-\d+-\d+/, 'from') }
46
- f.puts
47
- # FIXME: need to remove the ChangeLog entry in diff.
48
- diffstat(*args).each { |line| f.print line }
44
+ f.puts 'Index: ChangeLog'
45
+ f.print cl.read.sub(/^\d+-\d+-\d+/, 'from')
46
+ f.puts
47
+ f.print diffstat(*args).read
49
48
  f.puts
50
- diff(*args).each { |line| f.print line unless line =~ /^=+$/ }
49
+ diffw_from_status(*args).each { |line| f.print line if line !~ /^=+$/ }
51
50
  end
52
51
  end
53
52
  @@message.open('r')
@@ -55,4 +54,11 @@ class Vcs
55
54
 
56
55
  alias_command :msg, :message
57
56
 
57
+ def message_failed
58
+ if @@message.exist?
59
+ LOG.info "#{@@message}: Contains the generated message"
60
+ LOG.info ' (the ChangeLog entry, the diffstat, the diff)'
61
+ end
62
+ end
63
+
58
64
  end # class Vcs
@@ -10,8 +10,10 @@ require 'ask'
10
10
 
11
11
  class Vcs
12
12
 
13
+ COMMITED = Pathname.new(',commited')
14
+
13
15
  def edit! ( *files )
14
- system(ENV['EDITOR'], *files.map { |x| x.to_s })
16
+ system(EDITOR, *files.map { |x| x.to_s })
15
17
  end
16
18
 
17
19
  def common_commit! ( *args, &block )
@@ -20,7 +22,7 @@ class Vcs
20
22
 
21
23
  update!
22
24
 
23
- unless @@message.exist?
25
+ unless COMMITED.exist?
24
26
 
25
27
  begin
26
28
  mkchangelog(*args)
@@ -32,44 +34,57 @@ class Vcs
32
34
 
33
35
  edit! @@message
34
36
 
35
- changelog!(*args)
37
+ if ask('Committing, are you sure?', :y) == :n
38
+ commit_failed
39
+ end
40
+
41
+ concat_changelog!(*args)
36
42
 
37
43
  #pager! diff
38
44
  #pager! status
39
45
 
40
46
  args << 'ChangeLog' unless args.grep(/^[^-]/).empty?
41
47
 
42
- if ask('Committing, are you sure?', :y) == :n
43
- @@message.unlink
44
- LOG.error 'Aborting'
45
- exit
46
- end
47
-
48
48
  if commit!('-F', ADD_CL, *(opts + args))
49
- LOG.info 'Deleting junk files...'
50
- ADD_CL.delete
49
+ ADD_CL.rename(COMMITED)
51
50
  TMP_CL.delete if TMP_CL.exist?
52
51
  else
53
- @@message.unlink
54
- raise Failure, 'commit failed'
52
+ commit_failed
55
53
  end
56
54
 
57
55
  update!
58
56
 
57
+ else
58
+
59
+ message(*args)
60
+ edit! @@message
61
+
59
62
  end
60
63
 
64
+
61
65
  rev = self.revision.readline.chomp.to_i
62
66
 
63
67
  block.call(rev) if block_given?
64
68
 
69
+ LOG.info 'Deleting junk files...'
70
+ TMP_CL.delete if TMP_CL.exist?
71
+ ADD_CL.delete if ADD_CL.exist?
72
+ COMMITED.delete if COMMITED.exist?
65
73
  messages = Pathname.new(',messages')
66
74
  messages.mkpath unless messages.directory?
67
75
  message_rev = messages + "#{@@message}.#{rev}"
68
76
  LOG.info "Moving `#{@@message}' to `#{message_rev}'..."
69
77
  @@message.rename(message_rev)
70
- LOG.info "Remove `#{message_rev}' if everything is ok."
78
+ LOG.info "You can remove `#{message_rev}' if everything is ok."
71
79
 
72
80
  end
73
81
  alias_command :cci, :common_commit
74
82
 
83
+ def commit_failed
84
+ LOG.info "#{COMMITED}: Contains your ChangeLog entry" if COMMITED.exist?
85
+ LOG.error 'Aborting'
86
+ LOG.info 'You can rerun the same command to continue the commit'
87
+ raise 'Commit failed'
88
+ end
89
+
75
90
  end # class Vcs