!35 Use Ruby API 'File.exist?' instead of deprecated 'File.exists?'

From: @zhangruifang2020 
Reviewed-by: @gaoruoshu 
Signed-off-by: @gaoruoshu
This commit is contained in:
openeuler-ci-bot 2023-08-04 03:45:12 +00:00 committed by Gitee
commit 43f922181a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 146 additions and 1 deletions

View File

@ -0,0 +1,141 @@
From 36e916ddaec4a5b1e64adee34337582f152805c5 Mon Sep 17 00:00:00 2001
From: Nathan Hartman <hartmannathan@apache.org>
Date: Sun, 9 Oct 2022 12:50:28 +0000
Subject: [PATCH] swig-rb: Use Ruby API 'File.exist?' instead of deprecated
'File.exists?'
The Ruby API 'File.exists?' has been deprecated since Ruby 2.1 and is removed
as of Ruby 3.2. Use 'File.exist?' instead, which exists at least as far back
as Ruby 1.8. (According to our configure.ac, we support Ruby 1.8.x and newer,
except between 1.9 and 1.9.3.)
* subversion/bindings/swig/ruby/svn/util.rb
(): As above.
* subversion/bindings/swig/ruby/test/test_wc.rb
(SvnWcTest::test_adm_ensure,
SvnWcTest::test_delete,
SvnWcTest::test_update_editor,
SvnWcTest::test_update_editor_options,
SvnWcTest::test_switch_editor): As above.
* subversion/bindings/swig/ruby/test/windows_util.rb
(SvnTestUtil::Windows::SetupEnvironment::gen_make_opts): As above.
Found by: Mamoru TASAKA (mtasaka {_AT_} fedoraproject (dot) org)
git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1904472 13f79535-47bb-0310-9956-ffa450edef68
---
subversion/bindings/swig/ruby/svn/util.rb | 2 +-
subversion/bindings/swig/ruby/test/test_wc.rb | 26 +++++++++----------
.../bindings/swig/ruby/test/windows_util.rb | 2 +-
3 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/subversion/bindings/swig/ruby/svn/util.rb b/subversion/bindings/swig/ruby/svn/util.rb
index d409b984c2761..f73554f5f7283 100644
--- a/subversion/bindings/swig/ruby/svn/util.rb
+++ b/subversion/bindings/swig/ruby/svn/util.rb
@@ -20,7 +20,7 @@
if /cygwin|mingw|mswin32|bccwin32/.match(RUBY_PLATFORM)
$LOAD_PATH.each do |load_path|
svn_ext_path = File.join(load_path, "svn", "ext")
- if File.exists?(svn_ext_path)
+ if File.exist?(svn_ext_path)
svn_ext_path_win = File.expand_path(svn_ext_path)
svn_ext_path_win = svn_ext_path.gsub(File::SEPARATOR, File::ALT_SEPARATOR)
unless ENV["PATH"].split(";").find {|path| path == svn_ext_path_win}
diff --git a/subversion/bindings/swig/ruby/test/test_wc.rb b/subversion/bindings/swig/ruby/test/test_wc.rb
index 763cbf6611c1b..6548d83ee978b 100644
--- a/subversion/bindings/swig/ruby/test/test_wc.rb
+++ b/subversion/bindings/swig/ruby/test/test_wc.rb
@@ -342,11 +342,11 @@ def callbacks.handle_error(path, err)
def test_adm_ensure
adm_dir = Dir.glob(File.join(@wc_path, "{.,_}svn")).first
- assert(File.exists?(adm_dir))
+ assert(File.exist?(adm_dir))
FileUtils.rm_rf(adm_dir)
- assert(!File.exists?(adm_dir))
+ assert(!File.exist?(adm_dir))
Svn::Wc.ensure_adm(@wc_path, @fs.uuid, @repos_uri, @repos_uri, 0)
- assert(File.exists?(adm_dir))
+ assert(File.exist?(adm_dir))
end
def test_merge
@@ -474,19 +474,19 @@ def test_delete
ctx.add(path)
ctx.ci(@wc_path).revision
- assert(File.exists?(path))
+ assert(File.exist?(path))
Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
access.delete(path)
end
- assert(!File.exists?(path))
+ assert(!File.exist?(path))
ctx.revert(path)
- assert(File.exists?(path))
+ assert(File.exist?(path))
Svn::Wc::AdmAccess.open(nil, @wc_path, true, 5) do |access|
access.delete(path, nil, nil, true)
end
- assert(File.exists?(path))
+ assert(File.exist?(path))
end
end
@@ -808,9 +808,9 @@ def test_update_editor
ctx.add(path2)
rev2 = ctx.commit(@wc_path).revision
- assert(File.exists?(path2))
+ assert(File.exist?(path2))
assert_equal(0, ctx.up(@wc_path, 0))
- assert(!File.exists?(path2))
+ assert(!File.exist?(path2))
Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
editor = access.update_editor('', 0)
assert_equal(0, editor.target_revision)
@@ -848,9 +848,9 @@ def test_update_editor_options
ctx.add(path2)
rev2 = ctx.commit(@wc_path).revision
- assert(File.exists?(path2))
+ assert(File.exist?(path2))
assert_equal(0, ctx.up(@wc_path, 0))
- assert(!File.exists?(path2))
+ assert(!File.exist?(path2))
notification_count = 0
Svn::Wc::AdmAccess.open(nil, @wc_path) do |access|
notify_func = Proc.new {|n| notification_count += 1}
@@ -946,9 +946,9 @@ def test_switch_editor
ctx.add(dir2_path)
rev2 = ctx.commit(@wc_path).revision
- assert(File.exists?(path1))
+ assert(File.exist?(path1))
assert_equal(rev2, ctx.switch(@wc_path, dir2_uri))
- assert(File.exists?(File.join(@wc_path, file2)))
+ assert(File.exist?(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)
diff --git a/subversion/bindings/swig/ruby/test/windows_util.rb b/subversion/bindings/swig/ruby/test/windows_util.rb
index 726527a983805..338bf8fc31c27 100644
--- a/subversion/bindings/swig/ruby/test/windows_util.rb
+++ b/subversion/bindings/swig/ruby/test/windows_util.rb
@@ -115,7 +115,7 @@ def gen_make_opts
lines = []
gen_make_opts = File.join(@@top_dir, "gen-make.opts")
lines =
- File.read(gen_make_opts).lines.to_a if File.exists?(gen_make_opts)
+ File.read(gen_make_opts).lines.to_a if File.exist?(gen_make_opts)
config = Hash.new do |hash, key|
if /^--with-(.*)$/ =~ key
hash[key] = File.join(@@top_dir, $1)
--
2.23.0

View File

@ -10,7 +10,7 @@
Summary: Subversion, a version control system.
Name: subversion
Version: 1.14.2
Release: 2
Release: 3
License: ASL 2.0
URL: https://subversion.apache.org/
@ -21,6 +21,7 @@ Patch1: subversion-1.14.0-testwarn.patch
Patch2: subversion-1.14.0-soversion.patch
Patch3: subversion-1.8.0-rubybind.patch
Patch4: subversion-1.8.5-swigplWall.patch
Patch5: backport-swig-rb-Use-Ruby-API-File.exist-instead-of-deprecate.patch
BuildRequires: autoconf libtool texinfo which swig gettext apr-devel apr-util-devel libserf-devel cyrus-sasl-devel sqlite-devel file-devel utf8proc-devel lz4-devel apr-util-openssl dbus-devel, libsecret-devel httpd-devel
Requires: httpd
@ -314,6 +315,9 @@ make check-javahl
%endif
%changelog
* Fri Aug 4 2023 zhangruifang <zhangruifang1@h-partners.com> - 1.14.2-3
- Use Ruby API 'File.exist?' instead of deprecated 'File.exists?'
* Fri Feb 03 2023 fuanan <fuanan3@h-partners.com> - 1.14.2-2
- Fix compile warning: LICENSE and NOTICE files are repeat packed