rscm 0.1.0.1338 → 0.2.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 (47) hide show
  1. data/README +13 -28
  2. data/Rakefile +25 -24
  3. data/lib/rscm.rb +1 -6
  4. data/lib/rscm/abstract_scm.rb +36 -10
  5. data/lib/rscm/annotations.rb +50 -0
  6. data/lib/rscm/changes.rb +2 -5
  7. data/lib/rscm/logging.rb +1 -0
  8. data/lib/rscm/path_converter.rb +3 -2
  9. data/lib/rscm/{cvs → scm}/cvs.rb +16 -9
  10. data/lib/rscm/{cvs → scm}/cvs_log_parser.rb +4 -4
  11. data/lib/rscm/{darcs → scm}/darcs.rb +6 -3
  12. data/lib/rscm/scm/monotone.rb +162 -0
  13. data/lib/rscm/scm/monotone_log_parser.rb +95 -0
  14. data/lib/rscm/scm/mooky.rb +21 -0
  15. data/lib/rscm/{perforce → scm}/perforce.rb +7 -4
  16. data/lib/rscm/{starteam/starteam.rb → scm/star_team.rb} +23 -3
  17. data/lib/rscm/{svn/svn.rb → scm/subversion.rb} +17 -10
  18. data/lib/rscm/{svn/svn_log_parser.rb → scm/subversion_log_parser.rb} +8 -7
  19. data/test/rscm/abstract_scm_test.rb +21 -0
  20. data/test/rscm/annotations_test.rb +57 -0
  21. data/test/rscm/changes_fixture.rb +7 -7
  22. data/test/rscm/changes_test.rb +3 -3
  23. data/test/rscm/generic_scm_tests.rb +2 -2
  24. data/test/rscm/{cvs → scm}/cvs-dataforge.log +0 -0
  25. data/test/rscm/{cvs → scm}/cvs-test.log +0 -0
  26. data/test/rscm/{cvs → scm}/cvs_log_parser_test.rb +12 -13
  27. data/test/rscm/{cvs → scm}/cvs_test.rb +7 -7
  28. data/test/rscm/{darcs → scm}/darcs_test.rb +1 -1
  29. data/test/rscm/{monotone → scm}/keys +0 -0
  30. data/test/rscm/scm/monotone_log_parser_test.rb +109 -0
  31. data/test/rscm/{monotone → scm}/monotone_test.rb +1 -1
  32. data/test/rscm/{mooky → scm}/mooky_test.rb +1 -1
  33. data/test/rscm/{perforce → scm}/perforce_test.rb +1 -1
  34. data/test/rscm/{starteam/starteam_test.rb → scm/star_team.rb} +1 -1
  35. data/test/rscm/{svn/svn_log_parser_test.rb → scm/subversion_log_parser_test.rb} +25 -10
  36. data/test/rscm/{svn/svn_test.rb → scm/subversion_test.rb} +4 -5
  37. data/test/rscm/{svn/cargo-svn.log → scm/svn-cargo.log} +0 -0
  38. data/test/rscm/scm/svn-growl.log +875 -0
  39. data/test/rscm/scm/svn-growl2.log +30 -0
  40. data/test/rscm/{svn/proxytoys-svn.log → scm/svn-proxytoys.log} +0 -0
  41. metadata +35 -44
  42. data/lib/rscm/attr_attr.rb +0 -36
  43. data/lib/rscm/monotone/monotone.rb +0 -107
  44. data/lib/rscm/mooky/mooky.rb +0 -13
  45. data/test/actual +0 -3
  46. data/test/expected +0 -3
  47. data/test/rscm/attr_attr_test.rb +0 -32
@@ -3,10 +3,10 @@ require 'rscm/changes'
3
3
 
4
4
  module RSCM
5
5
 
6
- class SVNLogParser
6
+ class SubversionLogParser
7
7
  def initialize(io, path, checkout_dir)
8
8
  @io = io
9
- @changeset_parser = SVNLogEntryParser.new(path, checkout_dir)
9
+ @changeset_parser = SubversionLogEntryParser.new(path, checkout_dir)
10
10
  end
11
11
 
12
12
  def parse_changesets(&line_proc)
@@ -23,7 +23,7 @@ module RSCM
23
23
  end
24
24
  end
25
25
 
26
- class SVNLogEntryParser < Parser
26
+ class SubversionLogEntryParser < Parser
27
27
 
28
28
  def initialize(path, checkout_dir)
29
29
  super(/^------------------------------------------------------------------------/)
@@ -50,7 +50,7 @@ module RSCM
50
50
  elsif(@parse_state == :parse_changes)
51
51
  change = parse_change(line)
52
52
  if change
53
- # This unless won't work for new directories
53
+ # This unless won't work for new directories or if changesets are computed before checkout (which it usually is!)
54
54
  fullpath = "#{@checkout_dir}/#{change.path}"
55
55
  @changeset << change unless File.directory?(fullpath)
56
56
  end
@@ -67,7 +67,7 @@ module RSCM
67
67
 
68
68
  private
69
69
 
70
- STATES = {"M" => Change::MODIFIED, "A" => Change::ADDED, "D" => Change::DELETED}
70
+ STATES = {"M" => Change::MODIFIED, "A" => Change::ADDED, "D" => Change::DELETED} unless defined? STATES
71
71
 
72
72
  def parse_header(line)
73
73
  @changeset = ChangeSet.new
@@ -84,8 +84,9 @@ module RSCM
84
84
  if(line =~ /^ [M|A|D|R] ([^\s]+) \(from (.*)\)/)
85
85
  path_from_root = $1
86
86
  change.status = Change::MOVED
87
- elsif(line =~ /^ ([M|A|D]) (.+)$/)
88
- status, path_from_root = line.split
87
+ elsif(line =~ /^ ([M|A|D|R]) (.+)$/)
88
+ status = $1
89
+ path_from_root = $2
89
90
  change.status = STATES[status]
90
91
  else
91
92
  raise "could not parse change line: '#{line}'"
@@ -0,0 +1,21 @@
1
+ require 'test/unit'
2
+ require 'rscm'
3
+
4
+ module RSCM
5
+ class AbstractSCMTest < Test::Unit::TestCase
6
+ def test_should_load_all_scm_classes
7
+ expected_scms_classes = [
8
+ Cvs,
9
+ Darcs,
10
+ Monotone,
11
+ Mooky,
12
+ Perforce,
13
+ StarTeam,
14
+ Subversion
15
+ ]
16
+ assert_equal(
17
+ expected_scms_classes.collect{|c| c.name},
18
+ AbstractSCM.classes.collect{|c| c.name}.sort)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,57 @@
1
+ require 'test/unit'
2
+ require 'rscm/annotations'
3
+
4
+ module RSCM
5
+ class Whatever
6
+ attr_accessor :no_annotation
7
+ ann :boo => "huba luba", :pip => "pip pip"
8
+ attr_accessor :foo
9
+
10
+ ann :desc => "bang bang"
11
+ ann :tip => "a top tip"
12
+ attr_accessor :bar, :zap
13
+ end
14
+
15
+ class Other
16
+ attr_accessor :no_annotation
17
+ ann :boo => "boo"
18
+ ann :pip => "pip"
19
+ attr_accessor :foo
20
+
21
+ ann :desc => "desc", :tip => "tip"
22
+ attr_accessor :bar, :zap
23
+ end
24
+
25
+ class Subclass < Other
26
+ end
27
+
28
+ class AnnotationsTest < Test::Unit::TestCase
29
+ def test_should_handle_annotations_really_well
30
+ assert_equal("huba luba", Whatever.foo[:boo])
31
+ assert_equal("pip pip", Whatever.foo[:pip])
32
+
33
+ assert_nil(Whatever.bar[:pip])
34
+ assert_equal("bang bang", Whatever.bar[:desc])
35
+ assert_equal("a top tip", Whatever.bar[:tip])
36
+
37
+ assert_equal("bang bang", Whatever.zap[:desc])
38
+ assert_equal("a top tip", Whatever.zap[:tip])
39
+
40
+ assert_equal("boo", Other.foo[:boo])
41
+ assert_equal("pip", Other.foo[:pip])
42
+
43
+ assert_nil(Whatever.bar[:pip])
44
+ assert_equal("desc", Other.bar[:desc])
45
+ assert_equal("tip", Other.bar[:tip])
46
+
47
+ assert_equal("desc", Other.zap[:desc])
48
+ assert_equal("tip", Other.zap[:tip])
49
+ end
50
+
51
+ def test_should_inherit_attribute_annotations
52
+ assert_equal("boo", Subclass.foo[:boo])
53
+ assert_equal({:boo => "boo", :pip => "pip"}, Subclass.send("foo"))
54
+ assert_nil(Whatever.send("no_annotation"))
55
+ end
56
+ end
57
+ end
@@ -5,16 +5,16 @@ module RSCM
5
5
  module ChangesFixture
6
6
  def setup_changes
7
7
  #1
8
- @change1 = RSCM::Change.new("path/one", "jon", "Fixed CATCH-22", nil, Time.utc(2004,7,5,12,0,2))
9
- @change2 = RSCM::Change.new("path/two", "jon", "Fixed CATCH-22", nil, Time.utc(2004,7,5,12,0,4))
8
+ @change1 = RSCM::Change.new("path/one", nil, "jon", "Fixed CATCH-22", nil, Time.utc(2004,7,5,12,0,2))
9
+ @change2 = RSCM::Change.new("path/two", nil, "jon", "Fixed CATCH-22", nil, Time.utc(2004,7,5,12,0,4))
10
10
  #2
11
- @change3 = RSCM::Change.new("path/three", "jon", "hipp hurra", nil, Time.utc(2004,7,5,12,0,6))
11
+ @change3 = RSCM::Change.new("path/three", nil, "jon", "hipp hurra", nil, Time.utc(2004,7,5,12,0,6))
12
12
  #3
13
- @change4 = RSCM::Change.new("path/four", "aslak", "hipp hurraX", nil, Time.utc(2004,7,5,12,0,8))
13
+ @change4 = RSCM::Change.new("path/four", nil, "aslak", "hipp hurraX", nil, Time.utc(2004,7,5,12,0,8))
14
14
  #4
15
- @change5 = RSCM::Change.new("path/five", "aslak", "hipp hurra", nil, Time.utc(2004,7,5,12,0,10))
16
- @change6 = RSCM::Change.new("path/six", "aslak", "hipp hurra", nil, Time.utc(2004,7,5,12,0,12))
17
- @change7 = RSCM::Change.new("path/seven", "aslak", "hipp hurra", nil, Time.utc(2004,7,5,12,0,14))
15
+ @change5 = RSCM::Change.new("path/five", nil, "aslak", "hipp hurra", nil, Time.utc(2004,7,5,12,0,10))
16
+ @change6 = RSCM::Change.new("path/six", nil, "aslak", "hipp hurra", nil, Time.utc(2004,7,5,12,0,12))
17
+ @change7 = RSCM::Change.new("path/seven", nil, "aslak", "hipp hurra", nil, Time.utc(2004,7,5,12,0,14))
18
18
  end
19
19
  end
20
20
  end
@@ -97,9 +97,9 @@ module RSCM
97
97
 
98
98
  def test_reports_timestamp_of_latest_change
99
99
  changeset = ChangeSet.new
100
- changeset << Change.new(nil, nil, nil, nil, Time.utc(2004))
101
- changeset << Change.new(nil, nil, nil, nil, Time.utc(2005))
102
- changeset << Change.new(nil, nil, nil, nil, Time.utc(2003))
100
+ changeset << Change.new(nil, nil, nil, nil, nil, Time.utc(2004))
101
+ changeset << Change.new(nil, nil, nil, nil, nil, Time.utc(2005))
102
+ changeset << Change.new(nil, nil, nil, nil, nil, Time.utc(2003))
103
103
  assert_equal(Time.utc(2005), changeset.time)
104
104
  end
105
105
 
@@ -57,7 +57,7 @@ module RSCM
57
57
  assert_equal("src/java/com/thoughtworks/damagecontrolled/Thingy.java", files[2])
58
58
  assert_equal("src/test/com/thoughtworks/damagecontrolled/ThingyTestCase.java", files[3])
59
59
 
60
- initial_changesets = scm.changesets(checkout_dir, nil, nil, files)
60
+ initial_changesets = scm.changesets(checkout_dir, nil, nil)
61
61
  assert_equal(1, initial_changesets.length)
62
62
  initial_changeset = initial_changesets[0]
63
63
  assert_equal("imported\nsources", initial_changeset.message)
@@ -77,7 +77,7 @@ module RSCM
77
77
  # check that we now have one more change
78
78
  changesets = scm.changesets(checkout_dir, initial_changesets.time + 1)
79
79
 
80
- assert_equal(1, changesets.length)
80
+ assert_equal(1, changesets.length, changesets.collect{|cs| cs.to_s})
81
81
  changeset = changesets[0]
82
82
  assert_equal(2, changeset.length)
83
83
 
File without changes
File without changes
@@ -1,16 +1,15 @@
1
1
  require 'test/unit'
2
2
  require 'stringio'
3
3
  require 'fileutils'
4
- require 'rscm/changes'
5
- require 'rscm/cvs/cvs_log_parser'
4
+ require 'rscm'
6
5
 
7
6
  module RSCM
8
- class CVSLogParserTest < Test::Unit::TestCase
7
+ class CvsLogParserTest < Test::Unit::TestCase
9
8
 
10
9
  include FileUtils
11
10
 
12
11
  def setup
13
- @parser = CVSLogParser.new(nil)
12
+ @parser = CvsLogParser.new(nil)
14
13
  @parser.cvspath = "/scm/damagecontrol"
15
14
  @parser.cvsmodule = "damagecontrol"
16
15
  end
@@ -20,12 +19,12 @@ module RSCM
20
19
  end
21
20
 
22
21
  def test_read_log_entry
23
- assert_equal(nil, CVSLogParser.new(StringIO.new("")).next_log_entry)
22
+ assert_equal(nil, CvsLogParser.new(StringIO.new("")).next_log_entry)
24
23
  end
25
24
 
26
25
  def test_parses_entire_log_into_changesets
27
26
  File.open(File.dirname(__FILE__) + "/cvs-test.log") do |io|
28
- @parser = CVSLogParser.new(io)
27
+ @parser = CvsLogParser.new(io)
29
28
  changesets = @parser.parse_changesets
30
29
 
31
30
  assert_equal(24, changesets.length)
@@ -37,7 +36,7 @@ module RSCM
37
36
  # http://jira.codehaus.org/browse/DC-312
38
37
  def test_jira_dc_312
39
38
  File.open(File.dirname(__FILE__) + "/cvs-dataforge.log") do |io|
40
- @parser = CVSLogParser.new(io)
39
+ @parser = CvsLogParser.new(io)
41
40
  changesets = @parser.parse_changesets
42
41
 
43
42
  assert_equal(271, changesets.length)
@@ -110,7 +109,7 @@ EOF
110
109
  end
111
110
 
112
111
  def test_log_from_e2e_test
113
- @parser = CVSLogParser.new(StringIO.new(LOG_FROM_E2E_TEST))
112
+ @parser = CvsLogParser.new(StringIO.new(LOG_FROM_E2E_TEST))
114
113
  changesets = @parser.parse_changesets
115
114
  assert_equal(2, changesets.length)
116
115
  assert_match(/foo/, changesets[1].message)
@@ -195,7 +194,7 @@ description:
195
194
  EOF
196
195
 
197
196
  def test_can_parse_LOG_FROM_05_07_2004_19_41
198
- @parser = CVSLogParser.new(StringIO.new(LOG_FROM_05_07_2004_19_41))
197
+ @parser = CvsLogParser.new(StringIO.new(LOG_FROM_05_07_2004_19_41))
199
198
  assert_equal(11, @parser.split_entries(LOG_FROM_05_07_2004_19_41).size)
200
199
  assert_equal("server/damagecontrol/scm/CVS.rb", @parser.parse_path(@parser.split_entries(LOG_FROM_05_07_2004_19_41)[0]))
201
200
  changesets = @parser.parse_changesets
@@ -359,7 +358,7 @@ fixed broken url (NANO-8)
359
358
  EOF
360
359
 
361
360
  def test_can_parse_LOG_WITH_DELETIONS
362
- @parser = CVSLogParser.new(StringIO.new(LOG_WITH_DELETIONS))
361
+ @parser = CvsLogParser.new(StringIO.new(LOG_WITH_DELETIONS))
363
362
  changesets = @parser.parse_changesets
364
363
  assert_equal(2, changesets.length)
365
364
 
@@ -415,7 +414,7 @@ description:
415
414
  EOF
416
415
 
417
416
  def test_can_parse_LOG_WITH_MISSING_ENTRIES
418
- @parser = CVSLogParser.new(StringIO.new(LOG_WITH_MISSING_ENTRIES))
417
+ @parser = CvsLogParser.new(StringIO.new(LOG_WITH_MISSING_ENTRIES))
419
418
  changesets = @parser.parse_changesets
420
419
  assert_equal(0, changesets.length)
421
420
  end
@@ -461,7 +460,7 @@ installer!!!!!! it's getting close to release!!!
461
460
  EOF
462
461
 
463
462
  def test_can_distinguish_new_file_from_old_file
464
- @parser = CVSLogParser.new(StringIO.new(LOG_WITH_NEW_AND_OLD_FILE))
463
+ @parser = CvsLogParser.new(StringIO.new(LOG_WITH_NEW_AND_OLD_FILE))
465
464
  changesets = @parser.parse_changesets
466
465
 
467
466
  assert_equal(Change::ADDED, changesets[0][0].status)
@@ -566,7 +565,7 @@ Final changes for 2.1 release
566
565
  EOF
567
566
 
568
567
  def test_can_parse_logs_with_cvs_and_dashes_in_commit_message
569
- @parser = CVSLogParser.new(StringIO.new(LOG_WITH_WEIRD_CVS_AND_MANY_DASHES))
568
+ @parser = CvsLogParser.new(StringIO.new(LOG_WITH_WEIRD_CVS_AND_MANY_DASHES))
570
569
  changesets = @parser.parse_changesets
571
570
  assert_equal(6, changesets.length)
572
571
  end
@@ -1,30 +1,30 @@
1
1
  require 'test/unit'
2
2
  require 'rscm/path_converter'
3
- require 'rscm/cvs/cvs'
3
+ require 'rscm'
4
4
  require 'rscm/generic_scm_tests'
5
5
 
6
6
  module RSCM
7
7
 
8
- class CVS
8
+ class Cvs
9
9
  # Convenience factory method used in testing
10
- def CVS.local(cvsroot_dir, mod)
10
+ def Cvs.local(cvsroot_dir, mod)
11
11
  cvsroot_dir = PathConverter.filepath_to_nativepath(cvsroot_dir, true)
12
- CVS.new(":local:#{cvsroot_dir}", mod)
12
+ Cvs.new(":local:#{cvsroot_dir}", mod)
13
13
  end
14
14
  end
15
15
 
16
- class CVSTest < Test::Unit::TestCase
16
+ class CvsTest < Test::Unit::TestCase
17
17
 
18
18
  include GenericSCMTests
19
19
  include ApplyLabelTest
20
20
 
21
21
  def create_scm(repository_root_dir, path)
22
- CVS.local(repository_root_dir, path)
22
+ Cvs.local(repository_root_dir, path)
23
23
  end
24
24
 
25
25
  def test_should_fail_on_bad_command
26
26
  assert_raise(RuntimeError) do
27
- CVS.new("").create
27
+ Cvs.new("").create
28
28
  end
29
29
  end
30
30
 
@@ -1,7 +1,7 @@
1
1
  require 'test/unit'
2
2
  require 'fileutils'
3
+ require 'rscm'
3
4
  require 'rscm/generic_scm_tests'
4
- require 'rscm/darcs/darcs'
5
5
 
6
6
  module RSCM
7
7
  class DarcsTest < Test::Unit::TestCase
File without changes
@@ -0,0 +1,109 @@
1
+ require 'test/unit'
2
+ require 'stringio'
3
+ require 'rscm'
4
+
5
+ module RSCM
6
+ class MonotoneLogParserTest < Test::Unit::TestCase
7
+
8
+ CHANGESET = <<EOF
9
+ -----------------------------------------------------------------
10
+ Revision: a2c58e276439de7d9da549870e245776c592c7e8
11
+ Author: tester@test.net
12
+ Date: 2005-03-02T06:32:43
13
+
14
+ Added files:
15
+ build.xml project.xml
16
+ src/java/com/thoughtworks/damagecontrolled/Thingy.java
17
+ src/test/com/thoughtworks/damagecontrolled/ThingyTestCase.java
18
+
19
+ ChangeLog:
20
+
21
+ imported
22
+ sources
23
+ EOF
24
+
25
+ def test_should_parse_CHANGESET_to_changeset
26
+ parser = MonotoneLogParser.new
27
+ changeset = parser.parse_changeset(StringIO.new(CHANGESET), {})
28
+
29
+ assert_equal("a2c58e276439de7d9da549870e245776c592c7e8", changeset.revision)
30
+ assert_equal("tester@test.net", changeset.developer)
31
+ assert_equal(Time.utc(2005,3,2,6,32,43), changeset.time)
32
+
33
+ assert_equal(4, changeset.length)
34
+
35
+ assert_equal("build.xml", changeset[0].path)
36
+ assert_equal(Change::ADDED, changeset[0].status)
37
+
38
+ assert_equal("project.xml", changeset[1].path)
39
+ assert_equal(Change::ADDED, changeset[1].status)
40
+
41
+ assert_equal("src/java/com/thoughtworks/damagecontrolled/Thingy.java", changeset[2].path)
42
+ assert_equal(Change::ADDED, changeset[2].status)
43
+
44
+ assert_equal("src/test/com/thoughtworks/damagecontrolled/ThingyTestCase.java", changeset[3].path)
45
+ assert_equal(Change::ADDED, changeset[3].status)
46
+
47
+ assert_equal("imported\nsources", changeset.message)
48
+ end
49
+
50
+ CHANGESETS = <<EOF
51
+ -----------------------------------------------------------------
52
+ Revision: abbe1eb8f75bdf9b27d440340ec329816c13985c
53
+ Author: tester@test.net
54
+ Date: 2005-03-02T06:33:01
55
+
56
+ Modified files:
57
+ build.xml
58
+ src/java/com/thoughtworks/damagecontrolled/Thingy.java
59
+
60
+ ChangeLog:
61
+
62
+ changed
63
+ something
64
+ -----------------------------------------------------------------
65
+ Revision: a2c58e276439de7d9da549870e245776c592c7e8
66
+ Author: tester@test.net
67
+ Date: 2005-03-02T06:32:43
68
+
69
+ Added files:
70
+ build.xml project.xml
71
+ src/java/com/thoughtworks/damagecontrolled/Thingy.java
72
+ src/test/com/thoughtworks/damagecontrolled/ThingyTestCase.java
73
+
74
+ ChangeLog:
75
+
76
+ imported
77
+ sources
78
+ EOF
79
+
80
+ def test_should_parse_CHANGESETS_to_changesets
81
+ parser = MonotoneLogParser.new
82
+ changesets = parser.parse_changesets(StringIO.new(CHANGESETS))
83
+ assert_equal(2, changesets.length)
84
+ changeset = changesets[0]
85
+
86
+ assert_equal("build.xml", changeset[0].path)
87
+ assert_equal(Change::MODIFIED, changeset[0].status)
88
+
89
+ assert_equal("src/java/com/thoughtworks/damagecontrolled/Thingy.java", changeset[1].path)
90
+ assert_equal(Change::MODIFIED, changeset[1].status)
91
+ end
92
+
93
+ def test_should_parse_CHANGESETS_to_changesets_before
94
+ parser = MonotoneLogParser.new
95
+ changesets = parser.parse_changesets(StringIO.new(CHANGESETS), Time.utc(2005,03,02,06,32,43))
96
+ assert_equal(2, changesets.length)
97
+
98
+ changesets = parser.parse_changesets(StringIO.new(CHANGESETS), Time.utc(2005,03,02,06,32,44))
99
+ assert_equal(1, changesets.length)
100
+ end
101
+
102
+ def test_should_parse_CHANGESET_to_changesets
103
+ parser = MonotoneLogParser.new
104
+ changesets = parser.parse_changesets(StringIO.new(CHANGESET))
105
+ assert_equal(1, changesets.length)
106
+ end
107
+
108
+ end
109
+ end
@@ -1,6 +1,6 @@
1
1
  require 'test/unit'
2
+ require 'rscm'
2
3
  require 'rscm/generic_scm_tests'
3
- require 'rscm/monotone/monotone'
4
4
 
5
5
  module RSCM
6
6
  class MonotoneTest < Test::Unit::TestCase