1 require "my-assertions"
9 class SvnWcTest < Test::Unit::TestCase
21 assert_equal(Svn::Core.subr_version, Svn::Wc.version)
26 file1_path = File.join(@wc_path, file1)
28 Svn::Wc::AdmAccess.open(nil, @wc_path, false, 0) do |adm|
29 status = adm.status(file1_path)
30 assert_equal(Svn::Wc::STATUS_NONE, status.text_status)
31 assert_nil(status.entry)
34 non_exist_child_path = File.join(@wc_path, "NOT-EXIST")
35 assert_nothing_raised do
36 Svn::Wc::AdmAccess.probe_open(nil, non_exist_child_path, false, 0){}
39 FileUtils.touch(file1_path)
40 Svn::Wc::AdmAccess.open(nil, @wc_path, false, 0) do |adm|
41 status = adm.status(file1_path)
42 assert_equal(Svn::Wc::STATUS_UNVERSIONED, status.text_status)
43 assert_nil(status.entry)
47 ctx = make_context(log)
49 Svn::Wc::AdmAccess.open(nil, @wc_path, false, 0) do |adm|
50 status = adm.status(file1_path)
51 assert_equal(Svn::Wc::STATUS_ADDED, status.text_status)
54 commit_info = ctx.commit(@wc_path)
56 Svn::Wc::AdmAccess.open(nil, @wc_path, false, 0) do |adm|
57 status = adm.status(file1_path)
58 assert_equal(Svn::Wc::STATUS_NORMAL, status.text_status)
59 assert_equal(commit_info.revision, status.entry.revision)
64 assert_not_equal(0, Svn::Wc.check_wc(@wc_path))
65 assert(Svn::Wc.normal_prop?("name"))
66 assert(Svn::Wc.wc_prop?("#{Svn::Core::PROP_WC_PREFIX}name"))
67 assert(Svn::Wc.entry_prop?("#{Svn::Core::PROP_ENTRY_PREFIX}name"))
72 source = "sample source"
77 dir_path = File.join(@wc_path, dir)
78 path = File.join(dir_path, file)
79 ctx = make_context(log)
82 File.open(path, "w") {|f| f.print(source)}
84 rev = ctx.ci(@wc_path).revision
86 result = Svn::Wc::AdmAccess.open_anchor(path, true, 5)
87 anchor_access, target_access, target = result
89 assert_equal(file, target)
90 assert_equal(dir_path, anchor_access.path)
91 assert_equal(dir_path, target_access.path)
93 assert(anchor_access.locked?)
94 assert(target_access.locked?)
96 assert(!target_access.has_binary_prop?(path))
97 assert(!target_access.text_modified?(path))
98 assert(!target_access.props_modified?(path))
100 File.open(path, "w") {|f| f.print(source * 2)}
101 target_access.set_prop(prop_name, prop_value, path)
102 assert_equal(prop_value, target_access.prop(prop_name, path))
103 assert_equal({prop_name => prop_value},
104 target_access.prop_list(path))
105 assert(target_access.text_modified?(path))
106 assert(target_access.props_modified?(path))
108 target_access.set_prop("name", nil, path)
109 assert(!target_access.props_modified?(path))
111 target_access.revert(path)
112 assert(!target_access.text_modified?(path))
113 assert(!target_access.props_modified?(path))
118 access = Svn::Wc::AdmAccess.probe_open(nil, path, false, 5)
119 assert(!Svn::Wc.default_ignores({}).empty?)
120 assert_equal(Svn::Wc.default_ignores({}), access.ignores({}))
121 assert(access.wc_root?(@wc_path))
123 access = Svn::Wc::AdmAccess.probe_open(nil, @wc_path, false, 5)
124 assert_equal(@wc_path, access.path)
125 assert_equal(dir_path, access.retrieve(dir_path).path)
126 assert_equal(dir_path, access.probe_retrieve(dir_path).path)
127 assert_equal(dir_path, access.probe_try(dir_path, false, 5).path)
129 Svn::Wc::AdmAccess.probe_open(nil, @wc_path, false, 5) do |access|
130 assert(!access.locked?)
133 Svn::Wc::AdmAccess.probe_open(nil, @wc_path, true, 5) do |access|
134 assert(access.locked?)
138 def test_traversal_info
139 info = Svn::Wc::TraversalInfo.new
140 assert_equal([{}, {}], info.edited_externals)
143 def assert_externals_description
145 url = "http://svn.example.com/trunk"
146 description = "#{dir} #{url}"
147 items = yield([@wc_path, description])
148 assert_equal([[dir, url]],
149 items.collect {|item| [item.target_dir, item.url]})
150 assert_kind_of(Svn::Wc::ExternalItem2, items.first)
153 def test_externals_description
154 assert_externals_description do |args|
155 Svn::Wc::ExternalsDescription.parse(*args)
159 def test_externals_description_for_backward_compatibility
160 assert_externals_description do |args|
161 Svn::Wc.parse_externals_description(*args)
167 action = Svn::Wc::NOTIFY_SKIP
168 notify = Svn::Wc::Notify.new(path, action)
169 assert_equal(path, notify.path)
170 assert_equal(action, notify.action)
173 assert_equal(path, notify2.path)
174 assert_equal(action, notify2.action)
183 path = File.join(@wc_path, file)
184 ctx = make_context(log)
186 File.open(path, "w") {|f| f.print(source1)}
188 rev1 = ctx.ci(@wc_path).revision
190 Svn::Wc::AdmAccess.open(nil, @wc_path, false, 5) do |access|
192 entry = Svn::Wc::Entry.new(path, access, show)
193 assert_equal(file, entry.name)
194 assert_equal(file, entry.dup.name)
196 entries = access.read_entries
197 assert_equal(["", file].sort, entries.keys.sort)
198 entry = entries[file]
199 assert_equal(file, entry.name)
201 assert(!entry.conflicted?(@wc_path))
204 File.open(path, "w") {|f| f.print(source2)}
205 rev2 = ctx.ci(@wc_path).revision
207 ctx.up(@wc_path, rev1)
208 File.open(path, "w") {|f| f.print(source3)}
209 ctx.up(@wc_path, rev2)
211 Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
212 entry = access.read_entries[file]
213 assert(entry.conflicted?(@wc_path))
214 assert(entry.text_conflicted?(@wc_path))
215 assert(!entry.prop_conflicted?(@wc_path))
217 access.resolved_conflict(path)
218 assert(!entry.conflicted?(@wc_path))
220 access.process_committed(@wc_path, rev2 + 1)
224 def test_committed_queue
230 path1 = File.join(@wc_path, file1)
231 path2 = File.join(@wc_path, file2)
232 ctx = make_context(log)
234 File.open(path1, "w") {|f| f.print(source1)}
235 File.open(path2, "w") {|f| f.print(source2)}
238 rev1 = ctx.ci(@wc_path).revision
241 Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
242 queue = Svn::Wc::CommittedQueue.new
243 queue.push(access, path1, true, {"my-prop" => "value"})
244 queue.process(access, next_rev)
247 Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
248 queue = Svn::Wc::CommittedQueue.new
249 queue.push(access, path1, true, [Svn::Core::Prop.new("my-prop", "value")])
250 queue.process(access, next_rev)
257 path1 = File.join(@wc_path, file1)
258 path2 = File.join(@wc_path, file2)
260 ctx = make_context(log)
262 FileUtils.touch(path1)
264 rev1 = ctx.ci(@wc_path).revision
267 rev2 = ctx.ci(@wc_path).revision
269 Svn::Wc::AdmAccess.open(nil, @wc_path, false, 5) do |access|
270 assert_equal(["#{@repos_uri}/#{file2}", rev2],
271 access.ancestry(path2))
273 callbacks = Proc.new do |path, entry|
274 result << [path, entry]
276 def callbacks.found_entry(path, entry)
279 access.walk_entries(@wc_path, callbacks)
280 assert_equal([@wc_path, path1, path2].sort,
281 result.collect{|path, entry| path}.sort)
282 entry = result.assoc(path2)[1]
283 assert_equal(file2, entry.name)
285 callbacks = Proc.new do |path, entry|
286 raise Svn::Error::Cancelled
288 def callbacks.found_entry(path, entry)
291 assert_raises(Svn::Error::Cancelled) do
292 access.walk_entries(@wc_path, callbacks)
295 def callbacks.ignored_errors=(value)
296 @ignored_errors = value
298 def callbacks.handle_error(path, err)
299 @ignored_errors << [path, err] if err
302 callbacks.ignored_errors = ignored_errors
303 access.walk_entries(@wc_path, callbacks)
305 [@wc_path, Svn::Error::Cancelled],
306 [path1, Svn::Error::Cancelled],
307 [path2, Svn::Error::Cancelled],
309 ignored_errors.collect {|path, err| [path, err.class]})
312 Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
313 assert_raises(Svn::Error::WcPathFound) do
314 access.mark_missing_deleted(path1)
317 access.mark_missing_deleted(path1)
318 access.maybe_set_repos_root(path2, @repos_uri)
323 adm_dir = Dir.glob(File.join(@wc_path, "{.,_}svn")).first
324 assert(File.exists?(adm_dir))
325 FileUtils.rm_rf(adm_dir)
326 assert(!File.exists?(adm_dir))
327 Svn::Wc.ensure_adm(@wc_path, nil, @repos_uri, nil, 0)
328 assert(File.exists?(adm_dir))
346 merge_target = <<-EOM
362 right_label = "right"
363 merge_target_label = "merge_target"
367 merge_target_file = "merge_target"
368 left_path = File.join(@wc_path, left_file)
369 right_path = File.join(@wc_path, right_file)
370 merge_target_path = File.join(@wc_path, merge_target_file)
373 ctx = make_context(log)
375 File.open(left_path, "w") {|f| f.print(left)}
376 File.open(right_path, "w") {|f| f.print(right)}
377 File.open(merge_target_path, "w") {|f| f.print(merge_target)}
380 ctx.add(merge_target_path)
384 Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
385 assert_equal(Svn::Wc::MERGE_MERGED,
386 access.merge(left_path, right_path, merge_target_path,
387 left_label, right_label, merge_target_label))
388 assert_equal(expect, File.read(merge_target_path))
399 path1 = File.join(@wc_path, file1)
400 path2 = File.join(@wc_path, file2)
401 path3 = File.join(@wc_path, file3)
402 path4 = File.join(@wc_path, file4)
403 path5 = File.join(@wc_path, file5)
405 ctx = make_context(log)
407 File.open(path1, "w") {|f| f.print(source)}
409 rev1 = ctx.ci(@wc_path).revision
412 rev2 = ctx.ci(@wc_path).revision
416 Svn::Wc::AdmAccess.open(nil, @wc_path, false, 5) do |access|
417 status = access.status(path1)
418 assert_equal(Svn::Wc::STATUS_MISSING, status.text_status)
419 assert_equal(Svn::Wc::STATUS_MISSING, status.dup.text_status)
424 Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
425 access.copy(path1, file3)
426 assert(File.exist?(path3))
428 assert(!File.exist?(path1))
429 FileUtils.touch(path4)
431 assert(File.exist?(path4))
432 access.add_repos_file2(path5, path2, {})
433 assert_equal(source, File.open(path5) {|f| f.read})
435 status = access.status(path2)
436 assert_equal(Svn::Wc::STATUS_MISSING, status.text_status)
437 access.remove_from_revision_control(file2)
438 status = access.status(path2)
439 assert_equal(Svn::Wc::STATUS_NONE, status.text_status)
446 path = File.join(@wc_path, file)
448 ctx = make_context(log)
450 File.open(path, "w") {|f| f.print(source)}
452 ctx.ci(@wc_path).revision
454 assert(File.exists?(path))
455 Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
458 assert(!File.exists?(path))
462 assert(File.exists?(path))
463 Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
464 access.delete(path, nil, nil, true)
466 assert(File.exists?(path))
470 assert(!Svn::Wc.locked?(@wc_path))
471 Svn::Wc::AdmAccess.open(nil, @wc_path, true, -1) do |access|
472 assert(Svn::Wc.locked?(@wc_path))
474 assert(!Svn::Wc.locked?(@wc_path))
475 Svn::Wc::AdmAccess.open(nil, @wc_path, false, -1) do |access|
476 assert(!Svn::Wc.locked?(@wc_path))
478 assert(!Svn::Wc.locked?(@wc_path))
481 def assert_translated_eol(method_name)
486 src_path = File.join(@wc_path, src_file)
487 crlf_path = File.join(@wc_path, crlf_file)
488 cr_path = File.join(@wc_path, cr_file)
489 lf_path = File.join(@wc_path, lf_file)
492 crlf_source = source.gsub(/\n/, "\r\n")
493 cr_source = source.gsub(/\n/, "\r")
494 lf_source = source.gsub(/\n/, "\n")
496 File.open(crlf_path, "w") {}
497 File.open(cr_path, "w") {}
498 File.open(lf_path, "w") {}
501 ctx = make_context(log)
505 ctx.prop_set("svn:eol-style", "CRLF", crlf_path)
506 ctx.prop_set("svn:eol-style", "CR", cr_path)
507 ctx.prop_set("svn:eol-style", "LF", lf_path)
512 Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
514 File.open(src_path, "wb") {|f| f.print(source)}
515 args = [method_name, src_path, crlf_path, Svn::Wc::TRANSLATE_FROM_NF]
516 result = yield(access.send(*args), source)
517 result ||= File.open(src_path, "rb") {|f| f.read}
518 assert_equal(crlf_source, result)
520 File.open(src_path, "wb") {|f| f.print(source)}
521 args = [method_name, src_path, cr_path, Svn::Wc::TRANSLATE_FROM_NF]
522 result = yield(access.send(*args), source)
523 result ||= File.open(src_path, "rb") {|f| f.read}
524 assert_equal(cr_source, result)
526 File.open(src_path, "wb") {|f| f.print(source)}
527 args = [method_name, src_path, lf_path, Svn::Wc::TRANSLATE_FROM_NF]
528 result = yield(access.send(*args), source)
529 result ||= File.open(src_path, "rb") {|f| f.read}
530 assert_equal(lf_source, result)
535 def test_translated_file_eol
536 assert_translated_eol(:translated_file) do |name, source|
537 File.open(name, "rb") {|f| f.read}
541 def test_translated_file2_eol
542 assert_translated_eol(:translated_file2) do |file, source|
547 def test_translated_stream_eol
548 assert_translated_eol(:translated_stream) do |stream, source|
559 def assert_translated_keyword(method_name)
560 src_file = "$Revision$"
561 revision_file = "revision_file"
562 src_path = File.join(@wc_path, src_file)
563 revision_path = File.join(@wc_path, revision_file)
565 source = "$Revision$\n"
566 revision_source = source.gsub(/\$Revision\$/, "$Revision: 1 $")
568 File.open(revision_path, "w") {}
571 ctx = make_context(log)
572 ctx.add(revision_path)
573 ctx.prop_set("svn:keywords", "Revision", revision_path)
574 ctx.ci(revision_path)
576 Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
577 File.open(src_path, "wb") {|f| f.print(source)}
578 args = [method_name, src_path, revision_path, Svn::Wc::TRANSLATE_FROM_NF]
579 result = yield(access.send(*args), source)
580 result ||= File.open(src_path, "rb") {|f| f.read}
581 assert_equal(revision_source, result)
583 File.open(src_path, "wb") {|f| f.print(source)}
584 args = [method_name, src_path, revision_path, Svn::Wc::TRANSLATE_TO_NF]
585 assert_equal(source, yield(access.send(*args)))
589 def test_translated_file_keyword
590 assert_translated_keyword(:translated_file) do |name, source|
591 File.open(name, "rb") {|f| f.read}
595 def test_translated_file2_keyword
596 assert_translated_keyword(:translated_file2) do |file, source|
601 def test_translated_stream_keyword
602 assert_translated_keyword(:translated_stream) do |stream, source|
613 def test_revision_status
616 path = File.join(@wc_path, file)
618 File.open(path, "w") {|f| f.print("a")}
619 ctx = make_context(log)
623 File.open(path, "w") {|f| f.print("b")}
626 File.open(path, "w") {|f| f.print("c")}
627 rev = ctx.ci(path).revision
629 status = Svn::Wc::RevisionStatus.new(path, nil, true)
630 assert_equal(rev, status.min_rev)
631 assert_equal(rev, status.max_rev)
634 def test_external_item_new
635 assert_raises(NoMethodError) do
636 Svn::Wc::ExternalItem.new
639 item = Svn::Wc::ExternalItem2.new
640 assert_kind_of(Svn::Wc::ExternalItem2, item)
643 def test_external_item_dup
644 item = Svn::Wc::ExternalItem2.new
645 assert_kind_of(Svn::Wc::ExternalItem2, item)
647 item.target_dir = "xxx"
648 duped_item = item.dup
649 assert_equal(item.target_dir, duped_item.target_dir)
652 def test_committed_queue_new
653 queue = Svn::Wc::CommittedQueue.new
654 assert_kind_of(Svn::Wc::CommittedQueue, queue)
657 def assert_diff_callbacks(method_name)
663 dir_path = File.join(@wc_path, dir)
664 path1 = File.join(dir_path, file1)
665 path2 = File.join(dir_path, file2)
666 prop_name = "my-prop"
669 ctx = make_context(log)
671 callbacks = Svn::Ra::Callbacks.new(ctx.auth_baton)
672 session = Svn::Ra::Session.open(@repos_uri, config, callbacks)
674 FileUtils.mkdir(dir_path)
675 File.open(path1, "w") {|f| f.print(src)}
677 rev1 = ctx.commit(@wc_path).revision
679 File.open(path1, "w") {|f| f.print(src * 2)}
680 File.open(path2, "w") {|f| f.print(src)}
682 ctx.prop_set(prop_name, prop_value, path1)
684 Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |adm|
685 callbacks = Object.new
689 def callbacks.result=(result)
692 def callbacks.file_added(access, path, tmpfile1, tmpfile2, rev1,
693 rev2, mimetype1, mimetype2,
694 prop_changes, original_props)
695 @result << [:file_added, path, prop_changes]
696 [Svn::Wc::NOTIFY_STATE_UNCHANGED, Svn::Wc::NOTIFY_STATE_UNCHANGED]
698 def callbacks.file_changed(access, path, tmpfile1, tmpfile2, rev1,
699 rev2, mimetype1, mimetype2,
700 prop_changes, original_props)
701 @result << [:file_changed, path, prop_changes]
702 [Svn::Wc::NOTIFY_STATE_UNCHANGED, Svn::Wc::NOTIFY_STATE_UNCHANGED]
704 def callbacks.dir_props_changed(access, path, prop_changes, original_props)
705 @result << [:dir_props_changed, path, prop_changes]
706 Svn::Wc::NOTIFY_STATE_UNCHANGED
708 callbacks.result = []
709 editor = adm.__send__(method_name, dir, callbacks)
710 reporter = session.diff(rev1, "", @repos_uri, editor)
711 adm.crawl_revisions(dir_path, reporter)
714 :dir_changed_prop_names => [
715 "svn:entry:committed-date",
717 "svn:entry:last-author",
718 "svn:entry:committed-rev"
720 :file_changed_prop_name => prop_name,
721 :file_changed_prop_value => prop_value,
723 dir_changed_props, file_changed_props, empty_changed_props = yield(args)
725 [:dir_props_changed, @wc_path, dir_changed_props],
726 [:file_changed, path1, file_changed_props],
727 [:file_added, path2, empty_changed_props],
733 def test_diff_callbacks_for_backward_compatibility
734 assert_diff_callbacks(:diff_editor) do |args|
735 dir_changed_props = args[:dir_changed_prop_names].collect do |name|
736 Svn::Core::Prop.new(name, nil)
738 prop_name = args[:file_changed_prop_name]
739 prop_value = args[:file_changed_prop_value]
740 file_changed_props = [Svn::Core::Prop.new(prop_name, prop_value)]
741 empty_changed_props = []
742 [dir_changed_props, file_changed_props, empty_changed_props]
746 def test_diff_callbacks
747 assert_diff_callbacks(:diff_editor2) do |args|
748 dir_changed_props = {}
749 args[:dir_changed_prop_names].each do |name|
750 dir_changed_props[name] = nil
752 prop_name = args[:file_changed_prop_name]
753 prop_value = args[:file_changed_prop_value]
754 file_changed_props = {prop_name => prop_value}
755 empty_changed_props = {}
756 [dir_changed_props, file_changed_props, empty_changed_props]
760 def test_update_editor
766 dir_path = File.join(@wc_path, dir)
767 path1 = File.join(dir_path, file1)
768 path2 = File.join(dir_path, file2)
770 ctx = make_context(log)
772 callbacks = Svn::Ra::Callbacks.new(ctx.auth_baton)
773 session = Svn::Ra::Session.open(@repos_uri, config, callbacks)
775 FileUtils.mkdir(dir_path)
776 File.open(path1, "w") {|f| f.print(src)}
778 rev1 = ctx.commit(@wc_path).revision
780 File.open(path1, "w") {|f| f.print(src * 2)}
781 File.open(path2, "w") {|f| f.print(src)}
783 rev2 = ctx.commit(@wc_path).revision
785 assert(File.exists?(path2))
786 assert_equal(0, ctx.up(@wc_path, 0))
787 assert(!File.exists?(path2))
788 Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
789 editor = access.update_editor(@wc_path, 0)
790 assert_equal(0, editor.target_revision)
792 reporter = session.update2(rev2, "", editor)
793 access.crawl_revisions(@wc_path, reporter)
794 assert_equal(rev2, editor.target_revision)
798 def test_update_editor_options
804 dir_path = File.join(@wc_path, dir)
805 path1 = File.join(dir_path, file1)
806 path2 = File.join(dir_path, file2)
808 ctx = make_context(log)
810 callbacks = Svn::Ra::Callbacks.new(ctx.auth_baton)
811 session = Svn::Ra::Session.open(@repos_uri)
813 FileUtils.mkdir(dir_path)
814 File.open(path1, "w") {|f| f.print(src)}
816 rev1 = ctx.commit(@wc_path).revision
818 File.open(path1, "w") {|f| f.print(src * 2)}
819 File.open(path2, "w") {|f| f.print(src)}
821 rev2 = ctx.commit(@wc_path).revision
823 assert(File.exists?(path2))
824 assert_equal(0, ctx.up(@wc_path, 0))
825 assert(!File.exists?(path2))
826 notification_count = 0
827 Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
828 notify_func = Proc.new {|n| notification_count += 1}
829 assert_raises(ArgumentError) do
830 access.update_editor2(:target_revision => 0,
832 :notify_fun => notify_func)
834 editor = access.update_editor(@wc_path, 0, true, nil, false, nil,
836 assert_equal(0, editor.target_revision)
838 reporter = session.update2(rev2, "", editor)
839 access.crawl_revisions(@wc_path, reporter)
840 assert_equal(rev2, editor.target_revision)
842 assert_equal(4, notification_count, "wrong number of notifications")
845 def test_update_editor2_conflict_func
851 path = File.join(@wc_path, file)
852 ctx = make_context(log)
854 File.open(path, "w") {|f| f.print(source1)}
856 rev1 = ctx.ci(@wc_path).revision
858 File.open(path, "w") {|f| f.print(source2)}
859 rev2 = ctx.ci(@wc_path).revision
861 ctx.up(@wc_path, rev1)
862 File.open(path, "w") {|f| f.print(source3)}
864 session = Svn::Ra::Session.open(@repos_uri)
866 conflicted_paths = {}
868 Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
869 editor = access.update_editor2(
871 :conflict_func => lambda{|n|
872 conflicted_paths[n.path]=true
873 Svn::Wc::CONFLICT_CHOOSE_MERGED
875 :target_revision => 0
878 assert_equal(0, editor.target_revision)
880 reporter = session.update2(rev2, "", editor)
881 access.crawl_revisions(@wc_path, reporter)
882 assert_equal(rev2, editor.target_revision)
885 assert_equal([path], conflicted_paths.keys);
888 def test_switch_editor
895 dir1_path = File.join(@wc_path, dir1)
896 dir2_path = File.join(@wc_path, dir2)
897 dir1_uri = "#{@repos_uri}/#{dir1}"
898 dir2_uri = "#{@repos_uri}/#{dir2}"
899 path1 = File.join(dir1_path, file1)
900 path2 = File.join(dir2_path, file2)
902 ctx = make_context(log)
904 callbacks = Svn::Ra::Callbacks.new(ctx.auth_baton)
905 session = Svn::Ra::Session.open(@repos_uri, config, callbacks)
907 FileUtils.mkdir(dir1_path)
908 File.open(path1, "w") {|f| f.print(src)}
910 rev1 = ctx.commit(@wc_path).revision
912 FileUtils.mkdir(dir2_path)
913 File.open(path2, "w") {|f| f.print(src)}
915 rev2 = ctx.commit(@wc_path).revision
917 assert(File.exists?(path1))
918 assert_equal(rev2, ctx.switch(@wc_path, dir2_uri))
919 assert(File.exists?(File.join(@wc_path, file2)))
920 Svn::Wc::AdmAccess.open_anchor(@wc_path) do |access, dir_access, target|
921 editor = dir_access.switch_editor(@wc_path, dir1_uri, rev2)
922 assert_equal(rev2, editor.target_revision)
924 reporter = session.switch2(rev1, dir1, dir1_uri, editor)
925 dir_access.crawl_revisions(@wc_path, reporter)
926 assert_equal(rev1, editor.target_revision)
937 dir1_path = File.join(@wc_path, dir1)
938 dir2_path = File.join(@wc_path, dir2)
939 dir1_uri = "#{@repos_uri}/#{dir1}"
940 dir2_uri = "#{@repos_uri}/#{dir2}"
941 path1 = File.join(dir1_path, file1)
942 path2 = File.join(dir2_path, file2)
944 ctx = make_context(log)
946 callbacks = Svn::Ra::Callbacks.new(ctx.auth_baton)
947 session = Svn::Ra::Session.open(@repos_uri, config, callbacks)
949 FileUtils.mkdir(dir1_path)
950 File.open(path1, "w") {|f| f.print(src)}
952 rev1 = ctx.commit(@wc_path).revision
954 FileUtils.mkdir(dir2_path)
955 File.open(path2, "w") {|f| f.print(src)}
957 rev2 = ctx.commit(@wc_path).revision
959 Svn::Wc::AdmAccess.probe_open(nil, @wc_path) do |access|
960 assert(@repos_uri, access.entry(@wc_path).url)
962 access.relocate(@wc_path, @repos_uri, dir2_uri) do |uuid, url, root_url|
963 values << [uuid, url, root_url]
966 [@fs.uuid, dir2_uri, nil],
967 [@fs.uuid, dir2_uri, dir2_uri],
968 [nil, "#{dir2_uri}/#{dir1}", dir2_uri],
969 [nil, "#{dir2_uri}/#{dir1}/#{file1}", dir2_uri],
970 [nil, "#{dir2_uri}/#{dir2}", dir2_uri],
971 [nil, "#{dir2_uri}/#{dir2}/#{file2}", dir2_uri],
974 assert(dir2_uri, access.entry(@wc_path).url)
979 assert(!Svn::Wc.ignore?("xxx.c", []))
980 assert(Svn::Wc.ignore?("xxx.c", ["*.c"]))
981 assert(!Svn::Wc.ignore?("xxx.c", ["XXX.c"]))
982 assert(Svn::Wc.ignore?("xxx.c", ["xxx.c"]))
983 assert(!Svn::Wc.ignore?("xxx.c", ["*.H", "*.C"]))
984 assert(Svn::Wc.ignore?("xxx.C", ["*.H", "*.C"]))
991 path = File.join(@wc_path, file)
993 ctx = make_context(log)
994 File.open(path, "w") {|f| f.print(src)}
996 rev1 = ctx.commit(@wc_path).revision
998 Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
999 assert_nil(access.entry(@wc_path).changelist)
1003 notify_collector = Proc.new {|notify| notifies << notify }
1004 Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
1005 access.set_changelist(path, "123", nil, notify_collector)
1007 assert_equal([[path, nil]],
1008 notifies.collect {|notify| [notify.path, notify.err]})
1011 Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
1012 access.set_changelist(path, "456", nil, notify_collector)
1014 assert_equal([[path, Svn::Error::WcChangelistMove],
1016 notifies.collect {|notify| [notify.path, notify.err.class]})
1020 assert_raises(Svn::Error::ClientIsDirectory) do
1021 Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
1022 access.set_changelist(@wc_path, "789", nil, notify_collector)