rscm 0.4.5 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. data/CHANGES +12 -0
  2. data/README +14 -0
  3. data/Rakefile +4 -24
  4. data/lib/rscm.rb +1 -2
  5. data/lib/rscm/base.rb +289 -281
  6. data/lib/rscm/command_line.rb +135 -112
  7. data/lib/rscm/revision.rb +63 -166
  8. data/lib/rscm/revision_file.rb +8 -2
  9. data/lib/rscm/revision_poller.rb +78 -67
  10. data/lib/rscm/revisions.rb +79 -0
  11. data/lib/rscm/scm/clearcase.rb +11 -9
  12. data/lib/rscm/scm/cvs.rb +374 -352
  13. data/lib/rscm/scm/cvs_log_parser.rb +1 -0
  14. data/lib/rscm/scm/darcs.rb +9 -0
  15. data/lib/rscm/scm/perforce.rb +216 -149
  16. data/lib/rscm/scm/subversion.rb +44 -24
  17. data/lib/rscm/scm/subversion_log_parser.rb +37 -51
  18. data/lib/rscm/time_ext.rb +0 -1
  19. data/lib/rscm/version.rb +2 -2
  20. data/test/rscm/command_line_test.rb +7 -5
  21. data/test/rscm/compatibility/config.yml +4 -4
  22. data/test/rscm/compatibility/cvs_metaproject/diff.txt +52 -0
  23. data/test/rscm/compatibility/cvs_metaproject/file.txt +48 -0
  24. data/test/rscm/compatibility/cvs_metaproject/old.yml +13 -0
  25. data/test/rscm/compatibility/full.rb +2 -223
  26. data/test/rscm/compatibility/p4_gfx/files_0.yml +10 -0
  27. data/test/rscm/compatibility/p4_gfx/old.yml +26 -0
  28. data/test/rscm/compatibility/p4_gfx/revisions.yml +24 -0
  29. data/test/rscm/compatibility/p4_gfx/scm.yml +4 -0
  30. data/test/rscm/compatibility/rscm_engine.rb +197 -0
  31. data/test/rscm/compatibility/subversion_rscm/diff.txt +12 -0
  32. data/test/rscm/compatibility/subversion_rscm/file.txt +567 -0
  33. data/test/rscm/compatibility/subversion_rscm/old.yml +14 -0
  34. data/test/rscm/compatibility/subversion_rscm/revisions.yml +17 -0
  35. data/test/rscm/compatibility/subversion_rscm/scm.yml +1 -0
  36. data/test/rscm/revision_file_test.rb +10 -0
  37. data/test/rscm/revision_poller_test.rb +91 -0
  38. data/test/rscm/revision_test.rb +22 -117
  39. data/test/rscm/revisions_test.rb +80 -0
  40. data/test/rscm/scm/cvs_log_parser_test.rb +569 -567
  41. data/test/rscm/scm/cvs_test.rb +6 -3
  42. data/test/rscm/scm/darcs_test.rb +4 -7
  43. data/test/rscm/scm/perforce_test.rb +6 -2
  44. data/test/rscm/scm/star_team_test.rb +10 -0
  45. data/test/rscm/scm/subversion_log_parser_test.rb +38 -5
  46. data/test/rscm/scm/subversion_test.rb +2 -3
  47. data/test/rscm/test_helper.rb +41 -2
  48. data/testproject/damagecontrolled/build.xml +154 -154
  49. data/testproject/damagecontrolled/src/java/com/thoughtworks/damagecontrolled/Thingy.java +6 -6
  50. metadata +19 -7
  51. data/lib/rscm/historic_file.rb +0 -30
  52. data/test/rscm/compatibility/damage_control_minimal.rb +0 -104
  53. data/test/rscm/revision_fixture.rb +0 -20
  54. data/test/rscm/revisions.yaml +0 -42
  55. data/test/rscm/scm/star_team.rb +0 -36
@@ -1,13 +1,17 @@
1
1
  require 'rscm/parser'
2
2
  require 'rscm/revision'
3
+ require 'rscm/revisions'
4
+ require 'rscm/revision_file'
5
+ require 'time'
3
6
 
4
7
  module RSCM
5
8
 
6
9
  class SubversionLogParser
7
- def initialize(io, url, exclude_below=nil, path=nil)
10
+ def initialize(io, url, exclude_below_and_including=nil, exclude_above_and_including=nil, path=nil)
8
11
  @io = io
9
12
  @revision_parser = SubversionLogEntryParser.new(url, path)
10
- @exclude_below = exclude_below
13
+ @exclude_below_and_including = exclude_below_and_including
14
+ @exclude_above_and_including = exclude_above_and_including
11
15
  end
12
16
 
13
17
  def parse_revisions(&line_proc)
@@ -16,16 +20,24 @@ module RSCM
16
20
  revisions = Revisions.new
17
21
  while(!@io.eof?)
18
22
  revision = @revision_parser.parse(@io, &line_proc)
19
- if(revision)
23
+ unless(revision.nil?)
20
24
  # Filter out the lower bound to avoid inclusiveness of the lower bound (see contract)
21
25
  # We're doing this instead of increasing the from_identifer with 1, since that causes an error.
22
- exclude = false
23
- if(@exclude_below.is_a? Time)
24
- exclude = revision.time <= @exclude_below
25
- elsif(@exclude_below.is_a? Numeric)
26
- exclude = revision.identifier <= @exclude_below
26
+ too_low = false
27
+ too_high = false
28
+ next if revision.time.nil?
29
+ if(@exclude_below_and_including.is_a? Time)
30
+ too_low = revision.time <= @exclude_below_and_including
31
+ elsif(@exclude_below_and_including.is_a? Numeric)
32
+ too_low = revision.identifier <= @exclude_below_and_including
27
33
  end
28
- revisions.add(revision) unless exclude
34
+
35
+ if(@exclude_above_and_including.is_a? Time)
36
+ too_high = revision.time >= @exclude_above_and_including
37
+ elsif(@exclude_above_and_including.is_a? Numeric)
38
+ too_high = revision.identifier >= @exclude_above_and_including
39
+ end
40
+ revisions.add(revision) unless too_low || too_high
29
41
  end
30
42
  end
31
43
  revisions
@@ -61,8 +73,13 @@ module RSCM
61
73
  end
62
74
  max_similar -= 1
63
75
  end
76
+
64
77
  if(max_similar == 0)
65
- nil
78
+ if(@path.nil? || @path == "")
79
+ path_from_root
80
+ else
81
+ nil
82
+ end
66
83
  else
67
84
  path_from_root_tokens[max_similar..-1].join("/")
68
85
  end
@@ -79,10 +96,10 @@ module RSCM
79
96
  @parse_state = :parse_files
80
97
  elsif(@parse_state == :parse_files)
81
98
  file = parse_file(line)
82
- if(file)
99
+ if(file && file.path)
83
100
  previously_added_file = @revision[-1]
84
101
  if(previously_added_file)
85
- # remove previous revision_file it if it's a dir
102
+ # remove previous revision_file if it's a dir
86
103
  previous_tokens = previously_added_file.path.split("/")
87
104
  current_tokens = file.path.split("/")
88
105
  current_tokens.pop
@@ -90,7 +107,7 @@ module RSCM
90
107
  @revision.pop
91
108
  end
92
109
  end
93
- @revision << file
110
+ @revision.add file
94
111
  end
95
112
  elsif(@parse_state == :parse_message)
96
113
  @revision.message << line.chomp << "\n"
@@ -112,8 +129,10 @@ module RSCM
112
129
  @revision.message = ""
113
130
  revision, developer, time, the_rest = line.split("|")
114
131
  @revision.identifier = revision.strip[1..-1].to_i unless revision.nil?
115
- @revision.developer = developer.strip unless developer.nil?
116
- @revision.time = parse_time(time.strip) unless time.nil?
132
+ developer.strip!
133
+ @revision.developer = developer unless developer.nil? || developer == "(no author)"
134
+ time.strip!
135
+ @revision.time = Time.parse(time).utc unless time.nil? || time == "(no date)"
117
136
  end
118
137
 
119
138
  def parse_file(line)
@@ -133,47 +152,14 @@ module RSCM
133
152
  path_from_root.gsub!(/\\/, "/")
134
153
  path_from_root = path_from_root[1..-1]
135
154
  rp = relative_path(@url, path_from_root)
136
- if rp.nil?
137
- if !@path.nil?
138
- file.path = path_from_root[@path.length..-1]
139
- else
140
- return
141
- end
142
- else
143
- file.path = rp
144
- end
145
-
155
+ return if rp.nil?
156
+
157
+ file.path = rp
146
158
  file.native_revision_identifier = @revision.identifier
147
159
  # http://jira.codehaus.org/browse/DC-204
148
160
  file.previous_native_revision_identifier = file.native_revision_identifier.to_i - 1;
149
161
  file
150
162
  end
151
-
152
- def parse_time(svn_time)
153
- if(svn_time =~ /(.*)-(.*)-(.*) (.*):(.*):(.*) (\+|\-)([0-9]*) (.*)/)
154
- year = $1.to_i
155
- month = $2.to_i
156
- day = $3.to_i
157
- hour = $4.to_i
158
- min = $5.to_i
159
- sec = $6.to_i
160
- time = Time.utc(year, month, day, hour, min, sec)
161
-
162
- time = adjust_offset(time, $7, $8)
163
- else
164
- raise "unexpected time format"
165
- end
166
- end
167
-
168
- def adjust_offset(time, sign, offset)
169
- hour_offset = offset[0..1].to_i
170
- min_offset = offset[2..3].to_i
171
- sec_offset = 3600*hour_offset + 60*min_offset
172
- sec_offset = -sec_offset if(sign == "+")
173
- time += sec_offset
174
- time
175
- end
176
-
177
163
  end
178
164
 
179
165
  end
@@ -7,6 +7,5 @@ class Time
7
7
  def infinity
8
8
  Time.utc(2036)
9
9
  end
10
-
11
10
  end
12
11
  end
@@ -1,8 +1,8 @@
1
1
  module RSCM
2
2
  module VERSION
3
3
  MAJOR = 0
4
- MINOR = 4
5
- TINY = 5
4
+ MINOR = 5
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
 
@@ -1,5 +1,4 @@
1
- require 'test/unit'
2
- require 'rscm/tempdir'
1
+ require File.dirname(__FILE__) + '/test_helper'
3
2
  require 'rscm/command_line'
4
3
 
5
4
  module RSCM
@@ -14,17 +13,20 @@ module RSCM
14
13
  File.delete @stderr if File.exist? @stderr
15
14
  end
16
15
 
17
- def test_should_write_to_both_when_both_streams_specified_and_no_block
16
+ def test_should_write_to_both_files_when_both_files_specified_and_no_block
18
17
  setup_dir(method_name)
19
18
  CommandLine.execute("echo \"<hello\" && echo world", {:dir => @dir, :stdout => @stdout, :stderr => @stderr})
20
19
  assert_match(/.* echo \"<hello\"\s*\n.?\<hello.?\s*\n.* echo world\s*\nworld/n, File.open(@stdout).read)
21
20
  assert_match(/.* echo \"<hello\"\s*\n.* echo world\s*/n, File.open(@stderr).read)
22
21
  end
23
22
 
24
- def test_should_not_write_to_stdout_when_no_stdout_specified
23
+ def test_should_not_write_to_stdout_file_when_no_stdout_specified
25
24
  setup_dir(method_name)
25
+ orgout = STDOUT.dup
26
+ STDOUT.reopen(@stdout)
26
27
  CommandLine.execute("echo hello", {:dir => @dir, :stderr => @stderr})
27
- assert(!File.exist?(@stdout))
28
+ STDOUT.reopen(orgout)
29
+ assert_equal("#{@prompt} echo hello\nhello", File.open(@stdout).read.strip)
28
30
  assert_equal("#{@prompt} echo hello", File.open(@stderr).read.strip)
29
31
  end
30
32
 
@@ -1,4 +1,4 @@
1
- ---
2
- RSCM::SubversionTest: subversion_rscm
3
- RSCM::CvsTest: cvs_metaproject
4
- RSCM::PerforceTest: put your perforce dir here
1
+ ---
2
+ RSCM::SubversionTest: subversion_rscm
3
+ RSCM::CvsTest: cvs_metaproject
4
+ RSCM::PerforceTest: p4_gfx
@@ -0,0 +1,52 @@
1
+ Index: CHANGES
2
+ ===================================================================
3
+ RCS file: /var/cvs/xforge/xforge/CHANGES,v
4
+ retrieving revision 1.2
5
+ retrieving revision 1.3
6
+ diff -u -r1.2 -r1.3
7
+ --- CHANGES 18 Jul 2005 08:49:33 -0000 1.2
8
+ +++ CHANGES 12 Aug 2005 03:22:09 -0000 1.3
9
+ @@ -1,8 +1,43 @@
10
+ = XForge Changelog
11
+
12
+ +== Version 0.1.4
13
+ +
14
+ +This is the first functional release of XForge, a Ruby library and Rake task to automate release of
15
+ +files on RubyForge and other SourceForge clones.
16
+ +
17
+ +It's as simple as this:
18
+ +
19
+ +require 'xforge'
20
+ +
21
+ +desc "Create a new release on RubyForge"
22
+ +task :publish_files => [:gem] do
23
+ + release_files = FileList[
24
+ + "pkg/#{PKG_FILE_NAME}.gem"
25
+ + ]
26
+ +
27
+ + Rake::XForge::Release.new(PKG_NAME) do |release|
28
+ + # Never hardcode user name and password in the Rakefile!
29
+ + release.user_name = ENV['RUBYFORGE_USER']
30
+ + release.password = ENV['RUBYFORGE_PASSWORD']
31
+ + release.files = release_files.to_a
32
+ + release.release_name = "XForge #{PKG_VERSION}"
33
+ + # The rest of the options are defaults (among others, release_notes and release_changes, parsed from CHANGES)
34
+ + end
35
+ +end
36
+ +
37
+ +* Added logic for parsing of CHANGES files and include it in the release notes when publishing.
38
+ +* Wrote some proper release notes for once.
39
+ +
40
+ +== Version 0.1.3
41
+ +
42
+ +* Added logic for parsing of CHANGES files and include it in the release notes when publishing.
43
+ +
44
+ == Version 0.1.2
45
+
46
+ +This release is a minor release with fixes in the Rake script.
47
+ +
48
+ * Fixed RDoc for gem
49
+ +* Cleaned up documentation
50
+
51
+ == Version 0.1.1
52
+
@@ -0,0 +1,48 @@
1
+ = XForge Changelog
2
+
3
+ == Version 0.1.4
4
+
5
+ This is the first functional release of XForge, a Ruby library and Rake task to automate release of
6
+ files on RubyForge and other SourceForge clones.
7
+
8
+ It's as simple as this:
9
+
10
+ require 'xforge'
11
+
12
+ desc "Create a new release on RubyForge"
13
+ task :publish_files => [:gem] do
14
+ release_files = FileList[
15
+ "pkg/#{PKG_FILE_NAME}.gem"
16
+ ]
17
+
18
+ Rake::XForge::Release.new(PKG_NAME) do |release|
19
+ # Never hardcode user name and password in the Rakefile!
20
+ release.user_name = ENV['RUBYFORGE_USER']
21
+ release.password = ENV['RUBYFORGE_PASSWORD']
22
+ release.files = release_files.to_a
23
+ release.release_name = "XForge #{PKG_VERSION}"
24
+ # The rest of the options are defaults (among others, release_notes and release_changes, parsed from CHANGES)
25
+ end
26
+ end
27
+
28
+ * Added logic for parsing of CHANGES files and include it in the release notes when publishing.
29
+ * Wrote some proper release notes for once.
30
+
31
+ == Version 0.1.3
32
+
33
+ * Added logic for parsing of CHANGES files and include it in the release notes when publishing.
34
+
35
+ == Version 0.1.2
36
+
37
+ This release is a minor release with fixes in the Rake script.
38
+
39
+ * Fixed RDoc for gem
40
+ * Cleaned up documentation
41
+
42
+ == Version 0.1.1
43
+
44
+ * Rakefile: Don't include old gems in release.
45
+
46
+ == Version 0.1
47
+
48
+ * Added support for file releases
@@ -0,0 +1,13 @@
1
+ ---
2
+ start: 2005-08-14 00:00:00 Z
3
+ identifiers:
4
+ - 2005-07-18 07:53:39 Z
5
+ - 2005-07-18 08:49:33 Z
6
+ - 2005-07-18 09:01:23 Z
7
+ - 2005-08-12 03:22:09 Z
8
+ - 2005-08-13 01:23:50 Z
9
+ - 2005-08-13 01:26:31 Z
10
+ - 2005-08-13 08:48:42 Z
11
+ - 2005-08-13 08:53:03 Z
12
+ - 2005-08-13 08:54:44 Z
13
+ - 2005-08-13 08:56:51 Z
@@ -21,136 +21,12 @@ module Compatibility
21
21
  end
22
22
  end
23
23
 
24
- # Acceptance test for scm implementations
25
- #
26
- # 1) Create a central repository
27
- # 2) Import a test project to the central repository
28
- # 3) Verify that WorkingCopy is not uptodate (not yet checked out)
29
- # 4) Check out the contents of the central repo to WorkingCopy
30
- # 5) Verify that the checked out files were those imported
31
- # 6) Verify that the initial total revisions (from epoch to infinity) represents those from the import
32
- # 7) Verify that WorkingCopy is uptodate
33
- # 8) Change some files in WorkingCopy without committing them (yet)
34
- # 9) Check out the contents of the central repo to OtherWorkingCopy
35
- # 10) Verify that OtherWorkingCopy is uptodate
36
- # 11) Verify that WorkingCopy is uptodate
37
- # 12) Commit modifications in WorkingCopy
38
- # 13) Verify that there is one revision since the previous one, and that it corresponds to the changed files in 8.
39
- # 14) Verify that OtherWorkingCopy is *not* uptodate
40
- # 15) Check out OtherWorkingCopy
41
- # 16) Verify that OtherWorkingCopy is now uptodate
42
- # 17) Add and commit a file in WorkingCopy
43
- # 18) Verify that the revision (since last revision) for CheckoutHereToo contains only one file
44
- # 19) Get directory listings
45
- def test_basics
46
- work_dir = RSCM.new_temp_dir("basics")
47
- checkout_dir = "#{work_dir}/WorkingCopy"
48
- other_checkout_dir = "#{work_dir}/OtherWorkingCopy"
49
- repository_dir = "#{work_dir}/repository"
50
- scm = create_scm(repository_dir, "damagecontrolled")
51
- scm.default_options = DEFAULT_OPTIONS
52
- scm.checkout_dir = checkout_dir
53
-
54
- other_scm = create_scm(repository_dir, "damagecontrolled")
55
- other_scm.default_options = DEFAULT_OPTIONS
56
- other_scm.checkout_dir = other_checkout_dir
57
-
58
- raise "This scm (#{scm.name}) can't create 'central' repositories." unless scm.can_create_central?
59
-
60
- # 1
61
- scm.create_central
62
- @scm = scm
63
-
64
- # 2
65
- import_damagecontrolled(scm, "#{work_dir}/damagecontrolled")
66
-
67
- # 3
68
- assert(!scm.uptodate?(nil))
69
- assert(!scm.uptodate?(nil))
70
-
71
- # 4
72
- files = scm.checkout nil
73
-
74
- # 5
75
- assert_equal(4, files.length, files.join("\n"))
76
- files.sort!
77
- assert_equal("build.xml", files[0])
78
- assert_equal("project.xml", files[1])
79
- assert_equal("src/java/com/thoughtworks/damagecontrolled/Thingy.java", files[2])
80
- assert_equal("src/test/com/thoughtworks/damagecontrolled/ThingyTestCase.java", files[3])
81
-
82
- # 6
83
- initial_revisions = scm.revisions(nil)
84
- assert_equal("imported sources", initial_revisions[0].message)
85
- # Subversion seems to add a revision with message "Added directories"
86
- #assert_equal(1, initial_revisions.length)
87
- assert_equal(4, initial_revisions[0].length)
88
-
89
- # 7
90
- assert(scm.uptodate?(initial_revisions.latest.identifier))
91
-
92
- # 8
93
- change_file(scm, "#{checkout_dir}/build.xml")
94
- change_file(scm, "#{checkout_dir}/src/java/com/thoughtworks/damagecontrolled/Thingy.java")
95
-
96
- assert(!other_scm.uptodate?(initial_revisions.latest.identifier))
97
- other_scm.checkout nil
98
- assert(other_scm.uptodate?(initial_revisions.latest.identifier))
99
-
100
- sleep(1)
101
- scm.commit("changed something")
102
-
103
- # 13
104
- revisions = scm.revisions(initial_revisions.latest.identifier)
105
- assert_equal(1, revisions.length, "Actual revisions:\n" + revisions.collect{|cs| cs.to_s}.join("\n"))
106
-
107
- assert(revisions[0].identifier)
108
- revision = revisions[0]
109
- assert_equal(2, revision.length, "Actual files:\n" + revision.collect{|file| file.path}.join("\n"))
110
-
111
- assert_equal("changed something", revision.message)
112
-
113
- # why is this nil when running as the dcontrol user on codehaus? --jon
114
- #assert_equal(username, revision.developer)
115
- assert(revision.developer)
116
- assert(revision.identifier)
117
-
118
- assert_equal("build.xml", revision[0].path)
119
- assert(revision[0].native_revision_identifier)
120
- assert(revision[0].previous_native_revision_identifier)
121
- assert_equal("src/java/com/thoughtworks/damagecontrolled/Thingy.java", revision[1].path)
122
- assert(revision[1].native_revision_identifier)
123
- assert(revision[1].previous_native_revision_identifier)
124
-
125
- # 14
126
- assert(!other_scm.uptodate?(revisions.latest.identifier))
127
- assert(!other_scm.uptodate?(revisions.latest.identifier))
128
- assert(scm.uptodate?(revisions.latest.identifier))
129
- assert(scm.uptodate?(revisions.latest.identifier))
130
-
131
- # 15
132
- other_scm.checkout(nil).sort
133
-
134
- # 16
135
- assert(other_scm.uptodate?(nil))
136
-
137
- # 17
138
- add_or_edit_and_commit_file(scm, checkout_dir, "src/java/com/thoughtworks/damagecontrolled/Hello.txt", "Bla bla")
139
- assert(!other_scm.uptodate?(nil))
140
- revisions = other_scm.revisions(revisions.latest.identifier)
141
-
142
- # 18
143
- assert_equal(1, revisions.length)
144
- assert_equal(1, revisions[0].length)
145
- assert_equal("src/java/com/thoughtworks/damagecontrolled/Hello.txt", revisions[0][0].path)
146
- end
147
24
 
148
25
  def test_create_destroy
149
26
  work_dir = RSCM.new_temp_dir("create_destroy")
150
27
  checkout_dir = "#{work_dir}/checkout"
151
28
  repository_dir = "#{work_dir}/repository"
152
29
  scm = create_scm(repository_dir, "killme")
153
- scm.default_options = DEFAULT_OPTIONS
154
30
  scm.checkout_dir = checkout_dir
155
31
 
156
32
  (1..3).each do
@@ -169,14 +45,13 @@ module Compatibility
169
45
  repository_dir = "#{work_dir}/repository"
170
46
  trigger_proof = "#{work_dir}/trigger_proof"
171
47
  scm = create_scm(repository_dir, "damagecontrolled")
172
- scm.default_options = DEFAULT_OPTIONS
173
48
  scm.checkout_dir = checkout_dir
174
49
  scm.create_central
175
50
  @scm = scm
176
51
 
177
52
  # Verify that install/uninstall works
178
53
  touch = WINDOWS ? PathConverter.filepath_to_nativepath(File.dirname(__FILE__) + "/../../../bin/touch.exe", true) : `which touch`.strip
179
- trigger_command = "#{touch} " + PathConverter.filepath_to_nativepath(trigger_proof, true)
54
+ trigger_command = touch + " " + PathConverter.filepath_to_nativepath(trigger_proof, true)
180
55
  trigger_files_checkout_dir = File.expand_path("#{checkout_dir}/../trigger")
181
56
  (1..3).each do |i|
182
57
  assert(!scm.trigger_installed?(trigger_command, trigger_files_checkout_dir))
@@ -195,38 +70,11 @@ module Compatibility
195
70
  assert(File.exist?(trigger_proof))
196
71
  end
197
72
 
198
- def test_checkout_revision_identifier
199
- work_dir = RSCM.new_temp_dir("ids")
200
- checkout_dir = "#{work_dir}/checkout"
201
- repository_dir = "#{work_dir}/repository"
202
- scm = create_scm(repository_dir, "damagecontrolled")
203
- scm.default_options = DEFAULT_OPTIONS
204
- scm.checkout_dir = checkout_dir
205
- scm.create_central
206
- @scm = scm
207
-
208
- import_damagecontrolled(scm, "#{work_dir}/damagecontrolled")
209
- scm.checkout nil
210
- add_or_edit_and_commit_file(scm, checkout_dir, "before.txt", "Before label")
211
- before_cs = scm.revisions(Time.epoch)
212
-
213
- add_or_edit_and_commit_file(scm, checkout_dir, "after.txt", "After label")
214
- after_cs = scm.revisions(before_cs.latest.identifier)
215
- assert_equal(1, after_cs.length)
216
- assert_equal("after.txt", after_cs[0][0].path)
217
-
218
- scm.checkout(before_cs.latest.identifier)
219
-
220
- assert(File.exist?("#{checkout_dir}/before.txt"))
221
- assert(!File.exist?("#{checkout_dir}/after.txt"))
222
- end
223
-
224
73
  def test_should_move
225
74
  work_dir = RSCM.new_temp_dir("move")
226
75
  checkout_dir = "#{work_dir}/checkout"
227
76
  repository_dir = "#{work_dir}/repository"
228
77
  scm = create_scm(repository_dir, "damagecontrolled")
229
- scm.default_options = DEFAULT_OPTIONS
230
78
  scm.checkout_dir = checkout_dir
231
79
  scm.create_central
232
80
  @scm = scm
@@ -251,74 +99,6 @@ module Compatibility
251
99
  assert_same(scm.class, scm2.class)
252
100
  end
253
101
 
254
- EXPECTED_DIFF = <<EOF
255
- -one two three
256
- -four five six
257
- +one two three four
258
- +five six
259
- EOF
260
-
261
- def test_diffs_and_historic_file
262
- work_dir = RSCM.new_temp_dir("diff")
263
- checkout_dir = "#{work_dir}/checkout"
264
- repository_dir = "#{work_dir}/repository"
265
- import_dir = "#{work_dir}/import/diffing"
266
- scm = create_scm(repository_dir, "diffing")
267
- scm.default_options = DEFAULT_OPTIONS
268
- scm.checkout_dir = checkout_dir
269
- scm.create_central
270
- @scm = scm
271
-
272
- mkdir_p(import_dir)
273
- File.open("#{import_dir}/afile.txt", "w") do |io|
274
- io.puts("just some")
275
- io.puts("initial content")
276
- end
277
- scm.import_central :dir=>import_dir, :message=>"Importing"
278
- scm.checkout nil
279
- initial_revision = scm.revisions(nil).latest
280
- sleep(1)
281
-
282
- scm.edit("#{checkout_dir}/afile.txt")
283
- File.open("#{checkout_dir}/afile.txt", "w") do |io|
284
- io.puts("one two three")
285
- io.puts("four five six")
286
- end
287
- scm.commit("Modified existing file")
288
- sleep(1)
289
-
290
- scm.edit("#{checkout_dir}/afile.txt")
291
- File.open("#{checkout_dir}/afile.txt", "w") do |io|
292
- io.puts("one two three four")
293
- io.puts("five six")
294
- end
295
- scm.commit("Modified same file again")
296
-
297
- revisions = scm.revisions(initial_revision.identifier)
298
- assert_equal(2, revisions.length)
299
- assert_equal("Modified existing file", revisions[0].message)
300
- assert_equal("Modified same file again", revisions[1].message)
301
-
302
- got_diff = false
303
- scm.diff(revisions[1][0]) do |diff_io|
304
- got_diff = true
305
- diff_string = diff_io.read
306
- assert_match(/^\-one two three/, diff_string)
307
- assert_match(/^\-four five six/, diff_string)
308
- assert_match(/^\+one two three four/, diff_string)
309
- assert_match(/^\+five six/, diff_string)
310
- end
311
- assert(got_diff)
312
-
313
- # TODO: make separate test. Make helper method for the cumbersome setup!
314
- historic_afile = scm.file("afile.txt", false)
315
- revision_files = historic_afile.revision_files
316
- assert_equal(Array, revision_files.class)
317
- assert(revision_files.length >= 2)
318
- assert(revision_files.length <= 3)
319
- assert_equal("one two three four\nfive six\n", revision_files[-1].open(scm){|io| io.read})
320
- end
321
-
322
102
  private
323
103
 
324
104
  def import_damagecontrolled(scm, import_copy_dir)
@@ -329,7 +109,7 @@ EOF
329
109
  cp_r(path, dirname)
330
110
  todelete = Dir.glob("#{import_copy_dir}/**/.svn")
331
111
  rm_rf(todelete)
332
- scm.import_central :dir => import_copy_dir, :message => "imported sources"
112
+ scm.import_central import_copy_dir, :message => "imported sources"
333
113
  end
334
114
 
335
115
  def change_file(scm, file)
@@ -363,7 +143,6 @@ EOF
363
143
  checkout_dir = "#{work_dir}/LabelTest"
364
144
  repository_dir = "#{work_dir}/repository"
365
145
  scm = create_scm(repository_dir, "damagecontrolled")
366
- scm.default_options = DEFAULT_OPTIONS
367
146
  scm.checkout_dir = checkout_dir
368
147
  scm.create_central
369
148
  @scm = scm