5
class SvnDeltaTest < Test::Unit::TestCase
18
tmp_dir1 = "changed_tmp_dir1"
19
tmp_dir2 = "changed_tmp_dir2"
20
tmp_dir3 = "changed_tmp_dir3"
21
dir_path = File.join(@wc_path, dir)
22
tmp_dir1_path = File.join(@wc_path, tmp_dir1)
23
tmp_dir2_path = File.join(@wc_path, tmp_dir2)
24
tmp_dir3_path = File.join(dir_path, tmp_dir3)
26
tmp_dir1_svn_path = tmp_dir1
27
tmp_dir2_svn_path = tmp_dir2
28
tmp_dir3_svn_path = [dir_svn_path, tmp_dir3].join("/")
30
log = "added 3 dirs\nanded 5 files"
31
ctx = make_context(log)
33
ctx.mkdir([dir_path, tmp_dir1_path, tmp_dir2_path])
35
file1 = "changed1.txt"
36
file2 = "changed2.txt"
37
file3 = "changed3.txt"
38
file4 = "changed4.txt"
39
file5 = "changed5.txt"
40
file1_path = File.join(@wc_path, file1)
41
file2_path = File.join(dir_path, file2)
42
file3_path = File.join(@wc_path, file3)
43
file4_path = File.join(dir_path, file4)
44
file5_path = File.join(@wc_path, file5)
45
file1_svn_path = file1
46
file2_svn_path = [dir_svn_path, file2].join("/")
47
file3_svn_path = file3
48
file4_svn_path = [dir_svn_path, file4].join("/")
49
file5_svn_path = file5
50
FileUtils.touch(file1_path)
51
FileUtils.touch(file2_path)
52
FileUtils.touch(file3_path)
53
FileUtils.touch(file4_path)
54
FileUtils.touch(file5_path)
61
commit_info = ctx.commit(@wc_path)
62
first_rev = commit_info.revision
64
editor = traverse(Svn::Delta::ChangedEditor, commit_info.revision, true)
66
file1_svn_path, file2_svn_path,
67
file3_svn_path, file4_svn_path,
71
assert_equal([], editor.updated_files)
72
assert_equal([], editor.deleted_files)
73
assert_equal([].sort, editor.updated_dirs)
74
assert_equal([].sort, editor.deleted_dirs)
77
"#{tmp_dir1_svn_path}/",
78
"#{tmp_dir2_svn_path}/"
83
log = "deleted 2 dirs\nchanged 3 files\ndeleted 2 files\nadded 3 files"
84
ctx = make_context(log)
86
file6 = "changed6.txt"
87
file7 = "changed7.txt"
88
file8 = "changed8.txt"
89
file9 = "changed9.txt"
90
file6_path = File.join(dir_path, file6)
91
file7_path = File.join(@wc_path, file7)
92
file8_path = File.join(dir_path, file8)
93
file9_path = File.join(dir_path, file9)
94
file6_svn_path = [dir_svn_path, file6].join("/")
95
file7_svn_path = file7
96
file8_svn_path = [dir_svn_path, file8].join("/")
97
file9_svn_path = [dir_svn_path, file9].join("/")
99
File.open(file1_path, "w") {|f| f.puts "changed"}
100
File.open(file2_path, "w") {|f| f.puts "changed"}
101
File.open(file3_path, "w") {|f| f.puts "changed"}
102
ctx.rm_f([file4_path, file5_path])
103
FileUtils.touch(file6_path)
104
FileUtils.touch(file7_path)
105
FileUtils.touch(file8_path)
109
ctx.cp(file1_path, file9_path)
110
ctx.rm(tmp_dir1_path)
111
ctx.mv(tmp_dir2_path, tmp_dir3_path)
113
commit_info = ctx.commit(@wc_path)
114
second_rev = commit_info.revision
116
editor = traverse(Svn::Delta::ChangedEditor, commit_info.revision, true)
117
assert_equal([file1_svn_path, file2_svn_path, file3_svn_path].sort,
118
editor.updated_files)
119
assert_equal([file4_svn_path, file5_svn_path].sort,
120
editor.deleted_files)
121
assert_equal([file6_svn_path, file7_svn_path, file8_svn_path].sort,
123
assert_equal([].sort, editor.updated_dirs)
125
[file9_svn_path, file1_svn_path, first_rev]
129
["#{tmp_dir3_svn_path}/", "#{tmp_dir2_svn_path}/", first_rev]
132
assert_equal(["#{tmp_dir1_svn_path}/", "#{tmp_dir2_svn_path}/"].sort,
134
assert_equal([].sort, editor.added_dirs)
142
dir_path = File.join(@wc_path, dir)
145
log = "added 1 dirs\nanded 2 files"
146
ctx = make_context(log)
148
ctx.mkdir([dir_path])
152
file1_path = File.join(@wc_path, file1)
153
file2_path = File.join(dir_path, file2)
154
file1_svn_path = file1
155
file2_svn_path = [dir_svn_path, file2].join("/")
156
FileUtils.touch(file1_path)
157
FileUtils.touch(file2_path)
161
ctx.propset(prop_name, prop_value, dir_path)
163
commit_info = ctx.commit(@wc_path)
165
editor = traverse(Svn::Delta::ChangedDirsEditor, commit_info.revision)
166
assert_equal(["", dir_svn_path].collect{|path| "#{path}/"}.sort,
171
ctx = make_context(log)
173
ctx.propdel(prop_name, dir_path)
175
commit_info = ctx.commit(@wc_path)
177
editor = traverse(Svn::Delta::ChangedDirsEditor, commit_info.revision)
178
assert_equal([dir_svn_path].collect{|path| "#{path}/"}.sort,
182
ctx.propset(prop_name, prop_value, file1_path)
184
commit_info = ctx.commit(@wc_path)
186
editor = traverse(Svn::Delta::ChangedDirsEditor, commit_info.revision)
187
assert_equal([""].collect{|path| "#{path}/"}.sort,
191
ctx.propdel(prop_name, file1_path)
192
ctx.propset(prop_name, prop_value, file2_path)
194
commit_info = ctx.commit(@wc_path)
196
editor = traverse(Svn::Delta::ChangedDirsEditor, commit_info.revision)
197
assert_equal(["", dir_svn_path].collect{|path| "#{path}/"}.sort,
202
def traverse(editor_class, rev, pass_root=false)
205
base_root = @fs.root(base_rev)
207
editor = editor_class.new(root, base_root)
209
editor = editor_class.new
211
base_root.editor = editor
212
base_root.dir_delta("", "", root, "")