rscm 0.4.5 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. data/CHANGES +12 -0
  2. data/README +14 -0
  3. data/Rakefile +4 -24
  4. data/lib/rscm.rb +1 -2
  5. data/lib/rscm/base.rb +289 -281
  6. data/lib/rscm/command_line.rb +135 -112
  7. data/lib/rscm/revision.rb +63 -166
  8. data/lib/rscm/revision_file.rb +8 -2
  9. data/lib/rscm/revision_poller.rb +78 -67
  10. data/lib/rscm/revisions.rb +79 -0
  11. data/lib/rscm/scm/clearcase.rb +11 -9
  12. data/lib/rscm/scm/cvs.rb +374 -352
  13. data/lib/rscm/scm/cvs_log_parser.rb +1 -0
  14. data/lib/rscm/scm/darcs.rb +9 -0
  15. data/lib/rscm/scm/perforce.rb +216 -149
  16. data/lib/rscm/scm/subversion.rb +44 -24
  17. data/lib/rscm/scm/subversion_log_parser.rb +37 -51
  18. data/lib/rscm/time_ext.rb +0 -1
  19. data/lib/rscm/version.rb +2 -2
  20. data/test/rscm/command_line_test.rb +7 -5
  21. data/test/rscm/compatibility/config.yml +4 -4
  22. data/test/rscm/compatibility/cvs_metaproject/diff.txt +52 -0
  23. data/test/rscm/compatibility/cvs_metaproject/file.txt +48 -0
  24. data/test/rscm/compatibility/cvs_metaproject/old.yml +13 -0
  25. data/test/rscm/compatibility/full.rb +2 -223
  26. data/test/rscm/compatibility/p4_gfx/files_0.yml +10 -0
  27. data/test/rscm/compatibility/p4_gfx/old.yml +26 -0
  28. data/test/rscm/compatibility/p4_gfx/revisions.yml +24 -0
  29. data/test/rscm/compatibility/p4_gfx/scm.yml +4 -0
  30. data/test/rscm/compatibility/rscm_engine.rb +197 -0
  31. data/test/rscm/compatibility/subversion_rscm/diff.txt +12 -0
  32. data/test/rscm/compatibility/subversion_rscm/file.txt +567 -0
  33. data/test/rscm/compatibility/subversion_rscm/old.yml +14 -0
  34. data/test/rscm/compatibility/subversion_rscm/revisions.yml +17 -0
  35. data/test/rscm/compatibility/subversion_rscm/scm.yml +1 -0
  36. data/test/rscm/revision_file_test.rb +10 -0
  37. data/test/rscm/revision_poller_test.rb +91 -0
  38. data/test/rscm/revision_test.rb +22 -117
  39. data/test/rscm/revisions_test.rb +80 -0
  40. data/test/rscm/scm/cvs_log_parser_test.rb +569 -567
  41. data/test/rscm/scm/cvs_test.rb +6 -3
  42. data/test/rscm/scm/darcs_test.rb +4 -7
  43. data/test/rscm/scm/perforce_test.rb +6 -2
  44. data/test/rscm/scm/star_team_test.rb +10 -0
  45. data/test/rscm/scm/subversion_log_parser_test.rb +38 -5
  46. data/test/rscm/scm/subversion_test.rb +2 -3
  47. data/test/rscm/test_helper.rb +41 -2
  48. data/testproject/damagecontrolled/build.xml +154 -154
  49. data/testproject/damagecontrolled/src/java/com/thoughtworks/damagecontrolled/Thingy.java +6 -6
  50. metadata +19 -7
  51. data/lib/rscm/historic_file.rb +0 -30
  52. data/test/rscm/compatibility/damage_control_minimal.rb +0 -104
  53. data/test/rscm/revision_fixture.rb +0 -20
  54. data/test/rscm/revisions.yaml +0 -42
  55. data/test/rscm/scm/star_team.rb +0 -36
@@ -0,0 +1,10 @@
1
+ ---
2
+ - Metrix_Errors.yml
3
+ - Metrix_SingletonDeclaration.yml
4
+ - Metrix_SingletonUsage.yml
5
+ - Suspicious_Builds.yml
6
+ - cross.png
7
+ - errors_html.xsl
8
+ - suspicious_build_files.rb
9
+ - suspicious_html.xsl
10
+ - tick.png
@@ -0,0 +1,26 @@
1
+ ---
2
+ start: 2006-03-16 18:40:48 Z
3
+ identifiers:
4
+ - 25786
5
+ - 25905
6
+ - 25947
7
+ - 26080
8
+ - 26109
9
+ - 26117
10
+ - 26199
11
+ - 26269
12
+ - 26362
13
+ - 26373
14
+ - 26378
15
+ - 26402
16
+ - 26405
17
+ - 26420
18
+ - 26425
19
+ - 26524
20
+ - 26537
21
+ - 26554
22
+ - 26561
23
+ - 26568
24
+ - 26570
25
+ - 26964
26
+ - 27034
@@ -0,0 +1,24 @@
1
+ --- !ruby/object:RSCM::Revisions
2
+ revisions:
3
+ - !ruby/object:RSCM::Revision
4
+ developer: Aslak.Hellesoy
5
+ files:
6
+ - !ruby/object:RSCM::RevisionFile
7
+ native_revision_identifier: 5
8
+ path: suspicious_html.xsl
9
+ previous_native_revision_identifier: 4
10
+ status: MODIFIED
11
+ identifier: 26109
12
+ message: "\twords"
13
+ time: 2006-03-08 22:10:11 Z
14
+ - !ruby/object:RSCM::Revision
15
+ developer: Aslak.Hellesoy
16
+ files:
17
+ - !ruby/object:RSCM::RevisionFile
18
+ native_revision_identifier: 1
19
+ path: rules/README.txt
20
+ previous_native_revision_identifier: 0
21
+ status: ADDED
22
+ identifier: 26117
23
+ message: "\tPlaceholder for rules"
24
+ time: 2006-03-08 23:22:51 Z
@@ -0,0 +1,4 @@
1
+ --- !ruby/object:RSCM::Perforce
2
+ view: //depot/trunk/metrics/...
3
+ username: Aslak.Hellesoy
4
+ password: web40bof
@@ -0,0 +1,197 @@
1
+ module RSCM
2
+ module Compatibility
3
+ # These tests verify that an RSCM adapter implementation will work with RscmEngine
4
+ module RscmEngine
5
+ include Difftool
6
+
7
+ def setup
8
+ config_yml = File.dirname(__FILE__) + '/config.yml'
9
+ config = YAML::load_file(config_yml)
10
+ raise "#{config_yml} must have an entry for #{self.class.name}" if config[self.class.name].nil?
11
+ @testdata_dir = File.dirname(__FILE__) + '/' + config[self.class.name]
12
+ raise "#{@testdata_dir} directory doesn't exist" unless File.directory?(@testdata_dir)
13
+ @scm = YAML::load_file(@testdata_dir + '/scm.yml')
14
+ @scm.store_revisions_command = false
15
+ end
16
+
17
+ def teardown
18
+ begin
19
+ # @scm.destroy_working_copy
20
+ rescue => e
21
+ STDERR.puts "WARN: #{e.message}"
22
+ end
23
+ end
24
+
25
+ def test_should_get_revisions_by_revision_identifier
26
+ suffix = "#{@scm.class.name}_#{method_name}".gsub(/:/, '_')
27
+ do_verify_revisions_by_property(suffix, :identifier)
28
+ end
29
+
30
+ def test_should_get_revisions_by_time
31
+ # Subversion 1.3.0 currently has an unresolved bug:
32
+ # http://subversion.tigris.org/issues/show_bug.cgi?id=1642
33
+ #
34
+ # svn log http://buildpatterns.com/svn/repos/rscm/trunk/test/ --revision {"2006-03-03 11:55:55"}:{"2006-03-03 18:24:08"}
35
+ #
36
+ # returns revisions outside the lower bounds.
37
+ # we therefore exclude this test when running svn tests - it's not that important since rscm_engine only uses timestamps
38
+ # on the[0] run for a project, and it's not important that it is accurate.
39
+ unless self.class.name == 'RSCM::SubversionTest'
40
+ suffix = "#{@scm.class.name}_#{method_name}".gsub(/:/, '_')
41
+ do_verify_revisions_by_property(suffix, :time)
42
+ end
43
+ end
44
+
45
+ def do_verify_revisions_by_property(suffix, something)
46
+ dir = File.expand_path(RSCM.new_temp_dir(suffix))
47
+ options = {:stdout => "#{dir}/stdout.log", :stderr => "#{dir}/stderr.log"}.freeze
48
+ @scm.checkout_dir = "#{dir}/checkout"
49
+
50
+ expected_yaml = @testdata_dir + '/revisions.yml'
51
+ expected = YAML::load_file(expected_yaml)
52
+
53
+ # This should result in the same revisions [0]-1.[-1]+1)
54
+ from = expected[0].__send__(something)-1
55
+ to = expected[-1].__send__(something)+1
56
+ opts = options.dup.merge :to_identifier => to
57
+ actual = @scm.revisions(from, opts)
58
+ actual.sort!
59
+
60
+ if(expected != actual)
61
+ assert_equal_with_diff(expected_yaml, actual.to_yaml, "See logs in #{dir}")
62
+ end
63
+
64
+ # This should NOT result in the same revisions [0].[-1]+1)
65
+ from = expected[0].__send__(something)
66
+ to = expected[-1].__send__(something)+1
67
+ opts = options.dup.merge :to_identifier => to
68
+ actual = @scm.revisions(from, opts)
69
+ assert_not_equal(expected, actual)
70
+
71
+ # This should NOT result in the same revisions [0]+1.[-1])
72
+ from = expected[0].__send__(something)-1
73
+ to = expected[-1].__send__(something)
74
+ opts = options.dup.merge :to_identifier => to
75
+ actual = @scm.revisions(from, opts)
76
+ assert_not_equal(expected, actual)
77
+
78
+ end
79
+
80
+ def test_should_checkout_sources_to_particular_revision
81
+ dirname = "#{@scm.class.name}_#{method_name}".gsub(/:/, '_')
82
+ dir = File.expand_path(RSCM.new_temp_dir(dirname))
83
+ options = {:stdout => "#{dir}/stdout.log", :stderr => "#{dir}/stderr.log"}.freeze
84
+ revisions_yml = @testdata_dir + '/revisions.yml'
85
+ revisions = YAML::load_file(revisions_yml)
86
+ @scm.checkout_dir = RSCM.new_temp_dir("#{dirname}_0")
87
+ files_0 = @scm.checkout(revisions[0].identifier, options)
88
+ expected_yaml = @testdata_dir + "/files_0.yml"
89
+ expected = YAML::load_file(expected_yaml)
90
+ if(expected != files_0)
91
+ assert_equal_with_diff(expected_yaml, files_0.to_yaml)
92
+ end
93
+
94
+ # We can predict what the next checked out files should be
95
+ expected_files = files_0.dup
96
+ revisions[1].each do |file|
97
+ expected_files.delete(file.path) if file.status == "DELETED"
98
+ expected_files.push(file.path) if file.status == "ADDED"
99
+ end
100
+ expected_files.sort!
101
+ if(files_0 == expected_files)
102
+ flunk "The 2nd revision in #{revisions_yml} must have at least one added or deleted file"
103
+ end
104
+
105
+ @scm.checkout_dir = RSCM.new_temp_dir("#{dirname}_1")
106
+ files_1 = @scm.checkout(revisions[1].identifier, options)
107
+ assert_equal(expected_files, files_1)
108
+
109
+ # Now check out to the 1st revision again and verify files were removed
110
+ added_paths = revisions[1].find_all{|rf| rf.status=="ADDED"}.collect{|rf| rf.path}
111
+ assert added_paths.size > 0
112
+ added_paths.each do |p|
113
+ full_path = @scm.checkout_dir + '/' + p
114
+ assert File.exist?(full_path), "Should exist: #{full_path}"
115
+ end
116
+ @scm.checkout(revisions[0].identifier, options)
117
+ added_paths.each do |p|
118
+ full_path = @scm.checkout_dir + '/' + p
119
+ assert !File.exist?(full_path), "Should no longer exist: #{full_path}"
120
+ end
121
+ end
122
+
123
+ def test_should_poll_old_revisions
124
+ dirname = "#{@scm.class.name}_#{method_name}".gsub(/:/, '_')
125
+ dir = File.expand_path(RSCM.new_temp_dir(dirname))
126
+ options = {:stdout => "#{dir}/stdout.log", :stderr => "#{dir}/stderr.log"}.freeze
127
+ @scm.checkout_dir = "#{dir}/checkout"
128
+
129
+ old = YAML::load_file(@testdata_dir + '/old.yml')
130
+
131
+ identifiers = []
132
+
133
+ start = old['start']
134
+ @scm.poll(start) do |revisions|
135
+ identifiers << revisions.collect{|revision| revision.identifier}
136
+ end
137
+ identifiers.reverse!
138
+ identifiers.flatten!
139
+
140
+ expected_identifiers = old['identifiers']
141
+
142
+ assert_equal(expected_identifiers, identifiers, "Expected identifiers from epoch to #{start} didn't match")
143
+ end
144
+
145
+ def test_should_find_diff
146
+ dirname = "#{@scm.class.name}_#{method_name}".gsub(/:/, '_')
147
+ dir = File.expand_path(RSCM.new_temp_dir(dirname))
148
+ options = {:stdout => "#{dir}/stdout.log", :stderr => "#{dir}/stderr.log"}.freeze
149
+ @scm.checkout_dir = "#{dir}/checkout"
150
+
151
+ expected_yaml = @testdata_dir + '/revisions.yml'
152
+ expected = YAML::load_file(expected_yaml)
153
+
154
+ from = expected[0].identifier - 1
155
+ to = expected[-1].identifier + 1
156
+ opts = options.dup.merge :to_identifier => to
157
+ revisions = @scm.revisions(from, opts)
158
+ revisions.sort!
159
+
160
+ # find the first modified file in the 0th revision
161
+ modified_file = revisions[0].detect{|revision_file| revision_file.status == "MODIFIED"}
162
+
163
+ # now run diff command
164
+ diff = modified_file.diff(@scm, options) do |io|
165
+ io.read
166
+ end
167
+ assert_equal_with_diff(@testdata_dir + "/diff.txt", diff)
168
+ end
169
+
170
+ def test_should_open_file
171
+ dirname = "#{@scm.class.name}_#{method_name}".gsub(/:/, '_')
172
+ dir = File.expand_path(RSCM.new_temp_dir(dirname))
173
+ options = {:stdout => "#{dir}/stdout.log", :stderr => "#{dir}/stderr.log"}.freeze
174
+ @scm.checkout_dir = "#{dir}/checkout"
175
+
176
+ expected_yaml = @testdata_dir + '/revisions.yml'
177
+ expected = YAML::load_file(expected_yaml)
178
+
179
+ from = expected[0].identifier - 1
180
+ to = expected[-1].identifier + 1
181
+ opts = options.dup.merge :to_identifier => to
182
+ revisions = @scm.revisions(from, opts)
183
+ revisions.sort!
184
+
185
+ # find the first modified file in the 0th revision
186
+ modified_file = revisions[0].detect{|revision_file| revision_file.status == "MODIFIED"}
187
+
188
+ # now run diff command
189
+ file = modified_file.open(@scm, options) do |io|
190
+ io.read
191
+ end
192
+ assert_equal_with_diff(@testdata_dir + "/file.txt", file)
193
+ end
194
+
195
+ end
196
+ end
197
+ end
@@ -0,0 +1,12 @@
1
+ Index: cvs_log_parser_test.rb
2
+ ===================================================================
3
+ --- cvs_log_parser_test.rb (revision 155)
4
+ +++ cvs_log_parser_test.rb (revision 156)
5
+ @@ -201,6 +201,7 @@
6
+ expected_change.developer = "tirsen"
7
+ expected_change.message = "fixed some stuff in the log parser"
8
+ expected_change.native_revision_identifier = "1.19"
9
+ + expected_change.status = "MODIFIED"
10
+ expected_change.time = Time.utc(2004, 7, 5, 9, 41, 51)
11
+
12
+ assert_equal(expected_change, revisions[9][0])
@@ -0,0 +1,567 @@
1
+ require 'test/unit'
2
+ require 'stringio'
3
+ require 'fileutils'
4
+ require 'rscm'
5
+
6
+ module RSCM
7
+ class CvsLogParserTest < Test::Unit::TestCase
8
+
9
+ include FileUtils
10
+
11
+ def setup
12
+ @parser = CvsLogParser.new(nil)
13
+ @parser.cvspath = "/scm/damagecontrol"
14
+ @parser.cvsmodule = "damagecontrol"
15
+ end
16
+
17
+ def test_read_log_entry
18
+ assert_equal(nil, CvsLogParser.new(StringIO.new("")).next_log_entry)
19
+ end
20
+
21
+ def test_parses_entire_log_into_revisions
22
+ File.open(File.dirname(__FILE__) + "/cvs-test.log") do |io|
23
+ @parser = CvsLogParser.new(io)
24
+ revisions = @parser.parse_revisions
25
+
26
+ assert_equal(24, revisions.length)
27
+ assert_match(/o YAML config \(BuildBootstrapper\)/, revisions[1].message)
28
+ assert_match(/failure/, revisions[8].message)
29
+ end
30
+ end
31
+
32
+ # http://jira.codehaus.org/browse/DC-312
33
+ def test_jira_dc_312
34
+ File.open(File.dirname(__FILE__) + "/cvs-dataforge.log") do |io|
35
+ @parser = CvsLogParser.new(io)
36
+ revisions = @parser.parse_revisions
37
+
38
+ assert_equal(271, revisions.length)
39
+ end
40
+ end
41
+
42
+ def test_parse_files
43
+ revisions = Revisions.new
44
+ @parser.parse_files(LOG_ENTRY, revisions)
45
+ revisions.sort!
46
+ assert_equal(4, revisions.length)
47
+ assert_equal("src/ruby/damagecontrol/BuildExecutorTest.rb", revisions[0][0].path)
48
+ assert_match(/linux-windows galore/, revisions[1][0].message)
49
+ end
50
+
51
+ def test_sets_previous_native_revision_identifier_to_one_before_the_current
52
+ change = @parser.parse_file(CHANGE_ENTRY)
53
+ assert_equal("1.20", change.native_revision_identifier)
54
+ assert_equal("1.19", change.previous_native_revision_identifier)
55
+ end
56
+
57
+ def test_can_determine_previous_native_revision_identifiers_from_tricky_input
58
+ assert_equal("2.2.1.1", @parser.determine_previous_native_revision_identifier("2.2.1.2"))
59
+ assert_equal(nil, @parser.determine_previous_native_revision_identifier("2.2.1.1"))
60
+ end
61
+
62
+ def test_parse_file
63
+ change = @parser.parse_file(CHANGE_ENTRY)
64
+ assert_equal("1.20", change.native_revision_identifier)
65
+ assert_equal(Time.utc(2003,11,9,17,53,37), change.time)
66
+ assert_equal("tirsen", change.developer)
67
+ assert_match(/Quiet period is configurable for each project/, change.message)
68
+ end
69
+
70
+ def test_can_split_entries_separated_by_line_of_dashes
71
+ entries = @parser.split_entries(LOG_ENTRY)
72
+ assert_equal(5, entries.length)
73
+ assert_equal(CHANGE_ENTRY, entries[1])
74
+ end
75
+
76
+ CHANGE_ENTRY = <<-EOF
77
+ revision 1.20
78
+ date: 2003/11/09 17:53:37; author: tirsen; state: Exp; lines: +3 -4
79
+ Quiet period is configurable for each project
80
+ EOF
81
+
82
+ LOG_ENTRY_WITH_DELETED_FILE = <<EOF
83
+ RCS file: /scm/damagecontrol/damagecontrol/server/damagecontrol/Attic/codehaus.rb,v
84
+ Working file: server/damagecontrol/codehaus.rb
85
+ head: 1.23
86
+ branch:
87
+ locks: strict
88
+ access list:
89
+ keyword substitution: kv
90
+ total revisions: 23; selected revisions: 1
91
+ description:
92
+ ----------------------------
93
+ revision 1.23
94
+ date: 2004/07/13 07:56:26; author: tirsen; state: dead; lines: +0 -0
95
+ remove username check (doesn't work on beaver)
96
+ I do really want to see the url in irc, it's very, very convenient. thank you very much ;-)
97
+ EOF
98
+
99
+ def test_can_parse_files_with_deleted_file
100
+ revisions = Revisions.new
101
+ @parser.parse_files(LOG_ENTRY_WITH_DELETED_FILE, revisions)
102
+ assert_equal(1, revisions.length)
103
+ assert_equal("server/damagecontrol/codehaus.rb", revisions[0][0].path)
104
+ assert_equal(RevisionFile::DELETED, revisions[0][0].status)
105
+ end
106
+
107
+ def test_log_from_e2e_test
108
+ @parser = CvsLogParser.new(StringIO.new(LOG_FROM_E2E_TEST))
109
+ revisions = @parser.parse_revisions
110
+ assert_equal(2, revisions.length)
111
+ assert_match(/foo/, revisions[1].message)
112
+ assert_match(/bar/, revisions[0].message)
113
+ end
114
+
115
+ LOG_FROM_E2E_TEST = <<-EOF
116
+ =============================================================================
117
+
118
+ RCS file: C:\projects\damagecontrol\target\temp_e2e_1081547757\repository/e2eproject/build.bat,v
119
+ Working file: build.bat
120
+ head: 1.2
121
+ branch:
122
+ locks: strict
123
+ access list:
124
+ symbolic names:
125
+ keyword substitution: kv
126
+ total revisions: 2; selected revisions: 2
127
+ description:
128
+ ----------------------------
129
+ revision 1.2
130
+ date: 2004/04/09 21:56:47; author: jtirsen; state: Exp; lines: +1 -1
131
+ foo
132
+ ----------------------------
133
+ revision 1.1
134
+ date: 2004/04/09 21:56:12; author: jtirsen; state: Exp;
135
+ bar
136
+ =============================================================================EOF
137
+ EOF
138
+
139
+ LOG_ENTRY = <<-EOF
140
+ =============================================================================
141
+
142
+ RCS file: /scm/damagecontrol/damagecontrol/src/ruby/damagecontrol/BuildExecutorTest.rb,v
143
+ Working file: src/ruby/damagecontrol/BuildExecutorTest.rb
144
+ head: 1.20
145
+ branch:
146
+ locks: strict
147
+ access list:
148
+ symbolic names:
149
+ keyword substitution: kv
150
+ total revisions: 20; selected revisions: 4
151
+ description:
152
+ ----------------------------
153
+ revision 1.20
154
+ date: 2003/11/09 17:53:37; author: tirsen; state: Exp; lines: +3 -4
155
+ Quiet period is configurable for each project
156
+ ----------------------------
157
+ revision 1.19
158
+ date: 2003/11/09 17:04:18; author: tirsen; state: Exp; lines: +32 -2
159
+ Quiet period implemented for BuildExecutor, but does not yet handle multiple projects (builds are not queued as before)
160
+ ----------------------------
161
+ revision 1.18
162
+ date: 2003/11/09 15:51:50; author: rinkrank; state: Exp; lines: +1 -2
163
+ linux-windows galore
164
+ ----------------------------
165
+ revision 1.17
166
+ date: 2003/11/09 15:00:06; author: rinkrank; state: Exp; lines: +6 -8
167
+ o YAML config (BuildBootstrapper)
168
+ o EmailPublisher
169
+ =============================================================================
170
+ EOF
171
+
172
+ def test_can_parse_path
173
+ assert_equal("testdata/damagecontrolled/src/java/com/thoughtworks/damagecontrolled/Thingy.java",
174
+ @parser.parse_path(LOG_ENTRY_FROM_05_07_2004_19_42))
175
+ end
176
+
177
+ LOG_ENTRY_FROM_05_07_2004_19_42 = <<-EOF
178
+ RCS file: /scm/damagecontrol/damagecontrol/testdata/damagecontrolled/src/java/com/thoughtworks/damagecontrolled/Thingy.java,v
179
+ Working file: testdata/damagecontrolled/src/java/com/thoughtworks/damagecontrolled/Thingy.java
180
+ head: 1.1
181
+ branch:
182
+ locks: strict
183
+ access list:
184
+ symbolic names:
185
+ BEFORE_CENTRAL_REFACTORING: 1.1
186
+ RELEASE_0_1: 1.1
187
+ keyword substitution: kv
188
+ total revisions: 1; selected revisions: 1
189
+ description:
190
+ EOF
191
+
192
+ def test_can_parse_LOG_FROM_05_07_2004_19_41
193
+ @parser = CvsLogParser.new(StringIO.new(LOG_FROM_05_07_2004_19_41))
194
+ assert_equal(11, @parser.split_entries(LOG_FROM_05_07_2004_19_41).size)
195
+ assert_equal("server/damagecontrol/scm/CVS.rb", @parser.parse_path(@parser.split_entries(LOG_FROM_05_07_2004_19_41)[0]))
196
+ revisions = @parser.parse_revisions
197
+
198
+ assert_equal(10, revisions.length)
199
+ expected_change = RevisionFile.new
200
+ expected_change.path = "server/damagecontrol/scm/CVS.rb"
201
+ expected_change.developer = "tirsen"
202
+ expected_change.message = "fixed some stuff in the log parser"
203
+ expected_change.native_revision_identifier = "1.19"
204
+ expected_change.status = "MODIFIED"
205
+ expected_change.time = Time.utc(2004, 7, 5, 9, 41, 51)
206
+
207
+ assert_equal(expected_change, revisions[9][0])
208
+ end
209
+
210
+ LOG_FROM_05_07_2004_19_41 = <<-EOF
211
+
212
+ RCS file: /scm/damagecontrol/damagecontrol/server/damagecontrol/scm/CVS.rb,v
213
+ Working file: server/damagecontrol/scm/CVS.rb
214
+ head: 1.19
215
+ branch:
216
+ locks: strict
217
+ access list:
218
+ symbolic names:
219
+ BEFORE_CENTRAL_REFACTORING: 1.1
220
+ keyword substitution: kv
221
+ total revisions: 19; selected revisions: 19
222
+ description:
223
+ ----------------------------
224
+ revision 1.19
225
+ date: 2004/07/05 09:41:51; author: tirsen; state: Exp; lines: +1 -1
226
+ fixed some stuff in the log parser
227
+ ----------------------------
228
+ revision 1.18
229
+ date: 2004/07/05 09:38:21; author: tirsen; state: Exp; lines: +7 -6
230
+ fixed some stuff in the log parser
231
+ ----------------------------
232
+ revision 1.17
233
+ date: 2004/07/05 09:09:44; author: tirsen; state: Exp; lines: +2 -0
234
+ oops.... log parser can't actually log apparently, well, it can now...
235
+ ----------------------------
236
+ revision 1.16
237
+ date: 2004/07/05 08:52:39; author: tirsen; state: Exp; lines: +23 -26
238
+ refactorings in the web
239
+ fixed footer with css
240
+ some other cssing around
241
+ fixed cvs output so my irc client actually gives me a proper link I can click on
242
+ ----------------------------
243
+ revision 1.15
244
+ date: 2004/07/04 18:04:38; author: rinkrank; state: Exp; lines: +1 -1
245
+ debug debug
246
+ ----------------------------
247
+ revision 1.14
248
+ date: 2004/07/04 17:44:36; author: rinkrank; state: Exp; lines: +23 -8
249
+ improved error logging
250
+ ----------------------------
251
+ revision 1.13
252
+ date: 2004/07/04 15:59:16; author: rinkrank; state: Exp; lines: +1 -0
253
+ debugging cvs timestamps
254
+ ----------------------------
255
+ revision 1.12
256
+ date: 2004/07/03 19:25:19; author: rinkrank; state: Exp; lines: +20 -3
257
+ support for previous_native_revision_identifier in modifications
258
+ ----------------------------
259
+ revision 1.11
260
+ date: 2004/07/02
261
+ CVS and CC refactorings. Improved parsing of trigger command line and bootstrapping
262
+ ----------------------------
263
+ revision 1.1
264
+ date: 2003/10/04 12:04:14; author: tirsen; state: Exp;
265
+ Cleaned up the end-to-end test, did some more work on the CCLogPoller
266
+ EOF
267
+
268
+ LOG_ENTRY_FROM_06_07_2004_19_25_1 = <<EOF
269
+ RCS file: /home/projects/jmock/scm/jmock/core/src/test/jmock/core/testsupport/MockInvocationMat
270
+ V1_0_1: 1.4
271
+ V1_0_0: 1.4
272
+ V1_0_0_RC1: 1.4
273
+ v1_0_0_RC1: 1.4
274
+ before_removing_features_deprecated_pre_1_0_0: 1.1
275
+ keyword substitution: kv
276
+ total revisions: 4; selected revisions: 0
277
+ description:
278
+
279
+ EOF
280
+
281
+ def test_can_parse_LOG_ENTRY_FROM_06_07_2004_19_25_1
282
+ @parser.cvspath = "/home/projects/jmock/scm/jmock"
283
+ @parser.cvsmodule = "core"
284
+ assert_equal("src/test/jmock/core/testsupport/MockInvocationMat", @parser.parse_path(LOG_ENTRY_FROM_06_07_2004_19_25_1))
285
+ end
286
+
287
+ LOG_ENTRY_FROM_06_07_2004_19_19 = <<EOF
288
+ Working file: lib/xmlrpc/datetime.rb
289
+ head: 1.1
290
+ branch:
291
+ locks: strict
292
+ access list:
293
+ symbolic names:
294
+ BEFORE_CENTRAL_REFACTORING: 1.1
295
+ keyword substitution: kv
296
+ total revisions: 1; selected revisions: 0
297
+ description:
298
+
299
+ EOF
300
+
301
+ def test_can_parse_LOG_ENTRY_FROM_06_07_2004_19_19
302
+ assert_equal("lib/xmlrpc/datetime.rb", @parser.parse_path(LOG_ENTRY_FROM_06_07_2004_19_19))
303
+ end
304
+
305
+ LOG_ENTRY_FROM_06_07_2004_19_25_2 = <<EOF
306
+ RC
307
+ Working file: website/templates/logo.gif
308
+ head: 1.2
309
+ branch:
310
+ locks: strict
311
+ access list:
312
+ symbolic names:
313
+ steves_easymock: 1.2.0.2
314
+ Root_steves_easymock: 1.2
315
+ V1_0_1: 1.2
316
+ V1_0_0: 1.2
317
+ V1_0_0_RC1: 1.2
318
+ before_removing_features_deprecated_pre_1_0_0: 1.2
319
+ pre-hotmock-syntax-change: 1.2
320
+ keyword substitution: b
321
+ total revisions: 2; selected revisions: 0
322
+ description:
323
+
324
+ EOF
325
+
326
+ def test_can_parse_LOG_ENTRY_FROM_06_07_2004_19_25_2
327
+ assert_equal("website/templates/logo.gif", @parser.parse_path(LOG_ENTRY_FROM_06_07_2004_19_25_2))
328
+ end
329
+
330
+ LOG_WITH_DELETIONS= <<EOF
331
+ RCS file: /home/projects/picocontainer/scm/java/Attic/build.xml,v
332
+ Working file: build.xml
333
+ head: 1.11
334
+ branch:
335
+ locks: strict
336
+ access list:
337
+ symbolic names:
338
+ MERGE_CONTAINER_AND_REGISTRY_REFACTORING_BRANCH: 1.10.0.2
339
+ BEFORE_MERGE_CONTAINER_AND_REGISTRY_REFACTORING_TAG: 1.10
340
+ BEFORE_MULTIPLE_CONSTRUCTORS: 1.10
341
+ keyword substitution: kv
342
+ total revisions: 11; selected revisions: 2
343
+ description:
344
+ ----------------------------
345
+ revision 1.11
346
+ date: 2003/10/13 00:04:54 -0500; author: rinkrank; state: dead; lines: +0 -0
347
+ Obsolete
348
+ ----------------------------
349
+ revision 1.10
350
+ date: 2003/07/25 16:32:39; author: rinkrank; state: Exp; lines: +1 -1
351
+ fixed broken url (NANO-8)
352
+ =============================================================================
353
+ EOF
354
+
355
+ def test_can_parse_LOG_WITH_DELETIONS
356
+ @parser = CvsLogParser.new(StringIO.new(LOG_WITH_DELETIONS))
357
+ revisions = @parser.parse_revisions
358
+ assert_equal(2, revisions.length)
359
+
360
+ revision_delete = revisions[1]
361
+ assert_equal(Time.utc(2003,10,13,05,04,54,0), revision_delete.time)
362
+ assert_equal("Obsolete", revision_delete.message)
363
+ assert_equal("rinkrank", revision_delete.developer)
364
+ assert_equal(1, revision_delete.length)
365
+ assert_equal("build.xml", revision_delete[0].path)
366
+ assert_equal("1.11", revision_delete[0].native_revision_identifier)
367
+ assert_equal("1.10", revision_delete[0].previous_native_revision_identifier)
368
+ assert(RevisionFile::DELETED, revision_delete[0].status)
369
+
370
+ revision_fix_url = revisions[0]
371
+ assert_equal(Time.utc(2003,07,25,16,32,39,0), revision_fix_url.time)
372
+ assert_equal("fixed broken url (NANO-8)", revision_fix_url.message)
373
+ assert_equal("rinkrank", revision_fix_url.developer)
374
+ assert_equal(1, revision_fix_url.length)
375
+ assert_equal("build.xml", revision_fix_url[0].path)
376
+ assert_equal("1.10", revision_fix_url[0].native_revision_identifier)
377
+ assert_equal("1.9", revision_fix_url[0].previous_native_revision_identifier)
378
+ assert_equal(RevisionFile::MODIFIED, revision_fix_url[0].status)
379
+ end
380
+
381
+ LOG_WITH_MISSING_ENTRIES = <<EOF
382
+ RCS file: /cvsroot/damagecontrol/damagecontrol/Attic/build.xml,v
383
+ Working file: build.xml
384
+ head: 1.2
385
+ branch:
386
+ locks: strict
387
+ access list:
388
+ symbolic names:
389
+ initial-import: 1.1.1.1
390
+ mgm: 1.1.1
391
+ keyword substitution: kv
392
+ total revisions: 3; selected revisions: 0
393
+ description:
394
+ =============================================================================
395
+
396
+ RCS file: /cvsroot/damagecontrol/damagecontrol/maven.xml,v
397
+ Working file: maven.xml
398
+ head: 1.2
399
+ branch:
400
+ locks: strict
401
+ access list:
402
+ symbolic names:
403
+ keyword substitution: kv
404
+ total revisions: 2; selected revisions: 0
405
+ description:
406
+ =============================================================================
407
+ EOF
408
+
409
+ def test_can_parse_LOG_WITH_MISSING_ENTRIES
410
+ @parser = CvsLogParser.new(StringIO.new(LOG_WITH_MISSING_ENTRIES))
411
+ revisions = @parser.parse_revisions
412
+ assert_equal(0, revisions.length)
413
+ end
414
+
415
+ LOG_WITH_NEW_AND_OLD_FILE = <<EOF
416
+ RCS file: /home/projects/damagecontrol/scm/damagecontrol/dummy.txt,v
417
+ Working file: dummy.txt
418
+ head: 1.1
419
+ branch:
420
+ locks: strict
421
+ access list:
422
+ keyword substitution: kv
423
+ total revisions: 1; selected revisions: 1
424
+ description:
425
+ ----------------------------
426
+ revision 1.1
427
+ date: 2004/07/13 21:50:59; author: rinkrank; state: Exp;
428
+ Debug. Need to see what the log looks like for a new file.
429
+ =============================================================================
430
+
431
+ RCS file: /home/projects/damagecontrol/scm/damagecontrol/license.txt,v
432
+ Working file: license.txt
433
+ head: 1.4
434
+ branch:
435
+ locks: strict
436
+ access list:
437
+ keyword substitution: kv
438
+ total revisions: 4; selected revisions: 4
439
+ description:
440
+ ----------------------------
441
+ revision 1.101
442
+ date: 2004/07/10 17:41:14; author: rinkrank; state: Exp; lines: +2 -2
443
+ typo
444
+ ----------------------------
445
+ revision 1.11
446
+ date: 2004/07/10 17:38:22; author: rinkrank; state: Exp; lines: +2 -2
447
+ fixed http://jira.codehaus.org/browse/DC-123
448
+ ----------------------------
449
+ revision 1.1
450
+ date: 2004/07/02 08:42:51; author: tirsen; state: Exp;
451
+ installer!!!!!! it's getting close to release!!!
452
+ =============================================================================
453
+ EOF
454
+
455
+ def test_can_distinguish_new_file_from_old_file
456
+ @parser = CvsLogParser.new(StringIO.new(LOG_WITH_NEW_AND_OLD_FILE))
457
+ revisions = @parser.parse_revisions
458
+
459
+ assert_equal(RevisionFile::ADDED, revisions[0][0].status)
460
+ assert_equal(RevisionFile::MODIFIED, revisions[1][0].status)
461
+ assert_equal(RevisionFile::MODIFIED, revisions[2][0].status)
462
+ assert_equal(RevisionFile::ADDED, revisions[3][0].status)
463
+ end
464
+
465
+ # https://sitemesh.dev.java.net/source/browse/sitemesh/.cvsignore
466
+ # The default commit message probably showed up in vi, and the committer
467
+ # probably just left it there. Not sure why CVS kept it this way
468
+ # (lines starting with CVS: should be ignored in commit message afaik).
469
+ # Anyway, the parser now knows how to deal with this. (AH)
470
+ LOG_WITH_WEIRD_CVS_AND_MANY_DASHES = <<EOF
471
+ ? log.txt
472
+
473
+ RCS file: /cvs/sitemesh/.cvsignore,v
474
+ Working file: .cvsignore
475
+ head: 1.3
476
+ branch:
477
+ locks: strict
478
+ access list:
479
+ keyword substitution: kv
480
+ total revisions: 3; selected revisions: 3
481
+ description:
482
+ ----------------------------
483
+ revision 1.3
484
+ date: 2004/05/03 09:03:56; author: rhallier; state: Exp; lines: +2 -0
485
+ Issue number: SIM-90
486
+
487
+ Obtained from: JIRA
488
+
489
+ Submitted by: rhallier
490
+
491
+ Reviewed by:
492
+
493
+ CVS: ----------------------------------------------------------------------
494
+
495
+ CVS: Issue number:
496
+
497
+ CVS: If this change addresses one or more issues,
498
+
499
+ CVS: then enter the issue number(s) here.
500
+
501
+ CVS: Obtained from:
502
+
503
+ CVS: If this change has been taken from another system,
504
+
505
+ CVS: then name the system in this line, otherwise delete it.
506
+
507
+ CVS: Submitted by:
508
+
509
+ CVS: If this code has been contributed to the project by someone else; i.e.,
510
+
511
+ CVS: they sent us a patch or a set of diffs, then include their name/email
512
+
513
+ CVS: address here. If this is your work then delete this line.
514
+
515
+ CVS: Reviewed by:
516
+
517
+ CVS: If we are doing pre-commit code reviews and someone else has
518
+
519
+ CVS: reviewed your changes, include their name(s) here.
520
+
521
+ CVS: If you have not had it reviewed then delete this line.
522
+ ----------------------------
523
+ revision 1.2
524
+ date: 2003/11/22 07:56:51; author: hani; state: Exp; lines: +2 -1
525
+ Ignore IDEA files
526
+ ----------------------------
527
+ revision 1.1
528
+ date: 2003/11/03 16:27:37; author: mbogaert; state: Exp;
529
+ Moved from SF.
530
+ =============================================================================
531
+
532
+ RCS file: /cvs/sitemesh/CHANGES.txt,v
533
+ Working file: CHANGES.txt
534
+ head: 1.3
535
+ branch:
536
+ locks: strict
537
+ access list:
538
+ keyword substitution: kv
539
+ total revisions: 3; selected revisions: 3
540
+ description:
541
+ ----------------------------
542
+ revision 1.3
543
+ date: 2004/10/08 07:18:38; author: hani; state: Exp; lines: +18 -0
544
+ More files not updated for release
545
+ ----------------------------
546
+ revision 1.2
547
+ date: 2004/09/24 14:04:12; author: jwalnes1; state: Exp; lines: +19 -0
548
+ Preparing for 2.2 release.
549
+ Issue number:
550
+ Obtained from:
551
+ Submitted by:
552
+ Reviewed by:
553
+ ----------------------------
554
+ revision 1.1
555
+ date: 2004/07/22 01:30:27; author: farkas; state: Exp;
556
+ Final changes for 2.1 release
557
+ =============================================================================
558
+ EOF
559
+
560
+ def test_can_parse_logs_with_cvs_and_dashes_in_commit_message
561
+ @parser = CvsLogParser.new(StringIO.new(LOG_WITH_WEIRD_CVS_AND_MANY_DASHES))
562
+ revisions = @parser.parse_revisions
563
+ assert_equal(6, revisions.length)
564
+ end
565
+
566
+ end
567
+ end