rscm 0.2.1.1404 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +34 -23
- data/Rakefile +24 -29
- data/bin/touch.exe +0 -0
- data/lib/rscm.rb +6 -3
- data/lib/rscm/annotations.rb +26 -7
- data/lib/rscm/{abstract_scm.rb → base.rb} +109 -71
- data/lib/rscm/better.rb +16 -0
- data/lib/rscm/logging.rb +11 -5
- data/lib/rscm/path_converter.rb +9 -16
- data/lib/rscm/revision.rb +201 -0
- data/lib/rscm/revision_file.rb +71 -0
- data/lib/rscm/scm/clearcase.rb +7 -7
- data/lib/rscm/scm/cvs.rb +69 -70
- data/lib/rscm/scm/cvs_log_parser.rb +29 -29
- data/lib/rscm/scm/darcs.rb +82 -34
- data/lib/rscm/scm/darcs_log_parser.rb +65 -0
- data/lib/rscm/scm/monotone.rb +249 -77
- data/lib/rscm/scm/monotone_log_parser.rb +57 -43
- data/lib/rscm/scm/mooky.rb +3 -3
- data/lib/rscm/scm/perforce.rb +196 -134
- data/lib/rscm/scm/star_team.rb +10 -10
- data/lib/rscm/scm/subversion.rb +106 -77
- data/lib/rscm/scm/subversion_log_parser.rb +76 -47
- data/lib/rscm/time_ext.rb +2 -116
- data/test/rscm/annotations_test.rb +15 -2
- data/test/rscm/{abstract_scm_test.rb → base_test.rb} +3 -3
- data/test/rscm/difftool_test.rb +9 -3
- data/test/rscm/generic_scm_tests.rb +195 -124
- data/test/rscm/revision_fixture.rb +20 -0
- data/test/rscm/revision_test.rb +129 -0
- data/test/rscm/{changesets.yaml → revisions.yaml} +10 -10
- data/test/rscm/scm/clearcase.log +608 -0
- data/test/rscm/scm/clearcase_test.rb +39 -0
- data/test/rscm/scm/cvs_log_parser_test.rb +73 -73
- data/test/rscm/scm/cvs_test.rb +1 -1
- data/test/rscm/scm/darcs_log_parser_test.rb +171 -0
- data/test/rscm/scm/monotone_log_parser_test.rb +49 -31
- data/test/rscm/scm/monotone_test.rb +3 -2
- data/test/rscm/scm/p4client_test.rb +33 -0
- data/test/rscm/scm/perforce_test.rb +25 -3
- data/test/rscm/scm/star_team.rb +9 -9
- data/test/rscm/scm/subversion_log_parser_test.rb +107 -47
- metadata +17 -13
- data/lib/multipart.rb +0 -95
- data/lib/rscm/RSS.txt +0 -41
- data/lib/rscm/changes.rb +0 -268
- data/lib/rscm/example.yaml +0 -21
- data/lib/rubyforge_file_publisher.rb +0 -176
- data/test/rscm/changes_fixture.rb +0 -20
- data/test/rscm/changes_test.rb +0 -129
data/lib/rscm/time_ext.rb
CHANGED
@@ -1,125 +1,11 @@
|
|
1
|
-
module RSCM
|
2
|
-
module TimeExt
|
3
|
-
SECOND = 1
|
4
|
-
MINUTE = 60
|
5
|
-
HOUR = 60 * MINUTE
|
6
|
-
DAY = 24 * HOUR
|
7
|
-
WEEK = 7 * DAY
|
8
|
-
MONTH = 30 * DAY
|
9
|
-
YEAR = 365 * DAY
|
10
|
-
YEARS = 2 * YEAR
|
11
|
-
|
12
|
-
def duration_as_text(duration_secs)
|
13
|
-
case duration_secs
|
14
|
-
when 0 then "0 seconds"
|
15
|
-
when SECOND then "#{duration_secs/SECOND} second"
|
16
|
-
when SECOND+1..MINUTE-1 then "#{duration_secs/SECOND} seconds"
|
17
|
-
when MINUTE..2*MINUTE-1 then "#{duration_secs/MINUTE} minute"
|
18
|
-
when 2*MINUTE..HOUR-1 then "#{duration_secs/MINUTE} minutes"
|
19
|
-
when HOUR..2*HOUR-1 then "#{duration_secs/HOUR} hour"
|
20
|
-
when 2*HOUR..DAY-1 then "#{duration_secs/HOUR} hours"
|
21
|
-
when DAY..2*DAY-1 then "#{duration_secs/DAY} day"
|
22
|
-
when 2*DAY..WEEK-1 then "#{duration_secs/DAY} days"
|
23
|
-
when WEEK..2*WEEK-1 then "#{duration_secs/WEEK} week"
|
24
|
-
when 2*WEEK..MONTH-1 then "#{duration_secs/WEEK} weeks"
|
25
|
-
when MONTH..2*MONTH-1 then "#{duration_secs/MONTH} month"
|
26
|
-
when 2*MONTH..YEAR-1 then "#{duration_secs/MONTH} months"
|
27
|
-
when YEAR..2*YEAR-1 then "#{duration_secs/YEAR} year"
|
28
|
-
else "#{duration_secs/YEAR} years"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
module_function :duration_as_text
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# Time mixin that adds some additional utility methods
|
36
1
|
class Time
|
37
|
-
include RSCM::TimeExt
|
38
|
-
|
39
2
|
class << self
|
40
3
|
def epoch
|
41
|
-
Time.utc(
|
4
|
+
Time.utc(1972)
|
42
5
|
end
|
43
6
|
|
44
7
|
def infinity
|
45
|
-
Time.utc(
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def Time.parse_ymdHMS(timestamp_as_ymdHMS)
|
50
|
-
Time.utc(
|
51
|
-
timestamp_as_ymdHMS[0..3], # year
|
52
|
-
timestamp_as_ymdHMS[4..5], # month
|
53
|
-
timestamp_as_ymdHMS[6..7], # day
|
54
|
-
timestamp_as_ymdHMS[8..9], # hour
|
55
|
-
timestamp_as_ymdHMS[10..11], # minute
|
56
|
-
timestamp_as_ymdHMS[12..13] # second
|
57
|
-
)
|
58
|
-
end
|
59
|
-
|
60
|
-
def to_rfc2822
|
61
|
-
utc.strftime("%a, %d %b %Y %H:%M:%S +0000")
|
62
|
-
end
|
63
|
-
|
64
|
-
def to_human
|
65
|
-
utc.strftime("%d %b %Y %H:%M:%S")
|
66
|
-
end
|
67
|
-
|
68
|
-
def ymdHMS
|
69
|
-
utc.strftime("%Y%m%d%H%M%S")
|
70
|
-
end
|
71
|
-
|
72
|
-
def ==(o)
|
73
|
-
return false unless o.is_a?(Time)
|
74
|
-
ymdHMS == o.ymdHMS
|
75
|
-
end
|
76
|
-
|
77
|
-
# In many cases (for example when drawing a graph with
|
78
|
-
# dates along the x-axis) it can be useful to know what
|
79
|
-
# month, week or day a certain timestamp is within.
|
80
|
-
#
|
81
|
-
# This lets you do that. Call with :day, :week or :month
|
82
|
-
# returns period_number, period_start
|
83
|
-
#
|
84
|
-
# period_number is an int representing the day, week or month number of the year.
|
85
|
-
# period_start is a utc time of the start of the period.
|
86
|
-
def get_period_info(interval)
|
87
|
-
case interval
|
88
|
-
when :week then get_week_info
|
89
|
-
when :month then get_month_info
|
90
|
-
when :day then get_day_info
|
8
|
+
Time.utc(2036)
|
91
9
|
end
|
92
10
|
end
|
93
|
-
|
94
|
-
# week_number, week_start_date = get_info(time, :week)
|
95
|
-
def get_week_info
|
96
|
-
first_day_of_year = Time.utc(utc.year, 1, 1)
|
97
|
-
week_day_of_first_day_of_year = first_day_of_year.wday
|
98
|
-
# Sunday = 0, .. Monday = 6
|
99
|
-
first_monday_of_year = Time.utc(utc.year, 1, ((week_day_of_first_day_of_year % 7) + 1))
|
100
|
-
|
101
|
-
week_number = nil
|
102
|
-
week_start_date = nil
|
103
|
-
days = (utc.yday - first_monday_of_year.yday)
|
104
|
-
week_number = (days / 7) + 1
|
105
|
-
week_start_date = first_monday_of_year + ((week_number-1) * 7) * 60 * 60 * 24
|
106
|
-
return week_number, week_start_date
|
107
|
-
end
|
108
|
-
|
109
|
-
# month_number, month_start_date = get_info(time, :month)
|
110
|
-
def get_month_info
|
111
|
-
return month, Time.utc(utc.year, utc.month, 1)
|
112
|
-
end
|
113
|
-
|
114
|
-
# day_number, day_date = get_info(time, :day)
|
115
|
-
def get_day_info
|
116
|
-
return yday, Time.utc(utc.year, utc.month, utc.day)
|
117
|
-
end
|
118
|
-
|
119
|
-
def difference_as_text(t)
|
120
|
-
raise "t must be a time" unless t.is_a?(Time)
|
121
|
-
diff = (self - t).to_i
|
122
|
-
duration_as_text(diff)
|
123
|
-
end
|
124
|
-
|
125
11
|
end
|
@@ -4,16 +4,18 @@ require 'rscm/annotations'
|
|
4
4
|
module RSCM
|
5
5
|
class Whatever
|
6
6
|
attr_accessor :no_annotation
|
7
|
+
|
7
8
|
ann :boo => "huba luba", :pip => "pip pip"
|
8
9
|
attr_accessor :foo
|
9
10
|
|
10
11
|
ann :desc => "bang bang"
|
11
12
|
ann :tip => "a top tip"
|
12
|
-
attr_accessor :bar, :zap
|
13
|
+
attr_accessor :bar, :zap, :titi
|
13
14
|
end
|
14
15
|
|
15
16
|
class Other
|
16
17
|
attr_accessor :no_annotation
|
18
|
+
|
17
19
|
ann :boo => "boo"
|
18
20
|
ann :pip => "pip"
|
19
21
|
attr_accessor :foo
|
@@ -23,6 +25,8 @@ module RSCM
|
|
23
25
|
end
|
24
26
|
|
25
27
|
class Subclass < Other
|
28
|
+
ann :desc => "desc", :tip => "tip"
|
29
|
+
attr_accessor :other
|
26
30
|
end
|
27
31
|
|
28
32
|
class AnnotationsTest < Test::Unit::TestCase
|
@@ -51,7 +55,16 @@ module RSCM
|
|
51
55
|
def test_should_inherit_attribute_annotations
|
52
56
|
assert_equal("boo", Subclass.foo[:boo])
|
53
57
|
assert_equal({:boo => "boo", :pip => "pip"}, Subclass.send("foo"))
|
54
|
-
|
58
|
+
assert_equal({}, Whatever.send("no_annotation"))
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_should_get_annotations_from_object
|
62
|
+
assert_equal({:boo => "huba luba", :pip => "pip pip"}, Whatever.new.anns("foo"))
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_should_get_annotations_from_class
|
66
|
+
assert_equal(["@bar", "@foo", "@no_annotation", "@other", "@zap"], Subclass.new.__attr_accessors)
|
55
67
|
end
|
68
|
+
|
56
69
|
end
|
57
70
|
end
|
data/test/rscm/difftool_test.rb
CHANGED
@@ -8,6 +8,13 @@ module Test
|
|
8
8
|
# assertion method that reports differences as diff.
|
9
9
|
# useful when comparing big strings
|
10
10
|
def assert_equal_with_diff(expected, actual)
|
11
|
+
diff(expected, actual) do |diff_io|
|
12
|
+
diff_string = diff_io.read
|
13
|
+
assert_equal("", diff_string, diff_string)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def diff(expected, actual, &block)
|
11
18
|
dir = RSCM.new_temp_dir("diff")
|
12
19
|
|
13
20
|
expected_file = "#{dir}/expected"
|
@@ -17,8 +24,7 @@ module Test
|
|
17
24
|
|
18
25
|
difftool = WINDOWS ? File.dirname(__FILE__) + "/../../bin/diff.exe" : "diff"
|
19
26
|
IO.popen("#{difftool} #{RSCM::PathConverter.filepath_to_nativepath(expected_file, false)} #{RSCM::PathConverter.filepath_to_nativepath(actual_file, false)}") do |io|
|
20
|
-
|
21
|
-
assert_equal("", diff, diff)
|
27
|
+
yield io
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
@@ -26,7 +32,7 @@ module Test
|
|
26
32
|
end
|
27
33
|
|
28
34
|
module RSCM
|
29
|
-
class
|
35
|
+
class DifftoolTest < Test::Unit::TestCase
|
30
36
|
def test_diffing_fails_with_diff_when_different
|
31
37
|
assert_raises(Test::Unit::AssertionFailedError) {
|
32
38
|
assert_equal_with_diff("This is a\nmessage with\nsome text", "This is a\nmessage without\nsome text")
|
@@ -1,51 +1,69 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'rscm/tempdir'
|
3
3
|
require 'rscm/path_converter'
|
4
|
+
require 'rscm/difftool_test'
|
4
5
|
|
5
6
|
module RSCM
|
6
7
|
|
7
8
|
module GenericSCMTests
|
8
9
|
include FileUtils
|
9
10
|
|
10
|
-
|
11
|
+
def teardown
|
12
|
+
@scm.destroy_central if @scm
|
13
|
+
end
|
14
|
+
|
15
|
+
# Acceptance test for scm implementations
|
11
16
|
#
|
12
|
-
# 1) Create a
|
13
|
-
# 2) Import a test project
|
14
|
-
# 3) Verify that
|
15
|
-
# 4) Check out to
|
17
|
+
# 1) Create a central repository
|
18
|
+
# 2) Import a test project to the central repository
|
19
|
+
# 3) Verify that WorkingCopy is not uptodate (not yet checked out)
|
20
|
+
# 4) Check out the contents of the central repo to WorkingCopy
|
16
21
|
# 5) Verify that the checked out files were those imported
|
17
|
-
# 6) Verify that the initial total
|
18
|
-
# 7) Verify that
|
19
|
-
# 8) Change some files in
|
20
|
-
# 9) Check out to
|
21
|
-
# 10) Verify that
|
22
|
-
# 11) Verify that
|
23
|
-
# 12) Commit modifications in
|
24
|
-
# 13) Verify that
|
25
|
-
# 14) Verify that
|
26
|
-
# 15) Check out
|
27
|
-
# 16) Verify that
|
28
|
-
# 17) Add and commit a file in
|
29
|
-
# 18) Verify that the
|
22
|
+
# 6) Verify that the initial total revisions (from epoch to infinity) represents those from the import
|
23
|
+
# 7) Verify that WorkingCopy is uptodate
|
24
|
+
# 8) Change some files in WorkingCopy without committing them (yet)
|
25
|
+
# 9) Check out the contents of the central repo to OtherWorkingCopy
|
26
|
+
# 10) Verify that OtherWorkingCopy is uptodate
|
27
|
+
# 11) Verify that WorkingCopy is uptodate
|
28
|
+
# 12) Commit modifications in WorkingCopy
|
29
|
+
# 13) Verify that there is one revision since the previous one, and that it corresponds to the changed files in 8.
|
30
|
+
# 14) Verify that OtherWorkingCopy is *not* uptodate
|
31
|
+
# 15) Check out OtherWorkingCopy
|
32
|
+
# 16) Verify that OtherWorkingCopy is now uptodate
|
33
|
+
# 17) Add and commit a file in WorkingCopy
|
34
|
+
# 18) Verify that the revision (since last revision) for CheckoutHereToo contains only one file
|
30
35
|
def test_basics
|
31
36
|
work_dir = RSCM.new_temp_dir("basics")
|
32
|
-
checkout_dir = "#{work_dir}/
|
33
|
-
other_checkout_dir = "#{work_dir}/
|
37
|
+
checkout_dir = "#{work_dir}/WorkingCopy"
|
38
|
+
other_checkout_dir = "#{work_dir}/OtherWorkingCopy"
|
34
39
|
repository_dir = "#{work_dir}/repository"
|
35
|
-
scm = create_scm(repository_dir, "damagecontrolled")
|
36
|
-
scm.
|
40
|
+
scm = create_scm(repository_dir, "damagecontrolled")
|
41
|
+
scm.checkout_dir = checkout_dir
|
42
|
+
|
43
|
+
other_scm = create_scm(repository_dir, "damagecontrolled")
|
44
|
+
other_scm.checkout_dir = other_checkout_dir
|
45
|
+
|
46
|
+
raise "This scm (#{scm.name}) can't create 'central' repositories." unless scm.can_create_central?
|
47
|
+
|
48
|
+
# 1
|
49
|
+
scm.create_central
|
50
|
+
@scm = scm
|
37
51
|
assert(scm.name)
|
38
52
|
|
53
|
+
# 2
|
39
54
|
import_damagecontrolled(scm, "#{work_dir}/damagecontrolled")
|
40
|
-
|
41
|
-
#
|
42
|
-
assert(!scm.uptodate?(
|
43
|
-
assert(!scm.uptodate?(
|
55
|
+
|
56
|
+
# 3
|
57
|
+
assert(!scm.uptodate?(nil))
|
58
|
+
assert(!scm.uptodate?(nil))
|
59
|
+
|
60
|
+
# 4
|
44
61
|
yielded_files = []
|
45
|
-
files = scm.checkout
|
62
|
+
files = scm.checkout do |file_name|
|
46
63
|
yielded_files << file_name
|
47
64
|
end
|
48
|
-
|
65
|
+
|
66
|
+
# 5
|
49
67
|
assert_equal(4, files.length)
|
50
68
|
assert_equal(files, yielded_files)
|
51
69
|
files.sort!
|
@@ -57,102 +75,141 @@ module RSCM
|
|
57
75
|
assert_equal("src/java/com/thoughtworks/damagecontrolled/Thingy.java", files[2])
|
58
76
|
assert_equal("src/test/com/thoughtworks/damagecontrolled/ThingyTestCase.java", files[3])
|
59
77
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
assert_equal(
|
65
|
-
|
78
|
+
# 6
|
79
|
+
initial_revisions = scm.revisions(nil, nil)
|
80
|
+
assert_equal(1, initial_revisions.length)
|
81
|
+
initial_revision = initial_revisions[0]
|
82
|
+
assert_equal("imported\nsources", initial_revision.message)
|
83
|
+
assert_equal(4, initial_revision.length)
|
84
|
+
|
85
|
+
# 7
|
86
|
+
assert(scm.uptodate?(initial_revisions.latest.identifier))
|
66
87
|
|
67
|
-
#
|
88
|
+
# 8
|
68
89
|
change_file(scm, "#{checkout_dir}/build.xml")
|
69
90
|
change_file(scm, "#{checkout_dir}/src/java/com/thoughtworks/damagecontrolled/Thingy.java")
|
70
91
|
|
71
|
-
|
72
|
-
|
73
|
-
|
92
|
+
# 9
|
93
|
+
other_scm.checkout
|
94
|
+
# 10
|
95
|
+
assert(other_scm.uptodate?(nil))
|
96
|
+
# 11
|
97
|
+
assert(scm.uptodate?(nil))
|
98
|
+
# 12
|
99
|
+
scm.commit("changed\nsomething")
|
74
100
|
|
75
|
-
|
101
|
+
# 13
|
102
|
+
revisions = scm.revisions(initial_revisions.latest.identifier)
|
103
|
+
assert(revisions[0].identifier)
|
104
|
+
assert_equal(1, revisions.length, revisions.collect{|cs| cs.to_s})
|
105
|
+
revision = revisions[0]
|
106
|
+
assert_equal(2, revision.length)
|
76
107
|
|
77
|
-
|
78
|
-
changesets = scm.changesets(checkout_dir, initial_changesets.time + 1)
|
79
|
-
|
80
|
-
assert_equal(1, changesets.length, changesets.collect{|cs| cs.to_s})
|
81
|
-
changeset = changesets[0]
|
82
|
-
assert_equal(2, changeset.length)
|
83
|
-
|
84
|
-
assert_equal("changed\nsomething", changeset.message)
|
108
|
+
assert_equal("changed\nsomething", revision.message)
|
85
109
|
|
86
110
|
# why is this nil when running as the dcontrol user on codehaus? --jon
|
87
|
-
#assert_equal(username,
|
88
|
-
assert(
|
89
|
-
assert(
|
90
|
-
|
91
|
-
assert_equal("build.xml",
|
92
|
-
assert(
|
93
|
-
assert(
|
94
|
-
assert_equal("src/java/com/thoughtworks/damagecontrolled/Thingy.java",
|
95
|
-
assert(
|
96
|
-
assert(
|
97
|
-
|
98
|
-
|
99
|
-
assert(!
|
100
|
-
assert(
|
101
|
-
assert(scm.uptodate?(
|
102
|
-
|
103
|
-
|
111
|
+
#assert_equal(username, revision.developer)
|
112
|
+
assert(revision.developer)
|
113
|
+
assert(revision.identifier)
|
114
|
+
|
115
|
+
assert_equal("build.xml", revision[0].path)
|
116
|
+
assert(revision[0].native_revision_identifier)
|
117
|
+
assert(revision[0].previous_native_revision_identifier)
|
118
|
+
assert_equal("src/java/com/thoughtworks/damagecontrolled/Thingy.java", revision[1].path)
|
119
|
+
assert(revision[1].native_revision_identifier)
|
120
|
+
assert(revision[1].previous_native_revision_identifier)
|
121
|
+
|
122
|
+
# 14
|
123
|
+
assert(!other_scm.uptodate?(revisions.latest.identifier))
|
124
|
+
assert(!other_scm.uptodate?(revisions.latest.identifier))
|
125
|
+
assert(scm.uptodate?(revisions.latest.identifier))
|
126
|
+
assert(scm.uptodate?(revisions.latest.identifier))
|
127
|
+
|
128
|
+
# 15
|
129
|
+
files = other_scm.checkout.sort
|
104
130
|
assert_equal(2, files.length)
|
105
131
|
assert_equal("build.xml", files[0])
|
106
132
|
assert_equal("src/java/com/thoughtworks/damagecontrolled/Thingy.java", files[1])
|
107
133
|
|
108
|
-
|
109
|
-
|
134
|
+
# 16
|
135
|
+
assert(other_scm.uptodate?(nil))
|
110
136
|
add_or_edit_and_commit_file(scm, checkout_dir, "src/java/com/thoughtworks/damagecontrolled/Hello.txt", "Bla bla")
|
111
|
-
assert(!
|
112
|
-
|
113
|
-
assert_equal(1,
|
114
|
-
assert_equal(1,
|
115
|
-
assert("src/java/com/thoughtworks/damagecontrolled/Hello.txt",
|
116
|
-
assert("src/java/com/thoughtworks/damagecontrolled/Hello.txt",
|
137
|
+
assert(!other_scm.uptodate?(nil))
|
138
|
+
revisions = other_scm.revisions(revisions.latest.identifier)
|
139
|
+
assert_equal(1, revisions.length)
|
140
|
+
assert_equal(1, revisions[0].length)
|
141
|
+
assert("src/java/com/thoughtworks/damagecontrolled/Hello.txt", revisions[0][0].path)
|
142
|
+
assert("src/java/com/thoughtworks/damagecontrolled/Hello.txt", other_scm.checkout.sort[0])
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_create_destroy
|
146
|
+
work_dir = RSCM.new_temp_dir("create_destroy")
|
147
|
+
checkout_dir = "#{work_dir}/checkout"
|
148
|
+
repository_dir = "#{work_dir}/repository"
|
149
|
+
scm = create_scm(repository_dir, "killme")
|
150
|
+
scm.checkout_dir = checkout_dir
|
151
|
+
|
152
|
+
(1..3).each do
|
153
|
+
assert(!scm.central_exists?)
|
154
|
+
scm.create_central
|
155
|
+
assert(scm.central_exists?)
|
156
|
+
scm.destroy_central
|
157
|
+
end
|
158
|
+
|
159
|
+
assert(!scm.central_exists?)
|
117
160
|
end
|
118
161
|
|
119
162
|
def test_trigger
|
120
163
|
work_dir = RSCM.new_temp_dir("trigger")
|
121
|
-
|
122
|
-
checkout_dir = "#{work_dir}/#{path}/checkout"
|
164
|
+
checkout_dir = "#{work_dir}/checkout"
|
123
165
|
repository_dir = "#{work_dir}/repository"
|
124
|
-
|
125
|
-
scm
|
166
|
+
trigger_proof = "#{work_dir}/trigger_proof"
|
167
|
+
scm = create_scm(repository_dir, "damagecontrolled")
|
168
|
+
scm.checkout_dir = checkout_dir
|
169
|
+
scm.create_central
|
170
|
+
@scm = scm
|
126
171
|
|
172
|
+
# Verify that install/uninstall works
|
173
|
+
touch = WINDOWS ? PathConverter.filepath_to_nativepath(File.dirname(__FILE__) + "../../bin/touch.exe", false) : "touch"
|
174
|
+
trigger_command = "#{touch} " + PathConverter.filepath_to_nativepath(trigger_proof, false)
|
127
175
|
trigger_files_checkout_dir = File.expand_path("#{checkout_dir}/../trigger")
|
128
|
-
|
129
|
-
(1..3).each do
|
176
|
+
(1..3).each do |i|
|
130
177
|
assert(!scm.trigger_installed?(trigger_command, trigger_files_checkout_dir))
|
131
178
|
scm.install_trigger(trigger_command, trigger_files_checkout_dir)
|
132
179
|
assert(scm.trigger_installed?(trigger_command, trigger_files_checkout_dir))
|
133
180
|
scm.uninstall_trigger(trigger_command, trigger_files_checkout_dir)
|
134
181
|
end
|
182
|
+
|
183
|
+
# Verify that the trigger works
|
184
|
+
import_damagecontrolled(scm, "#{work_dir}/damagecontrolled")
|
185
|
+
scm.checkout
|
186
|
+
scm.install_trigger(trigger_command, trigger_files_checkout_dir)
|
187
|
+
assert(!File.exist?(trigger_proof))
|
188
|
+
|
189
|
+
add_or_edit_and_commit_file(scm, checkout_dir, "afile", "boo")
|
190
|
+
assert(File.exist?(trigger_proof))
|
135
191
|
end
|
136
192
|
|
137
|
-
def
|
138
|
-
work_dir = RSCM.new_temp_dir("
|
193
|
+
def test_checkout_revision_identifier
|
194
|
+
work_dir = RSCM.new_temp_dir("ids")
|
139
195
|
checkout_dir = "#{work_dir}/checkout"
|
140
196
|
repository_dir = "#{work_dir}/repository"
|
141
197
|
scm = create_scm(repository_dir, "damagecontrolled")
|
142
|
-
scm.
|
198
|
+
scm.checkout_dir = checkout_dir
|
199
|
+
scm.create_central
|
200
|
+
@scm = scm
|
143
201
|
|
144
202
|
import_damagecontrolled(scm, "#{work_dir}/damagecontrolled")
|
145
|
-
scm.checkout
|
203
|
+
scm.checkout
|
146
204
|
add_or_edit_and_commit_file(scm, checkout_dir, "before.txt", "Before label")
|
147
|
-
before_cs = scm.
|
205
|
+
before_cs = scm.revisions(Time.epoch)
|
148
206
|
|
149
207
|
add_or_edit_and_commit_file(scm, checkout_dir, "after.txt", "After label")
|
150
|
-
|
151
|
-
after_cs = scm.changesets(checkout_dir, next_identifier)
|
208
|
+
after_cs = scm.revisions(before_cs.latest.identifier)
|
152
209
|
assert_equal(1, after_cs.length)
|
153
210
|
assert_equal("after.txt", after_cs[0][0].path)
|
154
211
|
|
155
|
-
scm.checkout(
|
212
|
+
scm.checkout(before_cs.latest.identifier)
|
156
213
|
|
157
214
|
assert(File.exist?("#{checkout_dir}/before.txt"))
|
158
215
|
assert(!File.exist?("#{checkout_dir}/after.txt"))
|
@@ -164,51 +221,63 @@ module RSCM
|
|
164
221
|
assert_same(scm.class, scm2.class)
|
165
222
|
end
|
166
223
|
|
167
|
-
|
224
|
+
EXPECTED_DIFF = <<EOF
|
225
|
+
-one two three
|
226
|
+
-four five six
|
227
|
+
+one two three four
|
228
|
+
+five six
|
229
|
+
EOF
|
230
|
+
|
231
|
+
def test_diffs
|
168
232
|
work_dir = RSCM.new_temp_dir("diff")
|
169
|
-
|
170
|
-
checkout_dir = "#{work_dir}/#{path}/checkout"
|
233
|
+
checkout_dir = "#{work_dir}/checkout"
|
171
234
|
repository_dir = "#{work_dir}/repository"
|
172
235
|
import_dir = "#{work_dir}/import/diffing"
|
173
|
-
scm = create_scm(repository_dir,
|
174
|
-
scm.
|
236
|
+
scm = create_scm(repository_dir, "diffing")
|
237
|
+
scm.checkout_dir = checkout_dir
|
238
|
+
scm.create_central
|
239
|
+
@scm = scm
|
175
240
|
|
176
241
|
mkdir_p(import_dir)
|
177
242
|
File.open("#{import_dir}/afile.txt", "w") do |io|
|
243
|
+
io.puts("just some")
|
244
|
+
io.puts("initial content")
|
245
|
+
end
|
246
|
+
scm.import_central(import_dir, "Initial revision")
|
247
|
+
scm.checkout
|
248
|
+
initial_revision = scm.revisions(nil).latest
|
249
|
+
sleep(1)
|
250
|
+
|
251
|
+
scm.edit("#{checkout_dir}/afile.txt")
|
252
|
+
File.open("#{checkout_dir}/afile.txt", "w") do |io|
|
178
253
|
io.puts("one two three")
|
179
254
|
io.puts("four five six")
|
180
255
|
end
|
181
|
-
|
182
|
-
|
183
|
-
end
|
184
|
-
|
185
|
-
scm.import(import_dir, "Imported a file to diff against")
|
186
|
-
scm.checkout(checkout_dir)
|
256
|
+
scm.commit("Modified existing file")
|
257
|
+
sleep(1)
|
187
258
|
|
188
259
|
scm.edit("#{checkout_dir}/afile.txt")
|
189
260
|
File.open("#{checkout_dir}/afile.txt", "w") do |io|
|
190
261
|
io.puts("one two three four")
|
191
262
|
io.puts("five six")
|
192
263
|
end
|
193
|
-
|
194
|
-
io.puts("one quick brown")
|
195
|
-
io.puts("fox jumped over")
|
196
|
-
end
|
197
|
-
scm.commit(checkout_dir, "Modified file to diff")
|
264
|
+
scm.commit("Modified same file again")
|
198
265
|
|
199
|
-
scm.
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
io.puts("four five six")
|
204
|
-
end
|
205
|
-
File.open("#{checkout_dir}/anotherfile.txt", "w") do |io|
|
206
|
-
io.puts("one quick brown")
|
207
|
-
io.puts("fox jumped over the lazy dog")
|
208
|
-
end
|
209
|
-
scm.commit(checkout_dir, "Modified file to diff again")
|
266
|
+
revisions = scm.revisions(initial_revision.identifier)
|
267
|
+
assert_equal(2, revisions.length)
|
268
|
+
assert_equal("Modified existing file", revisions[0].message)
|
269
|
+
assert_equal("Modified same file again", revisions[1].message)
|
210
270
|
|
211
|
-
|
271
|
+
got_diff = false
|
272
|
+
scm.diff(revisions[1][0]) do |diff_io|
|
273
|
+
got_diff = true
|
274
|
+
diff_string = diff_io.read
|
275
|
+
assert_match(/^\-one two three/, diff_string)
|
276
|
+
assert_match(/^\-four five six/, diff_string)
|
277
|
+
assert_match(/^\+one two three four/, diff_string)
|
278
|
+
assert_match(/^\+five six/, diff_string)
|
279
|
+
end
|
280
|
+
assert(got_diff)
|
212
281
|
end
|
213
282
|
|
214
283
|
private
|
@@ -221,7 +290,7 @@ module RSCM
|
|
221
290
|
cp_r(path, dirname)
|
222
291
|
todelete = Dir.glob("#{import_copy_dir}/**/.svn")
|
223
292
|
rm_rf(todelete)
|
224
|
-
scm.
|
293
|
+
scm.import_central(import_copy_dir, "imported\nsources")
|
225
294
|
end
|
226
295
|
|
227
296
|
def change_file(scm, file)
|
@@ -240,12 +309,12 @@ module RSCM
|
|
240
309
|
File.open(absolute_path, "w") do |file|
|
241
310
|
file.puts(content)
|
242
311
|
end
|
243
|
-
scm.add(
|
312
|
+
scm.add(relative_filename) unless existed
|
244
313
|
|
245
314
|
message = existed ? "editing" : "adding"
|
246
315
|
|
247
316
|
sleep(1)
|
248
|
-
scm.commit(
|
317
|
+
scm.commit("#{message} #{relative_filename}")
|
249
318
|
end
|
250
319
|
end
|
251
320
|
|
@@ -255,23 +324,25 @@ module RSCM
|
|
255
324
|
checkout_dir = "#{work_dir}/LabelTest"
|
256
325
|
repository_dir = "#{work_dir}/repository"
|
257
326
|
scm = create_scm(repository_dir, "damagecontrolled")
|
258
|
-
scm.
|
327
|
+
scm.checkout_dir = checkout_dir
|
328
|
+
scm.create_central
|
329
|
+
@scm = scm
|
259
330
|
|
260
331
|
import_damagecontrolled(scm, "#{work_dir}/damagecontrolled")
|
261
332
|
|
262
|
-
scm.checkout
|
333
|
+
scm.checkout
|
263
334
|
|
264
335
|
# TODO: introduce a Revision class which implements comparator methods
|
265
336
|
assert_equal(
|
266
337
|
"1",
|
267
|
-
scm.label
|
338
|
+
scm.label
|
268
339
|
)
|
269
340
|
change_file(scm, "#{checkout_dir}/build.xml")
|
270
|
-
scm.commit(
|
271
|
-
scm.checkout
|
341
|
+
scm.commit("changed something")
|
342
|
+
scm.checkout
|
272
343
|
assert_equal(
|
273
344
|
"2",
|
274
|
-
scm.label
|
345
|
+
scm.label
|
275
346
|
)
|
276
347
|
end
|
277
348
|
end
|
@@ -279,4 +350,4 @@ module RSCM
|
|
279
350
|
module ApplyLabelTest
|
280
351
|
|
281
352
|
end
|
282
|
-
end
|
353
|
+
end
|