⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_repos.rb

📁 subversion-1.4.3-1.tar.gz 配置svn的源码
💻 RB
📖 第 1 页 / 共 2 页
字号:
                 editor.sequence.collect{|meth, *args| meth})  end  def test_commit_editor    trunk = "trunk"    tags = "tags"    tags_sub = "sub"    file = "file"    source = "sample source"    trunk_dir_path = File.join(@wc_path, trunk)    tags_dir_path = File.join(@wc_path, tags)    tags_sub_dir_path = File.join(tags_dir_path, tags_sub)    trunk_path = File.join(trunk_dir_path, file)    tags_path = File.join(tags_dir_path, file)    tags_sub_path = File.join(tags_sub_dir_path, file)    trunk_repos_uri = "#{@repos_uri}/#{trunk}"    rev1 = @repos.youngest_rev        editor = @repos.commit_editor(@repos_uri, "/")    root_baton = editor.open_root(rev1)    dir_baton = editor.add_directory(trunk, root_baton, nil, rev1)    file_baton = editor.add_file("#{trunk}/#{file}", dir_baton, nil, -1)    ret = editor.apply_textdelta(file_baton, nil)    ret.send(source)    editor.close_edit        assert_equal(rev1 + 1, @repos.youngest_rev)    rev2 = @repos.youngest_rev        ctx = make_context("")    ctx.up(@wc_path)    assert_equal(source, File.open(trunk_path) {|f| f.read})    editor = @repos.commit_editor(@repos_uri, "/")    root_baton = editor.open_root(rev2)    dir_baton = editor.add_directory(tags, root_baton, nil, rev2)    subdir_baton = editor.add_directory("#{tags}/#{tags_sub}",                                        dir_baton,                                        trunk_repos_uri,                                        rev2)    editor.close_edit        assert_equal(rev2 + 1, @repos.youngest_rev)    rev3 = @repos.youngest_rev        ctx.up(@wc_path)    assert_equal([                   ["/#{tags}/#{tags_sub}/#{file}", rev3],                   ["/#{trunk}/#{file}", rev2],                 ],                 @repos.fs.history("#{tags}/#{tags_sub}/#{file}",                                   rev1, rev3, rev2))    editor = @repos.commit_editor(@repos_uri, "/")    root_baton = editor.open_root(rev3)    dir_baton = editor.delete_entry(tags, rev3, root_baton)    editor.close_edit    ctx.up(@wc_path)    assert(!File.exist?(tags_path))  end  def test_prop    file = "file"    path = File.join(@wc_path, file)    source = "sample source"    log = "sample log"    ctx = make_context(log)    File.open(path, "w") {|f| f.print(source)}    ctx.add(path)    ctx.ci(@wc_path)    assert_equal([                   Svn::Core::PROP_REVISION_AUTHOR,                   Svn::Core::PROP_REVISION_LOG,                   Svn::Core::PROP_REVISION_DATE,                 ].sort,                 @repos.proplist.keys.sort)    assert_equal(log, @repos.prop(Svn::Core::PROP_REVISION_LOG))    @repos.set_prop(@author, Svn::Core::PROP_REVISION_LOG, nil)    assert_nil(@repos.prop(Svn::Core::PROP_REVISION_LOG))    assert_equal([                   Svn::Core::PROP_REVISION_AUTHOR,                   Svn::Core::PROP_REVISION_DATE,                 ].sort,                 @repos.proplist.keys.sort)  end    def test_load    file = "file"    path = File.join(@wc_path, file)    source = "sample source"    log = "sample log"    ctx = make_context(log)    File.open(path, "w") {|f| f.print(source)}    ctx.add(path)    rev1 = ctx.ci(@wc_path).revision    File.open(path, "a") {|f| f.print(source)}    rev2 = ctx.ci(@wc_path).revision    dest_path = File.join(@tmp_path, "dest")    repos = Svn::Repos.create(dest_path)    assert_not_equal(@repos.fs.root.committed_info("/"),                     repos.fs.root.committed_info("/"))    dump = Tempfile.new("dump")    feedback = Tempfile.new("feedback")    dump.open    feedback.open    @repos.dump_fs(dump, feedback, rev1, rev2)    dump.close    feedback.close    dump.open    feedback.open    repos.load_fs(dump, feedback, Svn::Repos::LOAD_UUID_DEFAULT, "/")    assert_equal(@repos.fs.root.committed_info("/"),                 repos.fs.root.committed_info("/"))  end  def test_node_editor    file = "file"    dir1 = "dir1"    dir2 = "dir2"    dir3 = "dir3"    dir1_path = File.join(@wc_path, dir1)    dir2_path = File.join(dir1_path, dir2)    dir3_path = File.join(dir2_path, dir3)    path = File.join(dir3_path, file)    source = "sample source"    log = "sample log"        ctx = make_context(log)    FileUtils.mkdir_p(dir3_path)    FileUtils.touch(path)    ctx.add(dir1_path)    rev1 = ctx.ci(@wc_path).revision    ctx.rm(dir3_path)    rev2 = ctx.ci(@wc_path).revision    rev1_root = @repos.fs.root(rev1)    rev2_root = @repos.fs.root(rev2)    editor = @repos.node_editor(rev1_root, rev2_root)    rev2_root.replay(editor)    tree = editor.baton.node    assert_equal("", tree.name)    assert_equal(dir1, tree.child.name)    assert_equal(dir2, tree.child.child.name)  end  def test_lock    file = "file"    log = "sample log"    path = File.join(@wc_path, file)    path_in_repos = "/#{file}"    ctx = make_context(log)        FileUtils.touch(path)    ctx.add(path)    rev = ctx.ci(@wc_path).revision        access = Svn::Fs::Access.new(@author)    @repos.fs.access = access    lock = @repos.lock(file)    locks = @repos.get_locks(file)    assert_equal([path_in_repos], locks.keys)    assert_equal(lock.token, locks[path_in_repos].token)    @repos.unlock(file, lock.token)    assert_equal({}, @repos.get_locks(file))  end  def test_authz    name = "REPOS"    conf_path = File.join(@tmp_path, "authz_file")    File.open(conf_path, "w") do |f|      f.print(<<-EOF)[/]#{@author} = rEOF    end        authz = Svn::Repos::Authz.read(conf_path)    assert(authz.can_access?(name, "/", @author, Svn::Repos::AUTHZ_READ))    assert(!authz.can_access?(name, "/", @author, Svn::Repos::AUTHZ_WRITE))    assert(!authz.can_access?(name, "/", "FOO", Svn::Repos::AUTHZ_READ))  end  def warning_func    Proc.new do |err|      STDERR.puts err if $DEBUG    end  end    class TestEditor < Svn::Delta::BaseEditor    attr_reader :sequence    def initialize      @sequence = []    end        def set_target_revision(target_revision)      @sequence << [:set_target_revision, target_revision]    end        def open_root(base_revision)      @sequence << [:open_root, base_revision]    end        def delete_entry(path, revision, parent_baton)      @sequence << [:delete_entry, path, revision, parent_baton]    end        def add_directory(path, parent_baton,                      copyfrom_path, copyfrom_revision)      @sequence << [:add_directory, path, parent_baton,        copyfrom_path, copyfrom_revision]    end        def open_directory(path, parent_baton, base_revision)      @sequence << [:open_directory, path, parent_baton, base_revision]    end        def change_dir_prop(dir_baton, name, value)      @sequence << [:change_dir_prop, dir_baton, name, value]    end        def close_directory(dir_baton)      @sequence << [:close_directory, dir_baton]    end        def absent_directory(path, parent_baton)      @sequence << [:absent_directory, path, parent_baton]    end        def add_file(path, parent_baton,                 copyfrom_path, copyfrom_revision)      @sequence << [:add_file, path, parent_baton,        copyfrom_path, copyfrom_revision]    end        def open_file(path, parent_baton, base_revision)      @sequence << [:open_file, path, parent_baton, base_revision]    end        # return nil or object which has `call' method.    def apply_textdelta(file_baton, base_checksum)      @sequence << [:apply_textdelta, file_baton, base_checksum]      nil    end        def change_file_prop(file_baton, name, value)      @sequence << [:change_file_prop, file_baton, name, value]    end        def close_file(file_baton, text_checksum)      @sequence << [:close_file, file_baton, text_checksum]    end        def absent_file(path, parent_baton)      @sequence << [:absent_file, path, parent_baton]    end        def close_edit(baton)      @sequence << [:close_edit, baton]    end        def abort_edit(baton)      @sequence << [:abort_edit, baton]    end  endend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -