Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/bindings/swig/ruby/test/test_repos.rb view on Meta::CPAN
@repos.file_revs(*args) do |path, rev, rev_props, prop_diffs|
hashed_prop_diffs = {}
prop_diffs.each do |prop|
hashed_prop_diffs[prop.name] = prop.value
end
revs << [path, rev, hashed_prop_diffs]
end
assert_equal([
["/#{file}", info1.revision, {}],
["/#{file}", info2.revision, {}],
["/#{file}", info3.revision, props],
],
revs)
revs = []
@repos.file_revs2(*args) do |path, rev, rev_props, prop_diffs|
revs << [path, rev, prop_diffs]
end
assert_equal([
["/#{file}", info1.revision, {}],
["/#{file}", info2.revision, {}],
["/#{file}", info3.revision, props],
],
revs)
rev, date, author = @repos.fs.root.committed_info("/")
assert_equal(info3.revision, rev)
assert_equal(info3.date, date)
assert_equal(info3.author, author)
ensure
ctx3.destroy unless ctx3.nil?
ctx2.destroy unless ctx2.nil?
ctx1.destroy unless ctx1.nil?
end
def test_hotcopy
log = "sample log"
file = "hello.txt"
path = File.join(@wc_path, file)
FileUtils.touch(path)
# So we can later rename files when running the tests on
# Windows, close access to the repos created by the test setup.
test_repos_path = @repos.path
@repos.close
@repos = nil
@fs.close
@fs = nil
rev = make_context(log) do |ctx|
ctx.add(path)
commit_info = ctx.commit(@wc_path)
rev = commit_info.revision
assert_equal(log, ctx.log_message(path, rev))
rev
end
dest_path = File.join(@tmp_path, "dest")
backup_path = File.join(@tmp_path, "back")
config = {}
fs_config = {}
dest_repos = Svn::Repos.create(dest_path, config, fs_config)
dest_repos.fs.set_warning_func(&warning_func)
dest_repos_path = dest_repos.path
dest_repos.close
FileUtils.mv(test_repos_path, backup_path)
FileUtils.mv(dest_repos_path, test_repos_path)
make_context(log) do |ctx|
assert_raises(Svn::Error::FsNoSuchRevision) do
assert_equal(log, ctx.log_message(path, rev))
end
FileUtils.rm_r(test_repos_path)
Svn::Repos.hotcopy(backup_path, test_repos_path)
assert_equal(log, ctx.log_message(path, rev))
end
end
def assert_transaction
log = "sample log"
make_context(log) do |ctx|
ctx.checkout(@repos_uri, @wc_path)
ctx.mkdir(["#{@wc_path}/new_dir"])
prev_rev = @repos.youngest_rev
past_date = Time.now
args = {
:author => @author,
:log => log,
:revision => prev_rev,
}
callback = Proc.new do |txn|
txn.abort
end
yield(:commit, @repos, args, callback)
assert_equal(prev_rev, @repos.youngest_rev)
assert_equal(prev_rev, @repos.dated_revision(past_date))
prev_rev = @repos.youngest_rev
@repos.transaction_for_commit(@author, log) do |txn|
end
assert_equal(prev_rev + 1, @repos.youngest_rev)
assert_equal(prev_rev, @repos.dated_revision(past_date))
assert_equal(prev_rev + 1, @repos.dated_revision(Time.now))
prev_rev = @repos.youngest_rev
args = {
:author => @author,
:revision => prev_rev,
}
callback = Proc.new do |txn|
end
yield(:update, @repos, args, callback)
assert_equal(prev_rev, @repos.youngest_rev)
end
end
def test_transaction
assert_transaction do |type, repos, args, callback|
case type
when :commit
repos.transaction_for_commit(args[:author], args[:log], &callback)
when :update
repos.transaction_for_update(args[:author], &callback)
end
end
end
def test_transaction_with_revision
assert_transaction do |type, repos, args, callback|
case type
when :commit
repos.transaction_for_commit(args[:author], args[:log],
args[:revision], &callback)
( run in 0.442 second using v1.01-cache-2.11-cpan-97f6503c9c8 )