<commit_before>require "English"
require "svn/error"
require "svn/util"
require "svn/core"
require "svn/fs"
require "svn/client"
require "svn/ext/repos"

module Svn
  module Repos
    Util.set_constants(Ext::Repos, self)
    Util.set_methods(Ext::Repos, self)


    @@alias_targets = %w(create hotcopy recover db_logfiles)
    class << self
      @@alias_targets.each do |target|
        alias_method "_#{target}", target
      end
    end
    @@alias_targets.each do |target|
      alias_method "_#{target}", target
    end
    @@alias_targets = nil

    module_function
    def create(path, config={}, fs_config={}, &block)
      _create(path, nil, nil, config, fs_config, &block)
    end

    def hotcopy(src, dest, clean_logs=true)
      _hotcopy(src, dest, clean_logs)
    end

    def recover(path, nonblocking=false, cancel_func=nil, &start_callback)
      recover3(path, nonblocking, start_callback, cancel_func)
    end

    def db_logfiles(path, only_unused=true)
      _db_logfiles(path, only_unused)
    end

    def read_authz(file, must_exist=true)
      Repos.authz_read(file, must_exist)
    end

    ReposCore = SWIG::TYPE_p_svn_repos_t
    class ReposCore
      class << self
        def def_simple_delegate(*ids)
          ids.each do |id|
            module_eval(<<-EOC, __FILE__, __LINE__)
            def #{id.to_s}
              Repos.#{id.to_s}(self)
            end
            EOC
          end
        end
      end

      def_simple_delegate :path, :db_env, :conf_dir
      def_simple_delegate :svnserve_conf, :lock_dir
      def_simple_delegate :db_lockfile, :db_logs_lockfile
      def_simple_delegate :hook_dir, :start_commit_hook
      def_simple_delegate :pre_commit_hook, :post_commit_hook
      def_simple_delegate :pre_revprop_change_hook, :post_revprop_change_hook
      def_simple_delegate :pre_lock_hook, :post_lock_hook
      def_simple_delegate :pre_unlock_hook, :post_unlock_hook

      attr_reader :authz_read_func

      def fs
        Repos.fs_wrapper(self)
      end

      def set_authz_read_func(&block)
        @authz_read_func = block
      end

      def report(rev, username, fs_base, target, tgt_path,
                 editor, text_deltas=true, recurse=true,
                 ignore_ancestry=false, authz_read_func=nil)
        authz_read_func ||= @authz_read_func
        args = [
          rev, username, self, fs_base, target, tgt_path,
          text_deltas, recurse, ignore_ancestry, editor,
          authz_read_func,
        ]
        report_baton = Repos.begin_report(*args)
        setup_report_baton(report_baton)
        if block_given?
          report_baton.set_path("", rev)
          result = yield(report_baton)
          report_baton.finish_report unless report_baton.aborted?
          result
        else
          report_baton
        end
      end

      def report2(rev, fs_base, target, tgt_path, editor, text_deltas=true,
                  ignore_ancestry=false, depth=nil, authz_read_func=nil)
        authz_read_func ||= @authz_read_func
        args = [
          rev, self, fs_base, target, tgt_path, text_deltas,
          ignore_ancestry, editor, authz_read_func,
        ]
        report_baton = Repos.begin_report2(*args)
        setup_report_baton(report_baton)
        if block_given?
          report_baton.set_path("", rev, false, nil, depth)
          result = yield(report_baton)
          report_baton.finish_report unless report_baton.aborted?
          result
        else
          report_baton
        end
      end

      def commit_editor(repos_url, base_path, txn=nil, user=nil,
                        log_msg=nil, commit_callback=nil,
                        authz_callback=nil)
        editor, baton = Repos.get_commit_editor3(self, txn, repos_url,
                                                 base_path, user, log_msg,
                                                 commit_callback,
                                                 authz_callback)
        editor.baton = baton
        editor
      end

      def commit_editor2(repos_url, base_path, txn=nil, user=nil,
                         log_msg=nil, commit_callback=nil,
                         authz_callback=nil)
        editor, baton = Repos.get_commit_editor4(self, txn, repos_url,<commit_msg>Follow on to r26222 which added a depth argument to svn_repos_begin_report2.<commit_after>require "English"
require "svn/error"
require "svn/util"
require "svn/core"
require "svn/fs"
require "svn/client"
require "svn/ext/repos"

module Svn
  module Repos
    Util.set_constants(Ext::Repos, self)
    Util.set_methods(Ext::Repos, self)


    @@alias_targets = %w(create hotcopy recover db_logfiles)
    class << self
      @@alias_targets.each do |target|
        alias_method "_#{target}", target
      end
    end
    @@alias_targets.each do |target|
      alias_method "_#{target}", target
    end
    @@alias_targets = nil

    module_function
    def create(path, config={}, fs_config={}, &block)
      _create(path, nil, nil, config, fs_config, &block)
    end

    def hotcopy(src, dest, clean_logs=true)
      _hotcopy(src, dest, clean_logs)
    end

    def recover(path, nonblocking=false, cancel_func=nil, &start_callback)
      recover3(path, nonblocking, start_callback, cancel_func)
    end

    def db_logfiles(path, only_unused=true)
      _db_logfiles(path, only_unused)
    end

    def read_authz(file, must_exist=true)
      Repos.authz_read(file, must_exist)
    end

    ReposCore = SWIG::TYPE_p_svn_repos_t
    class ReposCore
      class << self
        def def_simple_delegate(*ids)
          ids.each do |id|
            module_eval(<<-EOC, __FILE__, __LINE__)
            def #{id.to_s}
              Repos.#{id.to_s}(self)
            end
            EOC
          end
        end
      end

      def_simple_delegate :path, :db_env, :conf_dir
      def_simple_delegate :svnserve_conf, :lock_dir
      def_simple_delegate :db_lockfile, :db_logs_lockfile
      def_simple_delegate :hook_dir, :start_commit_hook
      def_simple_delegate :pre_commit_hook, :post_commit_hook
      def_simple_delegate :pre_revprop_change_hook, :post_revprop_change_hook
      def_simple_delegate :pre_lock_hook, :post_lock_hook
      def_simple_delegate :pre_unlock_hook, :post_unlock_hook

      attr_reader :authz_read_func

      def fs
        Repos.fs_wrapper(self)
      end

      def set_authz_read_func(&block)
        @authz_read_func = block
      end

      def report(rev, username, fs_base, target, tgt_path,
                 editor, text_deltas=true, recurse=true,
                 ignore_ancestry=false, authz_read_func=nil)
        authz_read_func ||= @authz_read_func
        args = [
          rev, username, self, fs_base, target, tgt_path,
          text_deltas, recurse, ignore_ancestry, editor,
          authz_read_func,
        ]
        report_baton = Repos.begin_report(*args)
        setup_report_baton(report_baton)
        if block_given?
          report_baton.set_path("", rev)
          result = yield(report_baton)
          report_baton.finish_report unless report_baton.aborted?
          result
        else
          report_baton
        end
      end

      def report2(rev, fs_base, target, tgt_path, editor, text_deltas=true,
                  ignore_ancestry=false, depth=nil, authz_read_func=nil)
        authz_read_func ||= @authz_read_func
        args = [
          rev, self, fs_base, target, tgt_path, text_deltas,
          depth, ignore_ancestry, editor, authz_read_func,
        ]
        report_baton = Repos.begin_report2(*args)
        setup_report_baton(report_baton)
        if block_given?
          report_baton.set_path("", rev, false, nil, depth)
          result = yield(report_baton)
          report_baton.finish_report unless report_baton.aborted?
          result
        else
          report_baton
        end
      end

      def commit_editor(repos_url, base_path, txn=nil, user=nil,
                        log_msg=nil, commit_callback=nil,
                        authz_callback=nil)
        editor, baton = Repos.get_commit_editor3(self, txn, repos_url,
                                                 base_path, user, log_msg,
                                                 commit_callback,
                                                 authz_callback)
        editor.baton = baton
        editor
      end

      def commit_editor2(repos_url, base_path, txn=nil, user=nil,
                         log_msg=nil, commit_callback=nil,
                         authz_callback=nil)
        editor, baton = Repos.get_commit_editor4(self, txn, repos_url,
{'fraction_non_alphanumeric': 0.08001860897883228, 'fraction_numerical': 0.00209351011863224, 'mean_word_length': 2.2242219722534684, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7578261', 'n_tokens_mistral': 2781, 'n_tokens_neox': 2704, 'n_words': 542}