Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/ruby/test/test_wc.rb view on Meta::CPAN
Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
notify_func = Proc.new {|n| notification_count += 1}
assert_raises(ArgumentError) do
access.update_editor2(:target_revision => 0,
:target => '',
:notify_fun => notify_func)
end
editor = access.update_editor('', 0, true, nil, false, nil,
notify_func)
assert_equal(0, editor.target_revision)
reporter = session.update2(rev2, "", editor)
access.crawl_revisions(@wc_path, reporter)
assert_equal(rev2, editor.target_revision)
end
assert_equal(4, notification_count, "wrong number of notifications")
end
end
end
def test_update_editor2_conflict_func
log = "sample log"
source1 = "source"
source2 = "SOURCE"
source3 = "SHOYU"
file = "file"
path = File.join(@wc_path, file)
make_context(log) do |ctx|
File.open(path, "w") {|f| f.print(source1)}
ctx.add(path)
rev1 = ctx.ci(@wc_path).revision
File.open(path, "w") {|f| f.print(source2)}
rev2 = ctx.ci(@wc_path).revision
ctx.up(@wc_path, rev1)
File.open(path, "w") {|f| f.print(source3)}
Svn::Ra::Session.open(@repos_uri) do |session|
conflicted_paths = {}
Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
editor = access.update_editor2(
:target => '',
:conflict_func => lambda{|n|
conflicted_paths[n.path]=true
Svn::Wc::CONFLICT_CHOOSE_MERGED
},
:target_revision => 0
)
assert_equal(0, editor.target_revision)
reporter = session.update2(rev2, "", editor)
access.crawl_revisions(@wc_path, reporter)
assert_equal(rev2, editor.target_revision)
end
assert_equal([File.expand_path(path)], conflicted_paths.keys);
end
end
end
def test_switch_editor
log = "sample log"
file1 = "hello.txt"
file2 = "hello2.txt"
src = "Hello"
dir1 = "dir1"
dir2 = "dir2"
dir1_path = File.join(@wc_path, dir1)
dir2_path = File.join(@wc_path, dir2)
dir1_uri = "#{@repos_uri}/#{dir1}"
dir2_uri = "#{@repos_uri}/#{dir2}"
path1 = File.join(dir1_path, file1)
path2 = File.join(dir2_path, file2)
make_context(log) do |ctx|
config = {}
callbacks = Svn::Ra::Callbacks.new(ctx.auth_baton)
Svn::Ra::Session.open(@repos_uri, config, callbacks) do |session|
FileUtils.mkdir(dir1_path)
File.open(path1, "w") {|f| f.print(src)}
ctx.add(dir1_path)
rev1 = ctx.commit(@wc_path).revision
FileUtils.mkdir(dir2_path)
File.open(path2, "w") {|f| f.print(src)}
ctx.add(dir2_path)
rev2 = ctx.commit(@wc_path).revision
assert(File.exists?(path1))
assert_equal(rev2, ctx.switch(@wc_path, dir2_uri))
assert(File.exists?(File.join(@wc_path, file2)))
Svn::Wc::AdmAccess.open_anchor(@wc_path) do |access, dir_access, target|
editor = dir_access.switch_editor('', dir1_uri, rev2)
assert_equal(rev2, editor.target_revision)
reporter = session.switch2(rev1, dir1, dir1_uri, editor)
dir_access.crawl_revisions(@wc_path, reporter)
assert_equal(rev1, editor.target_revision)
end
end
end
end
def test_relocate
log = "sample log"
file1 = "hello.txt"
file2 = "hello2.txt"
src = "Hello"
dir1 = "dir1"
dir2 = "dir2"
dir1_path = File.join(@wc_path, dir1)
dir2_path = File.join(@wc_path, dir2)
dir1_uri = "#{@repos_uri}/#{dir1}"
dir2_uri = "#{@repos_uri}/#{dir2}"
path1 = File.join(dir1_path, file1)
path2 = File.join(dir2_path, file2)
make_context(log) do |ctx|
config = {}
callbacks = Svn::Ra::Callbacks.new(ctx.auth_baton)
Svn::Ra::Session.open(@repos_uri, config, callbacks) do |session|
FileUtils.mkdir(dir1_path)
File.open(path1, "w") {|f| f.print(src)}
ctx.add(dir1_path)
rev1 = ctx.commit(@wc_path).revision
FileUtils.mkdir(dir2_path)
File.open(path2, "w") {|f| f.print(src)}
ctx.add(dir2_path)
rev2 = ctx.commit(@wc_path).revision
Svn::Wc::AdmAccess.probe_open(nil, @wc_path) do |access|
assert(@repos_uri, access.entry(@wc_path).url)
values = []
access.relocate(@wc_path, @repos_uri, dir2_uri) do |uuid, url, root_url|
values << [uuid, url, root_url]
end
assert(!values.empty?)
assert(dir2_uri, access.entry(@wc_path).url)
end
end
end
end
def test_ignore?
assert(!Svn::Wc.ignore?("xxx.c", []))
assert(Svn::Wc.ignore?("xxx.c", ["*.c"]))
assert(!Svn::Wc.ignore?("xxx.c", ["XXX.c"]))
assert(Svn::Wc.ignore?("xxx.c", ["xxx.c"]))
assert(!Svn::Wc.ignore?("xxx.c", ["*.H", "*.C"]))
assert(Svn::Wc.ignore?("xxx.C", ["*.H", "*.C"]))
end
def test_changelist
log = "sample log"
file = "hello.txt"
src = "Hello"
path = File.join(@wc_path, file)
make_context(log) do |ctx|
File.open(path, "w") {|f| f.print(src)}
ctx.add(path)
rev1 = ctx.commit(@wc_path).revision
end
Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
assert_nil(access.entry(@wc_path).changelist)
end
notifies = []
notify_collector = Proc.new {|notify| notifies << notify }
Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
access.set_changelist(path, "123", nil, notify_collector)
end
assert_equal([[File.expand_path(path), nil]],
notifies.collect {|notify| [notify.path, notify.err]})
notifies = []
Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
access.set_changelist(path, "456", nil, notify_collector)
end
assert_equal([[File.expand_path(path), Svn::Wc::NOTIFY_CHANGELIST_CLEAR],
[File.expand_path(path), Svn::Wc::NOTIFY_CHANGELIST_SET]],
notifies.collect {|notify| [notify.path, notify.action]})
notifies = []
Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
access.set_changelist(@wc_path, "789", nil, notify_collector)
end
end
def test_context_new_default_config
assert_not_nil context = Svn::Wc::Context.new
ensure
context.destroy
end
def test_context_new_specified_config
config_file = File.join(@config_path, Svn::Core::CONFIG_CATEGORY_CONFIG)
config = Svn::Core::Config.read(config_file)
assert_not_nil context = Svn::Wc::Context.new(:config=>config)
ensure
context.destroy
end
def test_context_create
assert_nothing_raised do
result = Svn::Wc::Context.create do |context|
assert_not_nil context
assert_kind_of Svn::Wc::Context, context
end
if RUBY_VERSION > '1.9'
assert_equal(result,true)
else
assert_nil result
end
end
end
end
( run in 0.530 second using v1.01-cache-2.11-cpan-5623c5533a1 )