subversion 1.6.6-x86-mswin32-60 → 1.6.11-x86-mswin32-60

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 (62) hide show
  1. data/licenses/apr-util/NOTICE +1 -1
  2. data/licenses/apr/NOTICE +1 -1
  3. data/licenses/zlib/README +37 -48
  4. data/readme.txt +20 -0
  5. data/{ruby → subversion}/ext/svn/ext/client.dll +0 -0
  6. data/subversion/ext/svn/ext/core.dll +0 -0
  7. data/{ruby → subversion}/ext/svn/ext/delta.dll +0 -0
  8. data/{ruby → subversion}/ext/svn/ext/fs.dll +0 -0
  9. data/{ruby → subversion}/ext/svn/ext/intl3_svn.dll +0 -0
  10. data/{ruby → subversion}/ext/svn/ext/libapr-1.dll +0 -0
  11. data/subversion/ext/svn/ext/libaprutil-1.dll +0 -0
  12. data/{ruby → subversion}/ext/svn/ext/libdb44.dll +0 -0
  13. data/subversion/ext/svn/ext/libsasl.dll +0 -0
  14. data/subversion/ext/svn/ext/libsvn_client-1.dll +0 -0
  15. data/{ruby → subversion}/ext/svn/ext/libsvn_delta-1.dll +0 -0
  16. data/{ruby → subversion}/ext/svn/ext/libsvn_diff-1.dll +0 -0
  17. data/subversion/ext/svn/ext/libsvn_fs-1.dll +0 -0
  18. data/subversion/ext/svn/ext/libsvn_ra-1.dll +0 -0
  19. data/{ruby → subversion}/ext/svn/ext/libsvn_repos-1.dll +0 -0
  20. data/{ruby → subversion}/ext/svn/ext/libsvn_subr-1.dll +0 -0
  21. data/{ruby → subversion}/ext/svn/ext/libsvn_swig_ruby-1.dll +0 -0
  22. data/subversion/ext/svn/ext/libsvn_wc-1.dll +0 -0
  23. data/{ruby → subversion}/ext/svn/ext/ra.dll +0 -0
  24. data/{ruby → subversion}/ext/svn/ext/repos.dll +0 -0
  25. data/{ruby → subversion}/ext/svn/ext/wc.dll +0 -0
  26. data/{ruby → subversion}/lib/svn/client.rb +0 -0
  27. data/{ruby → subversion}/lib/svn/core.rb +0 -0
  28. data/{ruby → subversion}/lib/svn/delta.rb +2 -2
  29. data/{ruby → subversion}/lib/svn/error.rb +0 -0
  30. data/{ruby → subversion}/lib/svn/fs.rb +0 -0
  31. data/{ruby → subversion}/lib/svn/info.rb +0 -0
  32. data/{ruby → subversion}/lib/svn/ra.rb +0 -0
  33. data/{ruby → subversion}/lib/svn/repos.rb +0 -0
  34. data/{ruby → subversion}/lib/svn/util.rb +0 -0
  35. data/{ruby → subversion}/lib/svn/wc.rb +0 -0
  36. data/subversion/test/greek_tree.rb +63 -0
  37. data/subversion/test/my-assertions.rb +48 -0
  38. data/subversion/test/run-test.rb +35 -0
  39. data/subversion/test/test-unit-ext.rb +4 -0
  40. data/subversion/test/test-unit-ext/always-show-result.rb +28 -0
  41. data/subversion/test/test-unit-ext/backtrace-filter.rb +17 -0
  42. data/subversion/test/test-unit-ext/long-display-for-emacs.rb +25 -0
  43. data/subversion/test/test-unit-ext/priority.rb +176 -0
  44. data/subversion/test/test_client.rb +2457 -0
  45. data/subversion/test/test_core.rb +849 -0
  46. data/subversion/test/test_delta.rb +497 -0
  47. data/subversion/test/test_error.rb +16 -0
  48. data/subversion/test/test_fs.rb +519 -0
  49. data/subversion/test/test_info.rb +331 -0
  50. data/subversion/test/test_ra.rb +436 -0
  51. data/subversion/test/test_repos.rb +872 -0
  52. data/subversion/test/test_util.rb +18 -0
  53. data/subversion/test/test_wc.rb +1063 -0
  54. data/subversion/test/util.rb +292 -0
  55. data/subversion/test/windows_util.rb +263 -0
  56. metadata +71 -39
  57. data/ruby/ext/svn/ext/core.dll +0 -0
  58. data/ruby/ext/svn/ext/libaprutil-1.dll +0 -0
  59. data/ruby/ext/svn/ext/libsvn_client-1.dll +0 -0
  60. data/ruby/ext/svn/ext/libsvn_fs-1.dll +0 -0
  61. data/ruby/ext/svn/ext/libsvn_ra-1.dll +0 -0
  62. data/ruby/ext/svn/ext/libsvn_wc-1.dll +0 -0
@@ -0,0 +1,872 @@
1
+ require "tempfile"
2
+
3
+ require "my-assertions"
4
+ require "util"
5
+
6
+ require "svn/core"
7
+ require "svn/fs"
8
+ require "svn/repos"
9
+ require "svn/client"
10
+
11
+ class SvnReposTest < Test::Unit::TestCase
12
+ include SvnTestUtil
13
+
14
+ def setup
15
+ setup_basic
16
+ end
17
+
18
+ def teardown
19
+ teardown_basic
20
+ end
21
+
22
+ def test_version
23
+ assert_equal(Svn::Core.subr_version, Svn::Repos.version)
24
+ end
25
+
26
+ def test_path
27
+ assert_equal(@repos_path, @repos.path)
28
+
29
+ assert_equal(File.join(@repos_path, "db"), @repos.db_env)
30
+
31
+ assert_equal(File.join(@repos_path, "conf"), @repos.conf_dir)
32
+ assert_equal(File.join(@repos_path, "conf", "svnserve.conf"),
33
+ @repos.svnserve_conf)
34
+
35
+ locks_dir = File.join(@repos_path, "locks")
36
+ assert_equal(locks_dir, @repos.lock_dir)
37
+ assert_equal(File.join(locks_dir, "db.lock"),
38
+ @repos.db_lockfile)
39
+ assert_equal(File.join(locks_dir, "db-logs.lock"),
40
+ @repos.db_logs_lockfile)
41
+
42
+ hooks_dir = File.join(@repos_path, "hooks")
43
+ assert_equal(hooks_dir, @repos.hook_dir)
44
+
45
+ assert_equal(File.join(hooks_dir, "start-commit"),
46
+ @repos.start_commit_hook)
47
+ assert_equal(File.join(hooks_dir, "pre-commit"),
48
+ @repos.pre_commit_hook)
49
+ assert_equal(File.join(hooks_dir, "post-commit"),
50
+ @repos.post_commit_hook)
51
+
52
+ assert_equal(File.join(hooks_dir, "pre-revprop-change"),
53
+ @repos.pre_revprop_change_hook)
54
+ assert_equal(File.join(hooks_dir, "post-revprop-change"),
55
+ @repos.post_revprop_change_hook)
56
+
57
+ assert_equal(File.join(hooks_dir, "pre-lock"),
58
+ @repos.pre_lock_hook)
59
+ assert_equal(File.join(hooks_dir, "post-lock"),
60
+ @repos.post_lock_hook)
61
+
62
+ assert_equal(File.join(hooks_dir, "pre-unlock"),
63
+ @repos.pre_unlock_hook)
64
+ assert_equal(File.join(hooks_dir, "post-unlock"),
65
+ @repos.post_unlock_hook)
66
+
67
+
68
+ search_path = @repos_path
69
+ assert_equal(@repos_path, Svn::Repos.find_root_path(search_path))
70
+ search_path = "#{@repos_path}/XXX"
71
+ assert_equal(@repos_path, Svn::Repos.find_root_path(search_path))
72
+
73
+ search_path = "not-found"
74
+ assert_equal(nil, Svn::Repos.find_root_path(search_path))
75
+ end
76
+
77
+ def test_create
78
+ tmp_repos_path = File.join(@tmp_path, "repos")
79
+ fs_type = Svn::Fs::TYPE_FSFS
80
+ fs_config = {Svn::Fs::CONFIG_FS_TYPE => fs_type}
81
+ repos = nil
82
+ Svn::Repos.create(tmp_repos_path, {}, fs_config) do |repos|
83
+ assert(File.exist?(tmp_repos_path))
84
+ fs_type_path = File.join(repos.fs.path, Svn::Fs::CONFIG_FS_TYPE)
85
+ assert_equal(fs_type, File.open(fs_type_path) {|f| f.read.chop})
86
+ repos.fs.set_warning_func(&warning_func)
87
+ end
88
+
89
+ assert(repos.closed?)
90
+ assert_raises(Svn::Error::ReposAlreadyClose) do
91
+ repos.fs
92
+ end
93
+
94
+ Svn::Repos.delete(tmp_repos_path)
95
+ assert(!File.exist?(tmp_repos_path))
96
+ end
97
+
98
+ def test_logs
99
+ log1 = "sample log1"
100
+ log2 = "sample log2"
101
+ log3 = "sample log3"
102
+ file = "file"
103
+ src = "source"
104
+ props = {"myprop" => "value"}
105
+ path = File.join(@wc_path, file)
106
+
107
+ ctx1 = make_context(log1)
108
+ File.open(path, "w") {|f| f.print(src)}
109
+ ctx1.add(path)
110
+ info1 = ctx1.ci(@wc_path)
111
+ start_rev = info1.revision
112
+
113
+ ctx2 = make_context(log2)
114
+ File.open(path, "a") {|f| f.print(src)}
115
+ info2 = ctx2.ci(@wc_path)
116
+
117
+ ctx3 = make_context(log3)
118
+ File.open(path, "a") {|f| f.print(src)}
119
+ props.each do |key, value|
120
+ ctx3.prop_set(key, value, path)
121
+ end
122
+ info3 = ctx3.ci(@wc_path)
123
+ end_rev = info3.revision
124
+
125
+ logs = @repos.logs(file, start_rev, end_rev, end_rev - start_rev + 1)
126
+ logs = logs.collect do |changed_paths, revision, author, date, message|
127
+ paths = {}
128
+ changed_paths.each do |key, changed_path|
129
+ paths[key] = changed_path.action
130
+ end
131
+ [paths, revision, author, date, message]
132
+ end
133
+ assert_equal([
134
+ [
135
+ {"/#{file}" => "A"},
136
+ info1.revision,
137
+ @author,
138
+ info1.date,
139
+ log1,
140
+ ],
141
+ [
142
+ {"/#{file}" => "M"},
143
+ info2.revision,
144
+ @author,
145
+ info2.date,
146
+ log2,
147
+ ],
148
+ [
149
+ {"/#{file}" => "M"},
150
+ info3.revision,
151
+ @author,
152
+ info3.date,
153
+ log3,
154
+ ],
155
+ ],
156
+ logs)
157
+ revs = []
158
+ args = [file, start_rev, end_rev]
159
+ @repos.file_revs(*args) do |path, rev, rev_props, prop_diffs|
160
+ hashed_prop_diffs = {}
161
+ prop_diffs.each do |prop|
162
+ hashed_prop_diffs[prop.name] = prop.value
163
+ end
164
+ revs << [path, rev, hashed_prop_diffs]
165
+ end
166
+ assert_equal([
167
+ ["/#{file}", info1.revision, {}],
168
+ ["/#{file}", info2.revision, {}],
169
+ ["/#{file}", info3.revision, props],
170
+ ],
171
+ revs)
172
+
173
+ revs = []
174
+ @repos.file_revs2(*args) do |path, rev, rev_props, prop_diffs|
175
+ revs << [path, rev, prop_diffs]
176
+ end
177
+ assert_equal([
178
+ ["/#{file}", info1.revision, {}],
179
+ ["/#{file}", info2.revision, {}],
180
+ ["/#{file}", info3.revision, props],
181
+ ],
182
+ revs)
183
+
184
+
185
+ rev, date, author = @repos.fs.root.committed_info("/")
186
+ assert_equal(info3.revision, rev)
187
+ assert_equal(info3.date, date)
188
+ assert_equal(info3.author, author)
189
+ ensure
190
+ ctx3.destroy unless ctx3.nil?
191
+ ctx2.destroy unless ctx2.nil?
192
+ ctx1.destroy unless ctx1.nil?
193
+ end
194
+
195
+ def test_hotcopy
196
+ log = "sample log"
197
+ file = "hello.txt"
198
+ path = File.join(@wc_path, file)
199
+ FileUtils.touch(path)
200
+
201
+ # So we can later rename files when running the tests on
202
+ # Windows, close access to the repos created by the test setup.
203
+ test_repos_path = @repos.path
204
+ @repos.close
205
+ @repos = nil
206
+ @fs.close
207
+ @fs = nil
208
+
209
+ rev = make_context(log) do |ctx|
210
+ ctx.add(path)
211
+ commit_info = ctx.commit(@wc_path)
212
+ rev = commit_info.revision
213
+
214
+ assert_equal(log, ctx.log_message(path, rev))
215
+ rev
216
+ end
217
+
218
+ dest_path = File.join(@tmp_path, "dest")
219
+ backup_path = File.join(@tmp_path, "back")
220
+ config = {}
221
+ fs_config = {}
222
+
223
+ dest_repos = Svn::Repos.create(dest_path, config, fs_config)
224
+ dest_repos.fs.set_warning_func(&warning_func)
225
+ dest_repos_path = dest_repos.path
226
+ dest_repos.close
227
+
228
+ FileUtils.mv(test_repos_path, backup_path)
229
+ FileUtils.mv(dest_repos_path, test_repos_path)
230
+
231
+ make_context(log) do |ctx|
232
+ assert_raises(Svn::Error::FsNoSuchRevision) do
233
+ assert_equal(log, ctx.log_message(path, rev))
234
+ end
235
+
236
+ FileUtils.rm_r(test_repos_path)
237
+ Svn::Repos.hotcopy(backup_path, test_repos_path)
238
+ assert_equal(log, ctx.log_message(path, rev))
239
+ end
240
+ end
241
+
242
+ def assert_transaction
243
+ log = "sample log"
244
+ make_context(log) do |ctx|
245
+ ctx.checkout(@repos_uri, @wc_path)
246
+ ctx.mkdir(["#{@wc_path}/new_dir"])
247
+
248
+ prev_rev = @repos.youngest_rev
249
+ past_date = Time.now
250
+ args = {
251
+ :author => @author,
252
+ :log => log,
253
+ :revision => prev_rev,
254
+ }
255
+ callback = Proc.new do |txn|
256
+ txn.abort
257
+ end
258
+ yield(:commit, @repos, args, callback)
259
+ assert_equal(prev_rev, @repos.youngest_rev)
260
+ assert_equal(prev_rev, @repos.dated_revision(past_date))
261
+
262
+ prev_rev = @repos.youngest_rev
263
+ @repos.transaction_for_commit(@author, log) do |txn|
264
+ end
265
+ assert_equal(prev_rev + 1, @repos.youngest_rev)
266
+ assert_equal(prev_rev, @repos.dated_revision(past_date))
267
+ assert_equal(prev_rev + 1, @repos.dated_revision(Time.now))
268
+
269
+ prev_rev = @repos.youngest_rev
270
+ args = {
271
+ :author => @author,
272
+ :revision => prev_rev,
273
+ }
274
+ callback = Proc.new do |txn|
275
+ end
276
+ yield(:update, @repos, args, callback)
277
+ assert_equal(prev_rev, @repos.youngest_rev)
278
+ end
279
+ end
280
+
281
+ def test_transaction
282
+ assert_transaction do |type, repos, args, callback|
283
+ case type
284
+ when :commit
285
+ repos.transaction_for_commit(args[:author], args[:log], &callback)
286
+ when :update
287
+ repos.transaction_for_update(args[:author], &callback)
288
+ end
289
+ end
290
+ end
291
+
292
+ def test_transaction_with_revision
293
+ assert_transaction do |type, repos, args, callback|
294
+ case type
295
+ when :commit
296
+ repos.transaction_for_commit(args[:author], args[:log],
297
+ args[:revision], &callback)
298
+ when :update
299
+ repos.transaction_for_update(args[:author], args[:revision], &callback)
300
+ end
301
+ end
302
+ end
303
+
304
+ def test_transaction2
305
+ assert_transaction do |type, repos, args, callback|
306
+ case type
307
+ when :commit
308
+ props = {
309
+ Svn::Core::PROP_REVISION_AUTHOR => args[:author],
310
+ Svn::Core::PROP_REVISION_LOG => args[:log],
311
+ }
312
+ repos.transaction_for_commit(props, &callback)
313
+ when :update
314
+ repos.transaction_for_update(args[:author], &callback)
315
+ end
316
+ end
317
+ end
318
+
319
+ def test_transaction2_with_revision
320
+ assert_transaction do |type, repos, args, callback|
321
+ case type
322
+ when :commit
323
+ props = {
324
+ Svn::Core::PROP_REVISION_AUTHOR => args[:author],
325
+ Svn::Core::PROP_REVISION_LOG => args[:log],
326
+ }
327
+ repos.transaction_for_commit(props,
328
+ args[:revision],
329
+ &callback)
330
+ when :update
331
+ repos.transaction_for_update(args[:author],
332
+ args[:revision],
333
+ &callback)
334
+ end
335
+ end
336
+ end
337
+
338
+ def test_trace_node_locations
339
+ file1 = "file1"
340
+ file2 = "file2"
341
+ file3 = "file3"
342
+ path1 = File.join(@wc_path, file1)
343
+ path2 = File.join(@wc_path, file2)
344
+ path3 = File.join(@wc_path, file3)
345
+ log = "sample log"
346
+ make_context(log) do |ctx|
347
+
348
+ FileUtils.touch(path1)
349
+ ctx.add(path1)
350
+ rev1 = ctx.ci(@wc_path).revision
351
+
352
+ ctx.mv(path1, path2)
353
+ rev2 = ctx.ci(@wc_path).revision
354
+
355
+ ctx.cp(path2, path3)
356
+ rev3 = ctx.ci(@wc_path).revision
357
+
358
+ assert_equal({
359
+ rev1 => "/#{file1}",
360
+ rev2 => "/#{file2}",
361
+ rev3 => "/#{file2}",
362
+ },
363
+ @repos.fs.trace_node_locations("/#{file2}",
364
+ [rev1, rev2, rev3]))
365
+ end
366
+ end
367
+
368
+ def assert_report
369
+ file = "file"
370
+ file2 = "file2"
371
+ fs_base = "base"
372
+ path = File.join(@wc_path, file)
373
+ path2 = File.join(@wc_path, file2)
374
+ source = "sample source"
375
+ log = "sample log"
376
+ make_context(log) do |ctx|
377
+
378
+ File.open(path, "w") {|f| f.print(source)}
379
+ ctx.add(path)
380
+ rev = ctx.ci(@wc_path).revision
381
+
382
+ assert_equal(Svn::Core::NODE_FILE, @repos.fs.root.stat(file).kind)
383
+
384
+ editor = TestEditor.new
385
+ args = {
386
+ :revision => rev,
387
+ :user_name => @author,
388
+ :fs_base => fs_base,
389
+ :target => "/",
390
+ :target_path => nil,
391
+ :editor => editor,
392
+ :text_deltas => true,
393
+ :recurse => true,
394
+ :ignore_ancestry => false,
395
+ }
396
+ callback = Proc.new do |baton|
397
+ baton.link_path(file, file2, rev)
398
+ baton.delete_path(file)
399
+ end
400
+ yield(@repos, args, callback)
401
+ assert_equal([
402
+ :set_target_revision,
403
+ :open_root,
404
+ :close_directory,
405
+ :close_edit,
406
+ ],
407
+ editor.sequence.collect{|meth, *args| meth})
408
+ end
409
+ end
410
+
411
+ def test_report
412
+ assert_report do |repos, args, callback|
413
+ @repos.report(args[:revision], args[:user_name], args[:fs_base],
414
+ args[:target], args[:target_path], args[:editor],
415
+ args[:text_deltas], args[:recurse], args[:ignore_ancestry],
416
+ &callback)
417
+ end
418
+ end
419
+
420
+ def test_report2
421
+ assert_report do |repos, args, callback|
422
+ if args[:recurse]
423
+ depth = Svn::Core::DEPTH_INFINITY
424
+ else
425
+ depth = Svn::Core::DEPTH_FILES
426
+ end
427
+ @repos.report2(args[:revision], args[:fs_base], args[:target],
428
+ args[:target_path], args[:editor], args[:text_deltas],
429
+ args[:ignore_ancestry], depth, &callback)
430
+ end
431
+ end
432
+
433
+ def assert_commit_editor
434
+ trunk = "trunk"
435
+ tags = "tags"
436
+ tags_sub = "sub"
437
+ file = "file"
438
+ source = "sample source"
439
+ user = "user"
440
+ log_message = "log"
441
+ trunk_dir_path = File.join(@wc_path, trunk)
442
+ tags_dir_path = File.join(@wc_path, tags)
443
+ tags_sub_dir_path = File.join(tags_dir_path, tags_sub)
444
+ trunk_path = File.join(trunk_dir_path, file)
445
+ tags_path = File.join(tags_dir_path, file)
446
+ tags_sub_path = File.join(tags_sub_dir_path, file)
447
+ trunk_repos_uri = "#{@repos_uri}/#{trunk}"
448
+ rev1 = @repos.youngest_rev
449
+
450
+ commit_callback_result = {}
451
+ args = {
452
+ :repos_url => @repos_uri,
453
+ :base_path => "/",
454
+ :user => user,
455
+ :log_message => log_message,
456
+ }
457
+
458
+ editor = yield(@repos, commit_callback_result, args)
459
+ root_baton = editor.open_root(rev1)
460
+ dir_baton = editor.add_directory(trunk, root_baton, nil, rev1)
461
+ file_baton = editor.add_file("#{trunk}/#{file}", dir_baton, nil, -1)
462
+ ret = editor.apply_textdelta(file_baton, nil)
463
+ ret.send(source)
464
+ editor.close_edit
465
+
466
+ assert_equal(rev1 + 1, @repos.youngest_rev)
467
+ assert_equal({
468
+ :revision => @repos.youngest_rev,
469
+ :date => @repos.prop(Svn::Core::PROP_REVISION_DATE),
470
+ :author => user,
471
+ },
472
+ commit_callback_result)
473
+ rev2 = @repos.youngest_rev
474
+
475
+ ctx = make_context("")
476
+ ctx.up(@wc_path)
477
+ assert_equal(source, File.open(trunk_path) {|f| f.read})
478
+
479
+ commit_callback_result = {}
480
+ editor = yield(@repos, commit_callback_result, args)
481
+ root_baton = editor.open_root(rev2)
482
+ dir_baton = editor.add_directory(tags, root_baton, nil, rev2)
483
+ subdir_baton = editor.add_directory("#{tags}/#{tags_sub}",
484
+ dir_baton,
485
+ trunk_repos_uri,
486
+ rev2)
487
+ editor.close_edit
488
+
489
+ assert_equal(rev2 + 1, @repos.youngest_rev)
490
+ assert_equal({
491
+ :revision => @repos.youngest_rev,
492
+ :date => @repos.prop(Svn::Core::PROP_REVISION_DATE),
493
+ :author => user,
494
+ },
495
+ commit_callback_result)
496
+ rev3 = @repos.youngest_rev
497
+
498
+ ctx.up(@wc_path)
499
+ assert_equal([
500
+ ["/#{tags}/#{tags_sub}/#{file}", rev3],
501
+ ["/#{trunk}/#{file}", rev2],
502
+ ],
503
+ @repos.fs.history("#{tags}/#{tags_sub}/#{file}",
504
+ rev1, rev3, rev2))
505
+
506
+ commit_callback_result = {}
507
+ editor = yield(@repos, commit_callback_result, args)
508
+ root_baton = editor.open_root(rev3)
509
+ dir_baton = editor.delete_entry(tags, rev3, root_baton)
510
+ editor.close_edit
511
+
512
+ assert_equal({
513
+ :revision => @repos.youngest_rev,
514
+ :date => @repos.prop(Svn::Core::PROP_REVISION_DATE),
515
+ :author => user,
516
+ },
517
+ commit_callback_result)
518
+
519
+ ctx.up(@wc_path)
520
+ assert(!File.exist?(tags_path))
521
+ end
522
+
523
+ def test_commit_editor
524
+ assert_commit_editor do |receiver, commit_callback_result, args|
525
+ commit_callback = Proc.new do |revision, date, author|
526
+ commit_callback_result[:revision] = revision
527
+ commit_callback_result[:date] = date
528
+ commit_callback_result[:author] = author
529
+ end
530
+ receiver.commit_editor(args[:repos_url], args[:base_path], args[:txn],
531
+ args[:user], args[:log_message], commit_callback)
532
+ end
533
+ end
534
+
535
+ def test_commit_editor2
536
+ assert_commit_editor do |receiver, commit_callback_result, args|
537
+ commit_callback = Proc.new do |info|
538
+ commit_callback_result[:revision] = info.revision
539
+ commit_callback_result[:date] = info.date
540
+ commit_callback_result[:author] = info.author
541
+ end
542
+ receiver.commit_editor2(args[:repos_url], args[:base_path], args[:txn],
543
+ args[:user], args[:log_message], commit_callback)
544
+ end
545
+ end
546
+
547
+ def test_commit_editor3
548
+ assert_commit_editor do |receiver, commit_callback_result, args|
549
+ props = {
550
+ Svn::Core::PROP_REVISION_AUTHOR => args[:user],
551
+ Svn::Core::PROP_REVISION_LOG => args[:log_message],
552
+ }
553
+ commit_callback = Proc.new do |info|
554
+ commit_callback_result[:revision] = info.revision
555
+ commit_callback_result[:date] = info.date
556
+ commit_callback_result[:author] = info.author
557
+ end
558
+ receiver.commit_editor3(args[:repos_url], args[:base_path], args[:txn],
559
+ props, commit_callback)
560
+ end
561
+ end
562
+
563
+ def test_prop
564
+ file = "file"
565
+ path = File.join(@wc_path, file)
566
+ source = "sample source"
567
+ log = "sample log"
568
+ make_context(log) do |ctx|
569
+
570
+ File.open(path, "w") {|f| f.print(source)}
571
+ ctx.add(path)
572
+ ctx.ci(@wc_path)
573
+
574
+ assert_equal([
575
+ Svn::Core::PROP_REVISION_AUTHOR,
576
+ Svn::Core::PROP_REVISION_LOG,
577
+ Svn::Core::PROP_REVISION_DATE,
578
+ ].sort,
579
+ @repos.proplist.keys.sort)
580
+ assert_equal(log, @repos.prop(Svn::Core::PROP_REVISION_LOG))
581
+ @repos.set_prop(@author, Svn::Core::PROP_REVISION_LOG, nil)
582
+ assert_nil(@repos.prop(Svn::Core::PROP_REVISION_LOG))
583
+ assert_equal([
584
+ Svn::Core::PROP_REVISION_AUTHOR,
585
+ Svn::Core::PROP_REVISION_DATE,
586
+ ].sort,
587
+ @repos.proplist.keys.sort)
588
+
589
+ assert_raises(Svn::Error::ReposHookFailure) do
590
+ @repos.set_prop(@author, Svn::Core::PROP_REVISION_DATE, nil)
591
+ end
592
+ assert_not_nil(@repos.prop(Svn::Core::PROP_REVISION_DATE))
593
+
594
+ assert_nothing_raised do
595
+ @repos.set_prop(@author, Svn::Core::PROP_REVISION_DATE, nil, nil, nil,
596
+ false)
597
+ end
598
+ assert_nil(@repos.prop(Svn::Core::PROP_REVISION_DATE))
599
+ assert_equal([
600
+ Svn::Core::PROP_REVISION_AUTHOR,
601
+ ].sort,
602
+ @repos.proplist.keys.sort)
603
+ end
604
+ end
605
+
606
+ def test_dump
607
+ file = "file"
608
+ path = File.join(@wc_path, file)
609
+ source = "sample source"
610
+ log = "sample log"
611
+ make_context(log) do |ctx|
612
+
613
+ File.open(path, "w") {|f| f.print(source)}
614
+ ctx.add(path)
615
+ rev1 = ctx.ci(@wc_path).revision
616
+
617
+ File.open(path, "a") {|f| f.print(source)}
618
+ rev2 = ctx.ci(@wc_path).revision
619
+
620
+ assert_nothing_raised do
621
+ @repos.dump_fs(nil, nil, rev1, rev2)
622
+ end
623
+
624
+ dump = StringIO.new("")
625
+ feedback = StringIO.new("")
626
+ @repos.dump_fs(dump, feedback, rev1, rev2)
627
+
628
+ dump_unless_feedback = StringIO.new("")
629
+ @repos.dump_fs(dump_unless_feedback, nil, rev1, rev2)
630
+
631
+ dump.rewind
632
+ dump_unless_feedback.rewind
633
+ assert_equal(dump.read, dump_unless_feedback.read)
634
+ end
635
+ end
636
+
637
+ def test_load
638
+ file = "file"
639
+ path = File.join(@wc_path, file)
640
+ source = "sample source"
641
+ log = "sample log"
642
+ make_context(log) do |ctx|
643
+
644
+ File.open(path, "w") {|f| f.print(source)}
645
+ ctx.add(path)
646
+ rev1 = ctx.ci(@wc_path).revision
647
+
648
+ File.open(path, "a") {|f| f.print(source)}
649
+ rev2 = ctx.ci(@wc_path).revision
650
+
651
+ dump = StringIO.new("")
652
+ @repos.dump_fs(dump, nil, rev1, rev2)
653
+
654
+ dest_path = File.join(@tmp_path, "dest")
655
+ repos = Svn::Repos.create(dest_path)
656
+ assert_raises(NoMethodError) do
657
+ repos.load_fs(nil)
658
+ end
659
+
660
+ [
661
+ [StringIO.new(""), Svn::Repos::LOAD_UUID_DEFAULT, "/"],
662
+ [StringIO.new("")],
663
+ [],
664
+ ].each_with_index do |args, i|
665
+ dest_path = File.join(@tmp_path, "dest#{i}")
666
+ repos = Svn::Repos.create(dest_path)
667
+ assert_not_equal(@repos.fs.root.committed_info("/"),
668
+ repos.fs.root.committed_info("/"))
669
+ dump.rewind
670
+ repos.load_fs(dump, *args)
671
+ assert_equal(@repos.fs.root.committed_info("/"),
672
+ repos.fs.root.committed_info("/"))
673
+ end
674
+ end
675
+ end
676
+
677
+ def test_node_editor
678
+ file = "file"
679
+ dir1 = "dir1"
680
+ dir2 = "dir2"
681
+ dir3 = "dir3"
682
+ dir1_path = File.join(@wc_path, dir1)
683
+ dir2_path = File.join(dir1_path, dir2)
684
+ dir3_path = File.join(dir2_path, dir3)
685
+ path = File.join(dir3_path, file)
686
+ source = "sample source"
687
+ log = "sample log"
688
+
689
+ make_context(log) do |ctx|
690
+ FileUtils.mkdir_p(dir3_path)
691
+ FileUtils.touch(path)
692
+ ctx.add(dir1_path)
693
+ rev1 = ctx.ci(@wc_path).revision
694
+
695
+ ctx.rm(dir3_path)
696
+ rev2 = ctx.ci(@wc_path).revision
697
+
698
+ rev1_root = @repos.fs.root(rev1)
699
+ rev2_root = @repos.fs.root(rev2)
700
+ editor = @repos.node_editor(rev1_root, rev2_root)
701
+ rev2_root.replay(editor)
702
+
703
+ tree = editor.baton.node
704
+
705
+ assert_equal("", tree.name)
706
+ assert_equal(dir1, tree.child.name)
707
+ assert_equal(dir2, tree.child.child.name)
708
+ end
709
+ end
710
+
711
+ def test_lock
712
+ file = "file"
713
+ log = "sample log"
714
+ path = File.join(@wc_path, file)
715
+ path_in_repos = "/#{file}"
716
+ make_context(log) do |ctx|
717
+
718
+ FileUtils.touch(path)
719
+ ctx.add(path)
720
+ rev = ctx.ci(@wc_path).revision
721
+
722
+ access = Svn::Fs::Access.new(@author)
723
+ @repos.fs.access = access
724
+ lock = @repos.lock(file)
725
+ locks = @repos.get_locks(file)
726
+ assert_equal([path_in_repos], locks.keys)
727
+ assert_equal(lock.token, locks[path_in_repos].token)
728
+ @repos.unlock(file, lock.token)
729
+ assert_equal({}, @repos.get_locks(file))
730
+ end
731
+ end
732
+
733
+ def test_authz
734
+ name = "REPOS"
735
+ conf_path = File.join(@tmp_path, "authz_file")
736
+ File.open(conf_path, "w") do |f|
737
+ f.print(<<-EOF)
738
+ [/]
739
+ #{@author} = r
740
+ EOF
741
+ end
742
+
743
+ authz = Svn::Repos::Authz.read(conf_path)
744
+ assert(authz.can_access?(name, "/", @author, Svn::Repos::AUTHZ_READ))
745
+ assert(!authz.can_access?(name, "/", @author, Svn::Repos::AUTHZ_WRITE))
746
+ assert(!authz.can_access?(name, "/", "FOO", Svn::Repos::AUTHZ_READ))
747
+ end
748
+
749
+ def test_recover
750
+ started = false
751
+ Svn::Repos.recover(@repos_path, false) do
752
+ started = true
753
+ end
754
+ assert(started)
755
+ end
756
+
757
+ def test_mergeinfo
758
+ log = "sample log"
759
+ file = "sample.txt"
760
+ src = "sample\n"
761
+ trunk = File.join(@wc_path, "trunk")
762
+ branch = File.join(@wc_path, "branch")
763
+ trunk_path = File.join(trunk, file)
764
+ branch_path = File.join(branch, file)
765
+ trunk_path_in_repos = "/trunk/#{file}"
766
+ branch_path_in_repos = "/branch/#{file}"
767
+
768
+ make_context(log) do |ctx|
769
+ ctx.mkdir(trunk, branch)
770
+ File.open(trunk_path, "w") {}
771
+ File.open(branch_path, "w") {}
772
+ ctx.add(trunk_path)
773
+ ctx.add(branch_path)
774
+ original_rev = ctx.commit(@wc_path).revision
775
+
776
+ File.open(branch_path, "w") {|f| f.print(src)}
777
+ merged_rev = ctx.commit(@wc_path).revision
778
+
779
+ ctx.merge(branch, original_rev, branch, merged_rev, trunk)
780
+ ctx.commit(@wc_path)
781
+
782
+ mergeinfo = Svn::Core::MergeInfo.parse("#{branch_path_in_repos}:#{merged_rev}")
783
+ assert_equal({trunk_path_in_repos => mergeinfo},
784
+ @repos.mergeinfo([trunk_path_in_repos]))
785
+ assert_equal(mergeinfo, @repos.mergeinfo(trunk_path_in_repos))
786
+ end
787
+ end
788
+
789
+ private
790
+ def warning_func
791
+ Proc.new do |err|
792
+ STDERR.puts err if $DEBUG
793
+ end
794
+ end
795
+
796
+ class TestEditor < Svn::Delta::BaseEditor
797
+ attr_reader :sequence
798
+ def initialize
799
+ @sequence = []
800
+ end
801
+
802
+ def set_target_revision(target_revision)
803
+ @sequence << [:set_target_revision, target_revision]
804
+ end
805
+
806
+ def open_root(base_revision)
807
+ @sequence << [:open_root, base_revision]
808
+ end
809
+
810
+ def delete_entry(path, revision, parent_baton)
811
+ @sequence << [:delete_entry, path, revision, parent_baton]
812
+ end
813
+
814
+ def add_directory(path, parent_baton,
815
+ copyfrom_path, copyfrom_revision)
816
+ @sequence << [:add_directory, path, parent_baton,
817
+ copyfrom_path, copyfrom_revision]
818
+ end
819
+
820
+ def open_directory(path, parent_baton, base_revision)
821
+ @sequence << [:open_directory, path, parent_baton, base_revision]
822
+ end
823
+
824
+ def change_dir_prop(dir_baton, name, value)
825
+ @sequence << [:change_dir_prop, dir_baton, name, value]
826
+ end
827
+
828
+ def close_directory(dir_baton)
829
+ @sequence << [:close_directory, dir_baton]
830
+ end
831
+
832
+ def absent_directory(path, parent_baton)
833
+ @sequence << [:absent_directory, path, parent_baton]
834
+ end
835
+
836
+ def add_file(path, parent_baton,
837
+ copyfrom_path, copyfrom_revision)
838
+ @sequence << [:add_file, path, parent_baton,
839
+ copyfrom_path, copyfrom_revision]
840
+ end
841
+
842
+ def open_file(path, parent_baton, base_revision)
843
+ @sequence << [:open_file, path, parent_baton, base_revision]
844
+ end
845
+
846
+ # return nil or object which has `call' method.
847
+ def apply_textdelta(file_baton, base_checksum)
848
+ @sequence << [:apply_textdelta, file_baton, base_checksum]
849
+ nil
850
+ end
851
+
852
+ def change_file_prop(file_baton, name, value)
853
+ @sequence << [:change_file_prop, file_baton, name, value]
854
+ end
855
+
856
+ def close_file(file_baton, text_checksum)
857
+ @sequence << [:close_file, file_baton, text_checksum]
858
+ end
859
+
860
+ def absent_file(path, parent_baton)
861
+ @sequence << [:absent_file, path, parent_baton]
862
+ end
863
+
864
+ def close_edit(baton)
865
+ @sequence << [:close_edit, baton]
866
+ end
867
+
868
+ def abort_edit(baton)
869
+ @sequence << [:abort_edit, baton]
870
+ end
871
+ end
872
+ end