rscm 0.4.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
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,14 @@
1
+ ---
2
+ start: 2006-03-10 00:00:00 Z
3
+ identifiers:
4
+ - 6
5
+ - 142
6
+ - 143
7
+ - 145
8
+ - 156
9
+ - 157
10
+ - 158
11
+ - 159
12
+ - 160
13
+ - 161
14
+ - 164
@@ -41,6 +41,16 @@ revisions:
41
41
  identifier: 156
42
42
  message: reorganisations for compat suites
43
43
  time: 2006-03-03 17:55:54 Z
44
+ to_s: |
45
+ 156 | aslak | Fri Mar 03 17:55:54 UTC 2006 | reorganisations for compat suites
46
+ rscm/compatibility/damage_control_minimal.rb | 156
47
+ rscm/compatibility/full.rb | 156
48
+ rscm/generic_scm_tests.rb | 156
49
+ rscm/scm/cvs_log_parser_test.rb | 156
50
+ rscm/scm/cvs_test.rb | 156
51
+ rscm/scm/perforce_test.rb | 156
52
+ rscm/scm/subversion_test.rb | 156
53
+
44
54
  - !ruby/object:RSCM::Revision
45
55
  developer: aslak
46
56
  files:
@@ -67,3 +77,10 @@ revisions:
67
77
  identifier: 157
68
78
  message: Added settings for subversion dc compat test
69
79
  time: 2006-03-03 18:24:07 Z
80
+ to_s: |
81
+ 157 | aslak | Fri Mar 03 18:24:07 UTC 2006 | Added settings for subversion dc compat test
82
+ rscm/compatibility/damage_control_minimal.rb | 157
83
+ rscm/compatibility/subversion_rscm/files.yml | 157
84
+ rscm/compatibility/subversion_rscm/revisions.yml | 157
85
+ rscm/compatibility/subversion_rscm/scm.yml | 157
86
+
@@ -1,2 +1,3 @@
1
1
  --- !ruby/object:RSCM::Subversion
2
2
  url: http://buildpatterns.com/svn/repos/rscm/trunk/test
3
+ path: rscm/trunk/test
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'rscm/revision_file'
3
+
4
+ module RSCM
5
+ class RevisionFileTest < Test::Unit::TestCase
6
+ def test_should_be_equal_when_data_equal
7
+ assert_equal RevisionFile.new, RevisionFile.new
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,91 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'rscm/revision_poller'
3
+
4
+ module RSCM
5
+ class FakeScm
6
+ include RevisionPoller
7
+
8
+ ra = Revision.new(1, Time.utc(2004, 6,12,0,0,0))
9
+ rb = Revision.new(120, Time.utc(2004, 7,12,0,0,0))
10
+ range_x = Array.new(120, ra); range_x[-1] = rb
11
+
12
+ rc = Revision.new(121, Time.utc(2004, 8,12,0,0,0))
13
+ rd = Revision.new(200, Time.utc(2004, 9,12,0,0,0))
14
+ range_y = Array.new(80, rc); range_y[-1] = rd
15
+
16
+ re = Revision.new(201, Time.utc(2004,10,12,0,0,0))
17
+ rf = Revision.new(240, Time.utc(2004,11,12,0,0,0))
18
+ range_z = Array.new(40, re); range_z[-1] = rf
19
+
20
+ @@all_revisions = {}
21
+
22
+ @@all_revisions[121] = Revisions.new(range_y)
23
+ @@all_revisions[200] = Revisions.new(range_z)
24
+ @@all_revisions[240] = Revisions.new()
25
+
26
+ @@all_revisions[Time.utc(2004,12,11,23,0,0)] = Revisions.new(range_z) # 1 hr back from re (201-240)
27
+ @@all_revisions[Time.utc(2004,10,11,22,0,0)] = Revisions.new(range_y) # 2 hr back from rc (121-200)
28
+ @@all_revisions[Time.utc(2004, 8,11,20,0,0)] = Revisions.new(range_x) # 4 hr back from ra (1-120)
29
+ @@all_revisions[Time.utc(2004, 6,11,20,0,0)] = Revisions.new() # 8 hr back from ra
30
+ @@all_revisions[Time.utc(2004, 6,11,16,0,0)] = Revisions.new() # 16 hr back from ra
31
+ @@all_revisions[Time.utc(2004, 6,11, 8,0,0)] = Revisions.new() # etc...
32
+ @@all_revisions[Time.utc(2004, 6,10,16,0,0)] = Revisions.new()
33
+ @@all_revisions[Time.utc(2004, 6, 9, 8,0,0)] = Revisions.new()
34
+ @@all_revisions[Time.utc(2004, 6, 6,16,0,0)] = Revisions.new()
35
+ @@all_revisions[Time.utc(2004, 6, 1, 8,0,0)] = Revisions.new()
36
+ @@all_revisions[Time.utc(2004, 5,21,16,0,0)] = Revisions.new()
37
+ @@all_revisions[Time.utc(2004, 4,30, 8,0,0)] = Revisions.new()
38
+ @@all_revisions[Time.utc(2004, 3,18,16,0,0)] = Revisions.new()
39
+ @@all_revisions[Time.utc(2003,12,24, 8,0,0)] = Revisions.new()
40
+ @@all_revisions[Time.utc(2003, 7, 6,16,0,0)] = Revisions.new()
41
+ @@all_revisions[Time.utc(2002, 7,30, 8,0,0)] = Revisions.new()
42
+ @@all_revisions[Time.utc(2000, 9,15,16,0,0)] = Revisions.new()
43
+ @@all_revisions[Time.utc(1996,12,20, 8,0,0)] = Revisions.new()
44
+ @@all_revisions[Time.utc(1989, 6,29,16,0,0)] = Revisions.new()
45
+ @@all_revisions[Time.utc(1974, 7,17, 8,0,0)] = Revisions.new()
46
+ @@all_revisions[Time.epoch] = Revisions.new()
47
+
48
+ def revisions(from, options)
49
+ result = @@all_revisions[from]
50
+ if result.nil?
51
+ raise "No rev for time #{from.strftime('%Y,%m,%d,%H,%M,%S')}" if from.is_a?(Time)
52
+ raise "No rev for rev #{from.inspect}" if from.is_a?(Revision)
53
+ end
54
+ result
55
+ end
56
+ end
57
+
58
+ class RevisionPollerTest < Test::Unit::TestCase
59
+ def test_should_poll_backwards
60
+ scm = FakeScm.new
61
+ callback_count = 0
62
+ scm.poll(Time.utc(2004,12,12,0,0,0), :backwards) do |revisions|
63
+ callback_count += 1
64
+ end
65
+ assert_equal 21, callback_count
66
+ end
67
+
68
+ def test_should_poll_forwards
69
+ scm = FakeScm.new
70
+ callback_count = 0
71
+
72
+ rc = Revision.new(121, Time.utc(2004, 8,12,0,0,0))
73
+ now = Time.utc(2006, 4,12,11,51,43)
74
+ scm.poll(rc, :forwards, 1, now) do |revisions|
75
+ callback_count += 1
76
+ end
77
+ assert_equal 15, callback_count
78
+ end
79
+
80
+ def test_should_poll_forwards_upto_24_hours_from_identifier
81
+ scm = FakeScm.new
82
+ callback_count = 0
83
+
84
+ now = Time.utc(2006, 4,12,11,51,43)
85
+ scm.poll(240, :forwards, 1, now) do |revisions|
86
+ callback_count += 1
87
+ end
88
+ assert_equal 6, callback_count
89
+ end
90
+ end
91
+ end
@@ -1,129 +1,34 @@
1
- require 'yaml'
2
- require 'rscm/revision_fixture'
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'rscm/revision'
3
+ require 'rscm/revision_file'
3
4
 
4
5
  module RSCM
5
- class RevisionTest < Test::Unit::TestCase
6
- include RevisionFixture
7
-
8
- def setup
9
- setup_changes
10
- end
11
-
12
- def test_convert_changes_to_revisions_should_match_user_message_and_timestamp_
13
- revisions = Revisions.new
14
- revisions.add(@change1)
15
- revisions.add(@change2)
16
- revisions.add(@change3)
17
- revisions.add(@change4)
18
- revisions.add(@change5)
19
- revisions.add(@change6)
20
- revisions.add(@change7)
21
-
22
- revision_0 = Revision.new
23
- revision_0 << @change1
24
- revision_0 << @change2
25
-
26
- revision_1 = Revision.new
27
- revision_1 << @change3
28
-
29
- revision_2 = Revision.new
30
- revision_2 << @change4
31
-
32
- revision_3 = Revision.new
33
- revision_3 << @change5
34
- revision_3 << @change6
35
- revision_3 << @change7
36
-
37
- assert_equal(4, revisions.length)
38
-
39
- expected_revisions = Revisions.new
40
- expected_revisions.add(revision_0)
41
- expected_revisions.add(revision_1)
42
- expected_revisions.add(revision_2)
43
- expected_revisions.add(revision_3)
44
-
45
- assert_equal(expected_revisions, revisions)
46
- end
47
-
48
- def test_revisions_can_add_individual_changes_and_group_in_revision_instances
49
- revisions = Revisions.new
50
- assert(0, revisions.length)
6
+ class RevisionTest < Test::Unit::TestCase
7
+ def test_accepts_files_in_range_and_reports_min_and_max
8
+ revision = Revision.new
51
9
 
52
- revisions.add(@change1)
53
- revisions.add(@change2)
54
- revisions.add(@change3)
55
- revisions.add(@change4)
56
- assert(3, revisions.length)
10
+ revision.add RevisionFile.new(nil, nil, nil, nil, nil, Time.utc(2004,11,11,12,12,12))
11
+ revision.add RevisionFile.new(nil, nil, nil, nil, nil, Time.utc(2004,11,11,12,13,12))
12
+ assert_raise(RuntimeError) do
13
+ revision.add RevisionFile.new(nil, nil, nil, nil, nil, Time.utc(2004,11,11,12,14,13))
14
+ end
57
15
 
58
- tjo_bing_revision = revisions[0]
59
- hipp_hurra_revision = revisions[1]
60
- hipp_hurraX_revision = revisions[2]
61
- assert(2, tjo_bing_revision.length)
62
- assert(1, hipp_hurra_revision.length)
63
- assert(1, hipp_hurraX_revision.length)
64
-
65
- assert_same(@change1, tjo_bing_revision[0])
66
- assert_same(@change2, tjo_bing_revision[1])
67
- assert_same(@change3, hipp_hurra_revision[0])
68
- assert_same(@change4, hipp_hurraX_revision[0])
16
+ t12 = Time.utc(2004,11,11,12,12,12)
17
+ t13 = Time.utc(2004,11,11,12,13,12)
18
+ assert_equal(t12, revision.time(:min))
19
+ assert_equal(t13, revision.time(:max))
69
20
  end
70
21
 
71
- def test_should_sort_by_time
72
- revisions = Revisions.new
73
- revisions.add(@change1)
74
- revisions.add(@change4)
75
- revisions.add(@change2)
76
- revisions.add(@change7)
77
- revisions.add(@change5)
78
- revisions.add(@change3)
79
- revisions.add(@change6)
80
-
81
- revisions = revisions.sort do |a,b|
82
- a.time <=> b.time
83
- end
84
- assert_equal(4, revisions.length)
85
-
86
- assert_equal(@change2.time, revisions[0].time)
87
- assert_equal(@change7.time, revisions[-1].time)
22
+ def test_should_be_equal_when_data_equal
23
+ assert_equal Revision.new, Revision.new
88
24
  end
89
25
 
90
- def test_can_parse_revisions_from_yaml
91
- revisions = File.open(File.dirname(__FILE__) + "/revisions.yaml") do |io|
92
- YAML::load(io)
93
- end
94
- assert_equal("rinkrank", revisions[0][1].developer)
95
- assert_equal("En to\ntre buksa \nned\n", revisions[0][1].message)
96
- end
97
-
98
- def test_reports_timestamp_of_latest_change
99
- revision = Revision.new
100
- revision << RevisionFile.new(nil, nil, nil, nil, nil, Time.utc(2004))
101
- revision << RevisionFile.new(nil, nil, nil, nil, nil, Time.utc(2005))
102
- revision << RevisionFile.new(nil, nil, nil, nil, nil, Time.utc(2003))
103
- assert_equal(Time.utc(2005), revision.time)
104
- end
105
-
106
- def test_should_sort_revisions
107
- revisions = Revisions.new
108
- revisions.add(@change1)
109
- revisions.add(@change4)
110
- revisions.add(@change2)
111
- revisions.add(@change7)
112
- revisions.add(@change5)
113
- revisions.add(@change3)
114
- revisions.add(@change6)
115
-
116
- cs0 = revisions[0]
117
- cs1 = revisions[1]
118
- cs2 = revisions[2]
119
- cs3 = revisions[3]
26
+ def test_should_be_yamlable
27
+ r1 = Revision.new
28
+ r1.developer = "aslak"
120
29
 
121
- reversed = revisions.reverse
122
- assert_equal(cs0, reversed[3])
123
- assert_equal(cs1, reversed[2])
124
- assert_equal(cs2, reversed[1])
125
- assert_equal(cs3, reversed[0])
30
+ r2 = YAML::load(YAML::dump(r1))
31
+ assert_equal r1.developer, r2.developer
126
32
  end
127
33
  end
128
-
129
34
  end
@@ -0,0 +1,80 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+ require 'rscm/revision'
3
+ require 'rscm/revision_file'
4
+ require 'rscm/revisions'
5
+ require 'yaml'
6
+
7
+ module RSCM
8
+ class RevisionsTest < Test::Unit::TestCase
9
+
10
+ def setup
11
+ @revision_file1 = RSCM::RevisionFile.new("path/one", "MODIFIED", "aslak", "Fixed CATCH-22", 2, Time.utc(2004,7,5,12,0,2))
12
+ @revision_file2 = RSCM::RevisionFile.new("path/two", "MODIFIED", "aslak", "Fixed CATCH-22", 3, Time.utc(2004,7,5,12,1,2))
13
+ @revision_file3 = RSCM::RevisionFile.new("path/three", "MODIFIED", "aslak", "Fixed CATCH-22", 4, Time.utc(2004,7,5,12,2,3))
14
+ end
15
+
16
+ def test_adds_revision_files_to_revisions_as_needed
17
+ revisions = Revisions.new
18
+ revisions.add(@revision_file1)
19
+ revisions.add(@revision_file2)
20
+ revisions.add(@revision_file3)
21
+
22
+ assert_equal(2, revisions.length)
23
+
24
+ revision_0 = Revision.new
25
+ revision_0.add @revision_file1
26
+ revision_0.add @revision_file2
27
+
28
+ revision_1 = Revision.new
29
+ revision_1.add @revision_file3
30
+
31
+ expected_revisions = Revisions.new
32
+ expected_revisions.add revision_0
33
+ expected_revisions.add revision_1
34
+
35
+ assert_equal(expected_revisions, revisions)
36
+ end
37
+
38
+ def test_should_sort_by_time
39
+ revisions = Revisions.new
40
+ revisions.add(@revision_file3)
41
+ revisions.add(@revision_file1)
42
+ revisions.add(@revision_file2)
43
+
44
+ revisions = revisions.sort do |a,b|
45
+ a.time <=> b.time
46
+ end
47
+ assert_equal(2, revisions.length)
48
+
49
+ assert_equal(@revision_file1.time, revisions[0].time(:min))
50
+ assert_equal(@revision_file2.time, revisions[0].time)
51
+ assert_equal(@revision_file3.time, revisions[1].time)
52
+ end
53
+
54
+ def test_should_be_equal_when_data_equal
55
+ r1 = Revisions.new
56
+ r1.add Revision.new
57
+
58
+ r2 = Revisions.new
59
+ r2.add Revision.new
60
+
61
+ assert_equal r1, r2
62
+ end
63
+
64
+ def test_should_be_equal_after_yaml_serialization
65
+ revisions = Revisions.new
66
+ revisions.add(@revision_file3)
67
+ revisions.add(@revision_file1)
68
+ revisions.add(@revision_file2)
69
+
70
+ revisions = revisions.sort do |a,b|
71
+ a.time <=> b.time
72
+ end
73
+
74
+ cp = YAML::load(YAML::dump(revisions))
75
+ assert_equal revisions[0][0].path, cp[0][0].path
76
+ end
77
+
78
+ end
79
+
80
+ end
@@ -1,567 +1,569 @@
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
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require 'stringio'
3
+ require 'fileutils'
4
+
5
+ module RSCM
6
+ class CvsLogParserTest < Test::Unit::TestCase
7
+
8
+ include FileUtils
9
+
10
+ def setup
11
+ @parser = CvsLogParser.new(nil)
12
+ @parser.cvspath = "/scm/damagecontrol"
13
+ @parser.cvsmodule = "damagecontrol"
14
+ end
15
+
16
+ def test_read_log_entry
17
+ assert_equal(nil, CvsLogParser.new(StringIO.new("")).next_log_entry)
18
+ end
19
+
20
+ def test_parses_entire_log_into_revisions
21
+ File.open(File.dirname(__FILE__) + "/cvs-test.log") do |io|
22
+ @parser = CvsLogParser.new(io)
23
+ revisions = @parser.parse_revisions
24
+
25
+ assert_equal(24, revisions.length)
26
+ assert_match(/o YAML config \(BuildBootstrapper\)/, revisions[1].message)
27
+ assert_match(/failure/, revisions[8].message)
28
+ end
29
+ end
30
+
31
+ # http://jira.codehaus.org/browse/DC-312
32
+ # Have to find the bottleneck. Might be in Revision/Revisions
33
+ def SLOOOWtest_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(273, revisions.length)
39
+ end
40
+ end
41
+
42
+ LOG_ENTRY = <<-EOF
43
+ =============================================================================
44
+
45
+ RCS file: /scm/damagecontrol/damagecontrol/src/ruby/damagecontrol/BuildExecutorTest.rb,v
46
+ Working file: src/ruby/damagecontrol/BuildExecutorTest.rb
47
+ head: 1.20
48
+ branch:
49
+ locks: strict
50
+ access list:
51
+ symbolic names:
52
+ keyword substitution: kv
53
+ total revisions: 20; selected revisions: 4
54
+ description:
55
+ ----------------------------
56
+ revision 1.20
57
+ date: 2003/11/09 17:53:37; author: tirsen; state: Exp; lines: +3 -4
58
+ Quiet period is configurable for each project
59
+ ----------------------------
60
+ revision 1.19
61
+ date: 2003/11/09 17:04:18; author: tirsen; state: Exp; lines: +32 -2
62
+ Quiet period implemented for BuildExecutor, but does not yet handle multiple projects (builds are not queued as before)
63
+ ----------------------------
64
+ revision 1.18
65
+ date: 2003/11/09 15:51:50; author: rinkrank; state: Exp; lines: +1 -2
66
+ linux-windows galore
67
+ ----------------------------
68
+ revision 1.17
69
+ date: 2003/11/09 15:00:06; author: rinkrank; state: Exp; lines: +6 -8
70
+ o YAML config (BuildBootstrapper)
71
+ o EmailPublisher
72
+ =============================================================================
73
+ EOF
74
+
75
+ def test_parse_files
76
+ revisions = Revisions.new
77
+ @parser.parse_files(LOG_ENTRY, revisions)
78
+ assert_equal(4, revisions.length)
79
+ assert_equal("src/ruby/damagecontrol/BuildExecutorTest.rb", revisions[0][0].path)
80
+ assert_match(/linux-windows galore/, revisions[2].message)
81
+ end
82
+
83
+ CHANGE_ENTRY = <<-EOF
84
+ revision 1.20
85
+ date: 2003/11/09 17:53:37; author: tirsen; state: Exp; lines: +3 -4
86
+ Quiet period is configurable for each project
87
+ EOF
88
+
89
+ def test_can_split_entries_separated_by_line_of_dashes
90
+ entries = @parser.split_entries(LOG_ENTRY)
91
+ assert_equal(5, entries.length)
92
+ assert_equal(CHANGE_ENTRY, entries[1])
93
+ end
94
+
95
+ def test_sets_previous_native_revision_identifier_to_one_before_the_current
96
+ change = @parser.parse_file(CHANGE_ENTRY)
97
+ assert_equal("1.20", change.native_revision_identifier)
98
+ assert_equal("1.19", change.previous_native_revision_identifier)
99
+ end
100
+
101
+ def test_can_determine_previous_native_revision_identifiers_from_tricky_input
102
+ assert_equal("2.2.1.1", @parser.determine_previous_native_revision_identifier("2.2.1.2"))
103
+ assert_equal(nil, @parser.determine_previous_native_revision_identifier("2.2.1.1"))
104
+ end
105
+
106
+ def test_parse_file
107
+ change = @parser.parse_file(CHANGE_ENTRY)
108
+ assert_equal("1.20", change.native_revision_identifier)
109
+ assert_equal(Time.utc(2003,11,9,17,53,37), change.time)
110
+ assert_equal("tirsen", change.developer)
111
+ assert_match(/Quiet period is configurable for each project/, change.message)
112
+ end
113
+
114
+ LOG_ENTRY_WITH_DELETED_FILE = <<EOF
115
+ RCS file: /scm/damagecontrol/damagecontrol/server/damagecontrol/Attic/codehaus.rb,v
116
+ Working file: server/damagecontrol/codehaus.rb
117
+ head: 1.23
118
+ branch:
119
+ locks: strict
120
+ access list:
121
+ keyword substitution: kv
122
+ total revisions: 23; selected revisions: 1
123
+ description:
124
+ ----------------------------
125
+ revision 1.23
126
+ date: 2004/07/13 07:56:26; author: tirsen; state: dead; lines: +0 -0
127
+ remove username check (doesn't work on beaver)
128
+ I do really want to see the url in irc, it's very, very convenient. thank you very much ;-)
129
+ EOF
130
+
131
+ def test_can_parse_files_with_deleted_file
132
+ revisions = Revisions.new
133
+ @parser.parse_files(LOG_ENTRY_WITH_DELETED_FILE, revisions)
134
+ assert_equal(1, revisions.length)
135
+ assert_equal("server/damagecontrol/codehaus.rb", revisions[0][0].path)
136
+ assert_equal(RevisionFile::DELETED, revisions[0][0].status)
137
+ end
138
+
139
+ def test_log_from_e2e_test
140
+ @parser = CvsLogParser.new(StringIO.new(LOG_FROM_E2E_TEST))
141
+ revisions = @parser.parse_revisions
142
+ assert_equal(2, revisions.length)
143
+ assert_match(/foo/, revisions[1].message)
144
+ assert_match(/bar/, revisions[0].message)
145
+ end
146
+
147
+ LOG_FROM_E2E_TEST = <<-EOF
148
+ =============================================================================
149
+
150
+ RCS file: C:\projects\damagecontrol\target\temp_e2e_1081547757\repository/e2eproject/build.bat,v
151
+ Working file: build.bat
152
+ head: 1.2
153
+ branch:
154
+ locks: strict
155
+ access list:
156
+ symbolic names:
157
+ keyword substitution: kv
158
+ total revisions: 2; selected revisions: 2
159
+ description:
160
+ ----------------------------
161
+ revision 1.2
162
+ date: 2004/04/09 21:56:47; author: jtirsen; state: Exp; lines: +1 -1
163
+ foo
164
+ ----------------------------
165
+ revision 1.1
166
+ date: 2004/04/09 21:56:12; author: jtirsen; state: Exp;
167
+ bar
168
+ =============================================================================EOF
169
+ EOF
170
+
171
+ def test_can_parse_path
172
+ assert_equal("testdata/damagecontrolled/src/java/com/thoughtworks/damagecontrolled/Thingy.java",
173
+ @parser.parse_path(LOG_ENTRY_FROM_05_07_2004_19_42))
174
+ end
175
+
176
+ LOG_ENTRY_FROM_05_07_2004_19_42 = <<-EOF
177
+ RCS file: /scm/damagecontrol/damagecontrol/testdata/damagecontrolled/src/java/com/thoughtworks/damagecontrolled/Thingy.java,v
178
+ Working file: testdata/damagecontrolled/src/java/com/thoughtworks/damagecontrolled/Thingy.java
179
+ head: 1.1
180
+ branch:
181
+ locks: strict
182
+ access list:
183
+ symbolic names:
184
+ BEFORE_CENTRAL_REFACTORING: 1.1
185
+ RELEASE_0_1: 1.1
186
+ keyword substitution: kv
187
+ total revisions: 1; selected revisions: 1
188
+ description:
189
+ EOF
190
+
191
+ def test_can_parse_LOG_FROM_05_07_2004_19_41
192
+ @parser = CvsLogParser.new(StringIO.new(LOG_FROM_05_07_2004_19_41))
193
+ assert_equal(11, @parser.split_entries(LOG_FROM_05_07_2004_19_41).size)
194
+ assert_equal("server/damagecontrol/scm/CVS.rb", @parser.parse_path(@parser.split_entries(LOG_FROM_05_07_2004_19_41)[0]))
195
+ revisions = @parser.parse_revisions
196
+ revisions.sort!
197
+
198
+ assert_equal(10, revisions.length)
199
+ expected_file = RevisionFile.new
200
+ expected_file.path = "server/damagecontrol/scm/CVS.rb"
201
+ expected_file.developer = "tirsen"
202
+ expected_file.message = "fixed some stuff in the log parser"
203
+ expected_file.native_revision_identifier = "1.19"
204
+ expected_file.status = "MODIFIED"
205
+ expected_file.time = Time.utc(2004, 7, 5, 9, 41, 51)
206
+
207
+ assert_equal(expected_file, 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
+ revisions.sort!
359
+
360
+ assert_equal(2, revisions.length)
361
+
362
+ revision_delete = revisions[1]
363
+ assert_equal(Time.utc(2003,10,13,05,04,54,0), revision_delete.time)
364
+ assert_equal("Obsolete", revision_delete.message)
365
+ assert_equal("rinkrank", revision_delete.developer)
366
+ assert_equal(1, revision_delete.length)
367
+ assert_equal("build.xml", revision_delete[0].path)
368
+ assert_equal("1.11", revision_delete[0].native_revision_identifier)
369
+ assert_equal("1.10", revision_delete[0].previous_native_revision_identifier)
370
+ assert(RevisionFile::DELETED, revision_delete[0].status)
371
+
372
+ revision_fix_url = revisions[0]
373
+ assert_equal(Time.utc(2003,07,25,16,32,39,0), revision_fix_url.time)
374
+ assert_equal("fixed broken url (NANO-8)", revision_fix_url.message)
375
+ assert_equal("rinkrank", revision_fix_url.developer)
376
+ assert_equal(1, revision_fix_url.length)
377
+ assert_equal("build.xml", revision_fix_url[0].path)
378
+ assert_equal("1.10", revision_fix_url[0].native_revision_identifier)
379
+ assert_equal("1.9", revision_fix_url[0].previous_native_revision_identifier)
380
+ assert_equal(RevisionFile::MODIFIED, revision_fix_url[0].status)
381
+ end
382
+
383
+ LOG_WITH_MISSING_ENTRIES = <<EOF
384
+ RCS file: /cvsroot/damagecontrol/damagecontrol/Attic/build.xml,v
385
+ Working file: build.xml
386
+ head: 1.2
387
+ branch:
388
+ locks: strict
389
+ access list:
390
+ symbolic names:
391
+ initial-import: 1.1.1.1
392
+ mgm: 1.1.1
393
+ keyword substitution: kv
394
+ total revisions: 3; selected revisions: 0
395
+ description:
396
+ =============================================================================
397
+
398
+ RCS file: /cvsroot/damagecontrol/damagecontrol/maven.xml,v
399
+ Working file: maven.xml
400
+ head: 1.2
401
+ branch:
402
+ locks: strict
403
+ access list:
404
+ symbolic names:
405
+ keyword substitution: kv
406
+ total revisions: 2; selected revisions: 0
407
+ description:
408
+ =============================================================================
409
+ EOF
410
+
411
+ def test_can_parse_LOG_WITH_MISSING_ENTRIES
412
+ @parser = CvsLogParser.new(StringIO.new(LOG_WITH_MISSING_ENTRIES))
413
+ revisions = @parser.parse_revisions
414
+ assert_equal(0, revisions.length)
415
+ end
416
+
417
+ LOG_WITH_NEW_AND_OLD_FILE = <<EOF
418
+ RCS file: /home/projects/damagecontrol/scm/damagecontrol/dummy.txt,v
419
+ Working file: dummy.txt
420
+ head: 1.1
421
+ branch:
422
+ locks: strict
423
+ access list:
424
+ keyword substitution: kv
425
+ total revisions: 1; selected revisions: 1
426
+ description:
427
+ ----------------------------
428
+ revision 1.1
429
+ date: 2004/07/13 21:50:59; author: rinkrank; state: Exp;
430
+ Debug. Need to see what the log looks like for a new file.
431
+ =============================================================================
432
+
433
+ RCS file: /home/projects/damagecontrol/scm/damagecontrol/license.txt,v
434
+ Working file: license.txt
435
+ head: 1.4
436
+ branch:
437
+ locks: strict
438
+ access list:
439
+ keyword substitution: kv
440
+ total revisions: 4; selected revisions: 4
441
+ description:
442
+ ----------------------------
443
+ revision 1.101
444
+ date: 2004/07/10 17:41:14; author: rinkrank; state: Exp; lines: +2 -2
445
+ typo
446
+ ----------------------------
447
+ revision 1.11
448
+ date: 2004/07/10 17:38:22; author: rinkrank; state: Exp; lines: +2 -2
449
+ fixed http://jira.codehaus.org/browse/DC-123
450
+ ----------------------------
451
+ revision 1.1
452
+ date: 2004/07/02 08:42:51; author: tirsen; state: Exp;
453
+ installer!!!!!! it's getting close to release!!!
454
+ =============================================================================
455
+ EOF
456
+
457
+ def test_can_distinguish_new_file_from_old_file
458
+ @parser = CvsLogParser.new(StringIO.new(LOG_WITH_NEW_AND_OLD_FILE))
459
+ revisions = @parser.parse_revisions
460
+
461
+ assert_equal(RevisionFile::ADDED, revisions[0][0].status)
462
+ assert_equal(RevisionFile::MODIFIED, revisions[1][0].status)
463
+ assert_equal(RevisionFile::MODIFIED, revisions[2][0].status)
464
+ assert_equal(RevisionFile::ADDED, revisions[3][0].status)
465
+ end
466
+
467
+ # https://sitemesh.dev.java.net/source/browse/sitemesh/.cvsignore
468
+ # The default commit message probably showed up in vi, and the committer
469
+ # probably just left it there. Not sure why CVS kept it this way
470
+ # (lines starting with CVS: should be ignored in commit message afaik).
471
+ # Anyway, the parser now knows how to deal with this. (AH)
472
+ LOG_WITH_WEIRD_CVS_AND_MANY_DASHES = <<EOF
473
+ ? log.txt
474
+
475
+ RCS file: /cvs/sitemesh/.cvsignore,v
476
+ Working file: .cvsignore
477
+ head: 1.3
478
+ branch:
479
+ locks: strict
480
+ access list:
481
+ keyword substitution: kv
482
+ total revisions: 3; selected revisions: 3
483
+ description:
484
+ ----------------------------
485
+ revision 1.3
486
+ date: 2004/05/03 09:03:56; author: rhallier; state: Exp; lines: +2 -0
487
+ Issue number: SIM-90
488
+
489
+ Obtained from: JIRA
490
+
491
+ Submitted by: rhallier
492
+
493
+ Reviewed by:
494
+
495
+ CVS: ----------------------------------------------------------------------
496
+
497
+ CVS: Issue number:
498
+
499
+ CVS: If this change addresses one or more issues,
500
+
501
+ CVS: then enter the issue number(s) here.
502
+
503
+ CVS: Obtained from:
504
+
505
+ CVS: If this change has been taken from another system,
506
+
507
+ CVS: then name the system in this line, otherwise delete it.
508
+
509
+ CVS: Submitted by:
510
+
511
+ CVS: If this code has been contributed to the project by someone else; i.e.,
512
+
513
+ CVS: they sent us a patch or a set of diffs, then include their name/email
514
+
515
+ CVS: address here. If this is your work then delete this line.
516
+
517
+ CVS: Reviewed by:
518
+
519
+ CVS: If we are doing pre-commit code reviews and someone else has
520
+
521
+ CVS: reviewed your changes, include their name(s) here.
522
+
523
+ CVS: If you have not had it reviewed then delete this line.
524
+ ----------------------------
525
+ revision 1.2
526
+ date: 2003/11/22 07:56:51; author: hani; state: Exp; lines: +2 -1
527
+ Ignore IDEA files
528
+ ----------------------------
529
+ revision 1.1
530
+ date: 2003/11/03 16:27:37; author: mbogaert; state: Exp;
531
+ Moved from SF.
532
+ =============================================================================
533
+
534
+ RCS file: /cvs/sitemesh/CHANGES.txt,v
535
+ Working file: CHANGES.txt
536
+ head: 1.3
537
+ branch:
538
+ locks: strict
539
+ access list:
540
+ keyword substitution: kv
541
+ total revisions: 3; selected revisions: 3
542
+ description:
543
+ ----------------------------
544
+ revision 1.3
545
+ date: 2004/10/08 07:18:38; author: hani; state: Exp; lines: +18 -0
546
+ More files not updated for release
547
+ ----------------------------
548
+ revision 1.2
549
+ date: 2004/09/24 14:04:12; author: jwalnes1; state: Exp; lines: +19 -0
550
+ Preparing for 2.2 release.
551
+ Issue number:
552
+ Obtained from:
553
+ Submitted by:
554
+ Reviewed by:
555
+ ----------------------------
556
+ revision 1.1
557
+ date: 2004/07/22 01:30:27; author: farkas; state: Exp;
558
+ Final changes for 2.1 release
559
+ =============================================================================
560
+ EOF
561
+
562
+ def test_can_parse_logs_with_cvs_and_dashes_in_commit_message
563
+ @parser = CvsLogParser.new(StringIO.new(LOG_WITH_WEIRD_CVS_AND_MANY_DASHES))
564
+ revisions = @parser.parse_revisions
565
+ assert_equal(6, revisions.length)
566
+ end
567
+
568
+ end
569
+ end