/usr/lib/ruby/1.8/svn/repos.rb is in libsvn-ruby1.8 1.6.17dfsg-3ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 | 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,
send_copyfrom_args=nil)
authz_read_func ||= @authz_read_func
args = [
rev, self, fs_base, target, tgt_path, text_deltas,
depth, ignore_ancestry, send_copyfrom_args, 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,
base_path, user, log_msg,
commit_callback,
authz_callback)
editor.baton = baton
editor
end
def commit_editor3(repos_url, base_path, txn=nil, rev_props=nil,
commit_callback=nil, authz_callback=nil)
rev_props ||= {}
editor, baton = Repos.get_commit_editor5(self, txn, repos_url,
base_path, rev_props,
commit_callback,
authz_callback)
editor.baton = baton
editor
end
def youngest_revision
fs.youngest_rev
end
alias_method :youngest_rev, :youngest_revision
def dated_revision(date)
Repos.dated_revision(self, date.to_apr_time)
end
def logs(paths, start_rev, end_rev, limit,
discover_changed_paths=true,
strict_node_history=false,
authz_read_func=nil)
authz_read_func ||= @authz_read_func
paths = [paths] unless paths.is_a?(Array)
infos = []
receiver = Proc.new do |changed_paths, revision, author, date, message|
if block_given?
yield(changed_paths, revision, author, date, message)
end
infos << [changed_paths, revision, author, date, message]
end
Repos.get_logs3(self, paths, start_rev, end_rev,
limit, discover_changed_paths,
strict_node_history, authz_read_func,
receiver)
infos
end
def file_revs(path, start_rev, end_rev, authz_read_func=nil)
args = [path, start_rev, end_rev, authz_read_func]
if block_given?
revs = file_revs2(*args) do |path, rev, rev_props, prop_diffs|
yield(path, rev, rev_props, Util.hash_to_prop_array(prop_diffs))
end
else
revs = file_revs2(*args)
end
revs.collect do |path, rev, rev_props, prop_diffs|
[path, rev, rev_props, Util.hash_to_prop_array(prop_diffs)]
end
end
def file_revs2(path, start_rev, end_rev, authz_read_func=nil)
authz_read_func ||= @authz_read_func
revs = []
handler = Proc.new do |path, rev, rev_props, prop_diffs|
yield(path, rev, rev_props, prop_diffs) if block_given?
revs << [path, rev, rev_props, prop_diffs]
end
Repos.get_file_revs(self, path, start_rev, end_rev,
authz_read_func, handler)
revs
end
def commit_txn(txn)
Repos.fs_commit_txn(self, txn)
end
def transaction_for_commit(*args)
if args.first.is_a?(Hash)
props, rev = args
else
author, log, rev = args
props = {
Svn::Core::PROP_REVISION_AUTHOR => author,
Svn::Core::PROP_REVISION_LOG => log,
}
end
txn = Repos.fs_begin_txn_for_commit2(self, rev || youngest_rev, props)
if block_given?
yield(txn)
commit(txn) if fs.transactions.include?(txn.name)
else
txn
end
end
def transaction_for_update(author, rev=nil)
txn = Repos.fs_begin_txn_for_update(self, rev || youngest_rev, author)
if block_given?
yield(txn)
txn.abort if fs.transactions.include?(txn.name)
else
txn
end
end
def commit(txn)
Repos.fs_commit_txn(self, txn)
end
def lock(path, token=nil, comment=nil, dav_comment=true,
expiration_date=nil, current_rev=nil, steal_lock=false)
if expiration_date
expiration_date = expiration_date.to_apr_time
else
expiration_date = 0
end
current_rev ||= youngest_rev
Repos.fs_lock(self, path, token, comment,
dav_comment, expiration_date,
current_rev, steal_lock)
end
def unlock(path, token, break_lock=false)
Repos.fs_unlock(self, path, token, break_lock)
end
def get_locks(path, authz_read_func=nil)
authz_read_func ||= @authz_read_func
Repos.fs_get_locks(self, path, authz_read_func)
end
def set_prop(author, name, new_value, rev=nil, authz_read_func=nil,
use_pre_revprop_change_hook=true,
use_post_revprop_change_hook=true)
authz_read_func ||= @authz_read_func
rev ||= youngest_rev
Repos.fs_change_rev_prop3(self, rev, author, name, new_value,
use_pre_revprop_change_hook,
use_post_revprop_change_hook,
authz_read_func)
end
def prop(name, rev=nil, authz_read_func=nil)
authz_read_func ||= @authz_read_func
rev ||= youngest_rev
value = Repos.fs_revision_prop(self, rev, name, authz_read_func)
if name == Svn::Core::PROP_REVISION_DATE
value = Time.from_svn_format(value)
end
value
end
def proplist(rev=nil, authz_read_func=nil)
authz_read_func ||= @authz_read_func
rev ||= youngest_rev
props = Repos.fs_revision_proplist(self, rev, authz_read_func)
if props.has_key?(Svn::Core::PROP_REVISION_DATE)
props[Svn::Core::PROP_REVISION_DATE] =
Time.from_svn_format(props[Svn::Core::PROP_REVISION_DATE])
end
props
end
def node_editor(base_root, root)
editor, baton = Repos.node_editor(self, base_root, root)
def baton.node
Repos.node_from_baton(self)
end
editor.baton = baton
editor
end
def dump_fs(dumpstream, feedback_stream, start_rev, end_rev,
incremental=true, use_deltas=true, &cancel_func)
Repos.dump_fs2(self, dumpstream, feedback_stream,
start_rev, end_rev, incremental,
use_deltas, cancel_func)
end
def load_fs(dumpstream, feedback_stream=nil, uuid_action=nil,
parent_dir=nil, use_pre_commit_hook=true,
use_post_commit_hook=true, &cancel_func)
uuid_action ||= Svn::Repos::LOAD_UUID_DEFAULT
Repos.load_fs2(self, dumpstream, feedback_stream,
uuid_action, parent_dir,
use_pre_commit_hook, use_post_commit_hook,
cancel_func)
end
def build_parser(uuid_action, parent_dir,
use_history=true, outstream=nil)
outstream ||= StringIO.new
parser, baton = Repos.get_fs_build_parser2(use_history,
uuid_action,
outstream,
parent_dir)
def parser.parse_dumpstream(stream, &cancel_func)
Repos.parse_dumpstream2(stream, self, @baton, cancel_func)
end
def parser.outstream=(new_stream)
@outstream = new_stream
end
def parser.baton=(new_baton)
@baton = new_baton
end
def parser.baton
@baton
end
parser.outstream = outstream
parser.baton = baton
parser
end
def delta_tree(root, base_rev)
base_root = fs.root(base_rev)
editor = node_editor(base_root, root)
root.replay(editor)
editor.baton.node
end
def mergeinfo(paths, revision=nil, inherit=nil,
include_descendants=false, &authz_read_func)
path = nil
unless paths.is_a?(Array)
path = paths
paths = [path]
end
revision ||= Svn::Core::INVALID_REVNUM
results = Repos.fs_get_mergeinfo(self, paths, revision,
inherit, include_descendants,
authz_read_func)
results = results[path] if path
results
end
private
def setup_report_baton(baton)
baton.instance_variable_set("@aborted", false)
def baton.aborted?
@aborted
end
def baton.set_path(path, revision, start_empty=false, lock_token=nil,
depth=nil)
Repos.set_path3(self, path, revision, depth, start_empty, lock_token)
end
def baton.link_path(path, link_path, revision, start_empty=false,
lock_token=nil, depth=nil)
Repos.link_path3(self, path, link_path, revision, depth,
start_empty, lock_token)
end
def baton.delete_path(path)
Repos.delete_path(self, path)
end
def baton.finish_report
Repos.finish_report(self)
end
def baton.abort_report
Repos.abort_report(self)
@aborted = true
end
end
end
class Node
alias text_mod? text_mod
alias prop_mod? prop_mod
def copy?
Util.copy?(copyfrom_path, copyfrom_rev)
end
def add?
action == "A"
end
def delete?
action == "D"
end
def replace?
action == "R"
end
def file?
kind == Core::NODE_FILE
end
def dir?
kind == Core::NODE_DIR
end
def none?
kind == Core::NODE_NONE
end
def unknown?
kind == Core::NODE_UNKNOWN
end
end
Authz = SWIG::TYPE_p_svn_authz_t
class Authz
class << self
def read(file, must_exist=true)
Repos.authz_read(file, must_exist)
end
end
def can_access?(repos_name, path, user, required_access)
Repos.authz_check_access(self,
repos_name,
path,
user,
required_access)
end
end
end
end
|