/usr/lib/ruby/1.8/svn/core.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 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 | require "English"
require "time"
require "stringio"
require "tempfile"
require "svn/util"
require "svn/error"
require "svn/ext/core"
class Time
MILLION = 1_000_000
class << self
def from_apr_time(apr_time)
return apr_time if apr_time.is_a?(Time)
sec, usec = apr_time.divmod(MILLION)
Time.at(sec, usec)
end
def from_svn_format(str)
return nil if str.nil?
return str if str.is_a?(Time)
from_apr_time(Svn::Core.time_from_cstring(str))
end
def parse_svn_format(str)
return str if str.is_a?(Time)
matched, result = Svn::Core.parse_date(str, Time.now.to_apr_time)
if matched
from_apr_time(result)
else
nil
end
end
end
def to_apr_time
to_i * MILLION + usec
end
def to_svn_format
Svn::Core.time_to_cstring(self.to_apr_time)
end
def to_svn_human_format
Svn::Core.time_to_human_cstring(self.to_apr_time)
end
end
module Svn
module Core
Util.set_constants(Ext::Core, self)
Util.set_methods(Ext::Core, self)
nls_init
Util.reset_message_directory
# for backward compatibility
SWIG_INVALID_REVNUM = INVALID_REVNUM
SWIG_IGNORED_REVNUM = IGNORED_REVNUM
class << self
alias binary_mime_type? mime_type_is_binary
alias prop_diffs2 prop_diffs
def prop_diffs(target_props, source_props)
Property.prop_diffs(target_props, source_props)
end
end
DEFAULT_CHARSET = default_charset
LOCALE_CHARSET = locale_charset
AuthCredSSLClientCert = AuthCredSslClientCert
AuthCredSSLClientCertPw = AuthCredSslClientCertPw
AuthCredSSLServerTrust = AuthCredSslServerTrust
dirent_all = 0
constants.each do |name|
dirent_all |= const_get(name) if /^DIRENT_/ =~ name
end
DIRENT_ALL = dirent_all
Pool = Svn::Ext::Core::Apr_pool_wrapper_t
class Pool
RECOMMENDED_MAX_FREE_SIZE = ALLOCATOR_RECOMMENDED_MAX_FREE
MAX_FREE_UNLIMITED = ALLOCATOR_MAX_FREE_UNLIMITED
class << self
def number_of_pools
ObjectSpace.each_object(Pool) {}
end
end
alias _initialize initialize
private :_initialize
def initialize(parent=nil)
_initialize(parent)
@parent = parent
end
def destroy
@parent = nil
_destroy
end
private :_destroy
end
class Stream
if Core.const_defined?(:STREAM_CHUNK_SIZE)
CHUNK_SIZE = Core::STREAM_CHUNK_SIZE
else
CHUNK_SIZE = 8192
end
def write(data)
Core.stream_write(self, data)
end
def read(len=nil)
if len.nil?
read_all
else
buf = ""
while len > CHUNK_SIZE
buf << _read(CHUNK_SIZE)
len -= CHUNK_SIZE
end
buf << _read(len)
buf
end
end
def close
Core.stream_close(self)
end
def copy(other, &cancel_proc)
Core.stream_copy2(self, other, cancel_proc)
end
private
def _read(size)
Core.stream_read(self, size)
end
def read_all
buf = ""
while chunk = _read(CHUNK_SIZE)
buf << chunk
end
buf
end
end
class AuthBaton
attr_reader :providers, :parameters
alias _initialize initialize
private :_initialize
def initialize(providers=[], parameters={})
_initialize(providers)
@providers = providers
self.parameters = parameters
end
def [](name)
Core.auth_get_parameter(self, name)
end
def []=(name, value)
Core.auth_set_parameter(self, name, value)
@parameters[name] = value
end
def parameters=(params)
@parameters = {}
params.each do |key, value|
self[key] = value
end
end
end
module Authenticatable
attr_accessor :auth_baton
def add_simple_provider
add_provider(Core.auth_get_simple_provider)
end
if Core.respond_to?(:auth_get_windows_simple_provider)
def add_windows_simple_provider
add_provider(Core.auth_get_windows_simple_provider)
end
end
if Core.respond_to?(:auth_get_keychain_simple_provider)
def add_keychain_simple_provider
add_provider(Core.auth_get_keychain_simple_provider)
end
end
def add_username_provider
add_provider(Core.auth_get_username_provider)
end
def add_ssl_client_cert_file_provider
add_provider(Core.auth_get_ssl_client_cert_file_provider)
end
def add_ssl_client_cert_pw_file_provider
add_provider(Core.auth_get_ssl_client_cert_pw_file_provider)
end
def add_ssl_server_trust_file_provider
add_provider(Core.auth_get_ssl_server_trust_file_provider)
end
if Core.respond_to?(:auth_get_windows_ssl_server_trust_provider)
def add_windows_ssl_server_trust_provider
add_provider(Core.auth_get_windows_ssl_server_trust_provider)
end
end
def add_simple_prompt_provider(retry_limit, prompt=Proc.new)
args = [retry_limit]
klass = AuthCredSimple
add_prompt_provider("simple", args, prompt, klass)
end
def add_username_prompt_provider(retry_limit, prompt=Proc.new)
args = [retry_limit]
klass = AuthCredUsername
add_prompt_provider("username", args, prompt, klass)
end
def add_ssl_server_trust_prompt_provider(prompt=Proc.new)
args = []
klass = AuthCredSSLServerTrust
add_prompt_provider("ssl_server_trust", args, prompt, klass)
end
def add_ssl_client_cert_prompt_provider(retry_limit, prompt=Proc.new)
args = [retry_limit]
klass = AuthCredSSLClientCert
add_prompt_provider("ssl_client_cert", args, prompt, klass)
end
def add_ssl_client_cert_pw_prompt_provider(retry_limit, prompt=Proc.new)
args = [retry_limit]
klass = AuthCredSSLClientCertPw
add_prompt_provider("ssl_client_cert_pw", args, prompt, klass)
end
private
def add_prompt_provider(name, args, prompt, credential_class)
real_prompt = Proc.new do |*prompt_args|
credential = credential_class.new
prompt.call(credential, *prompt_args)
credential
end
method_name = "swig_rb_auth_get_#{name}_prompt_provider"
baton, provider = Core.send(method_name, real_prompt, *args)
provider.instance_variable_set("@baton", baton)
provider.instance_variable_set("@prompt", real_prompt)
add_provider(provider)
end
def add_provider(provider)
if auth_baton
providers = auth_baton.providers
parameters = auth_baton.parameters
else
providers = []
parameters = {}
end
self.auth_baton = AuthBaton.new(providers + [provider], parameters)
end
end
class AuthProviderObject
class << self
undef new
end
end
Diff = SWIG::TYPE_p_svn_diff_t
class Diff
attr_accessor :original, :modified, :latest, :ancestor
class << self
def version
Core.diff_version
end
def file_diff(original, modified, options=nil)
options ||= Core::DiffFileOptions.new
diff = Core.diff_file_diff_2(original, modified, options)
if diff
diff.original = original
diff.modified = modified
end
diff
end
def file_diff3(original, modified, latest, options=nil)
options ||= Core::DiffFileOptions.new
diff = Core.diff_file_diff3_2(original, modified, latest, options)
if diff
diff.original = original
diff.modified = modified
diff.latest = latest
end
diff
end
def file_diff4(original, modified, latest, ancestor, options=nil)
options ||= Core::DiffFileOptions.new
args = [original, modified, latest, ancestor, options]
diff = Core.diff_file_diff4_2(*args)
if diff
diff.original = original
diff.modified = modified
diff.latest = latest
diff.ancestor = ancestor
end
diff
end
end
def unified(orig_label, mod_label, header_encoding=nil)
header_encoding ||= Svn::Core.locale_charset
output = StringIO.new
args = [
output, self, @original, @modified,
orig_label, mod_label, header_encoding
]
Core.diff_file_output_unified2(*args)
output.rewind
output.read
end
def merge(conflict_original=nil, conflict_modified=nil,
conflict_latest=nil, conflict_separator=nil,
display_original_in_conflict=true,
display_resolved_conflicts=true)
header_encoding ||= Svn::Core.locale_charset
output = StringIO.new
args = [
output, self, @original, @modified, @latest,
conflict_original, conflict_modified,
conflict_latest, conflict_separator,
display_original_in_conflict,
display_resolved_conflicts,
]
Core.diff_file_output_merge(*args)
output.rewind
output.read
end
def conflict?
Core.diff_contains_conflicts(self)
end
def diff?
Core.diff_contains_diffs(self)
end
end
class DiffFileOptions
class << self
def parse(*args)
options = new
options.parse(*args)
options
end
end
def parse(*args)
args = args.first if args.size == 1 and args.first.is_a?(Array)
Svn::Core.diff_file_options_parse(self, args)
end
end
class Version
alias _initialize initialize
def initialize(major=nil, minor=nil, patch=nil, tag=nil)
_initialize
self.major = major if major
self.minor = minor if minor
self.patch = patch if patch
self.tag = tag || ""
end
def ==(other)
valid? and other.valid? and Core.ver_equal(self, other)
end
def compatible?(other)
valid? and other.valid? and Core.ver_compatible(self, other)
end
def valid?
(major and minor and patch and tag) ? true : false
end
alias _tag= tag=
def tag=(value)
@tag = value
self._tag = value
end
def to_a
[major, minor, patch, tag]
end
def to_s
"#{major}.#{minor}.#{patch}#{tag}"
end
end
# Following methods are also available:
#
# [created_rev]
# Returns a revision at which the instance was last modified.
# [have_props?]
# Returns +true+ if the instance has properties.
# [last_author]
# Returns an author who last modified the instance.
# [size]
# Returns a size of the instance.
class Dirent
alias have_props? has_props
# Returns +true+ when the instance is none.
def none?
kind == NODE_NONE
end
# Returns +true+ when the instance is a directory.
def directory?
kind == NODE_DIR
end
# Returns +true+ when the instance is a file.
def file?
kind == NODE_FILE
end
# Returns +true+ when the instance is an unknown node.
def unknown?
kind == NODE_UNKNOWN
end
# Returns a Time when the instance was last changed.
#
# Svn::Core::Dirent#time is replaced by this method, _deprecated_,
# and provided for backward compatibility with the 1.3 API.
def time2
__time = time
__time && Time.from_apr_time(__time)
end
end
Config = SWIG::TYPE_p_svn_config_t
class Config
include Enumerable
class << self
def get(path=nil)
Core.config_get_config(path)
end
alias config get
def read(file, must_exist=true)
Core.config_read(file, must_exist)
end
def ensure(dir)
Core.config_ensure(dir)
end
def read_auth_data(cred_kind, realm_string, config_dir=nil)
Core.config_read_auth_data(cred_kind, realm_string, config_dir)
end
def write_auth_data(hash, cred_kind, realm_string, config_dir=nil)
Core.config_write_auth_data(hash, cred_kind,
realm_string, config_dir)
end
end
def merge(file, must_exist=true)
Core.config_merge(self, file, must_exist)
end
def get(section, option, default=nil)
Core.config_get(self, section, option, default)
end
def get_bool(section, option, default)
Core.config_get_bool(self, section, option, default)
end
def set(section, option, value)
Core.config_set(self, section, option, value)
end
alias_method :[]=, :set
def set_bool(section, option, value)
Core.config_set_bool(self, section, option, value)
end
def each
each_section do |section|
each_option(section) do |name, value|
yield(section, name, value)
true
end
true
end
end
def each_option(section)
receiver = Proc.new do |name, value|
yield(name, value)
end
Core.config_enumerate2(self, section, receiver)
end
def each_section
receiver = Proc.new do |name|
yield(name)
end
Core.config_enumerate_sections2(self, receiver)
end
def find_group(key, section)
Core.config_find_group(self, key, section)
end
def get_server_setting(group, name, default=nil)
Core.config_get_server_setting(self, group, name, default)
end
def get_server_setting_int(group, name, default)
Core.config_get_server_setting_int(self, group, name, default)
end
alias_method :_to_s, :to_s
def to_s
result = ""
each_section do |section|
result << "[#{section}]\n"
each_option(section) do |name, value|
result << "#{name} = #{value}\n"
end
result << "\n"
end
result
end
def inspect
"#{_to_s}#{to_hash.inspect}"
end
def to_hash
sections = {}
each do |section, name, value|
sections[section] ||= {}
sections[section][name] = value
end
sections
end
def ==(other)
other.is_a?(self.class) and to_hash == other.to_hash
end
end
module Property
module_function
def kind(name)
kind, len = Core.property_kind(name)
[kind, name[0...len]]
end
def svn_prop?(name)
Core.prop_is_svn_prop(name)
end
def needs_translation?(name)
Core.prop_needs_translation(name)
end
def categorize(props)
categorize2(props).collect do |categorized_props|
Util.hash_to_prop_array(categorized_props)
end
end
alias_method :categorize_props, :categorize
module_function :categorize_props
def categorize2(props)
Core.categorize_props(props)
end
def diffs(target_props, source_props)
Util.hash_to_prop_array(diffs2(target_props, source_props))
end
alias_method :prop_diffs, :diffs
module_function :prop_diffs
def diffs2(target_props, source_props)
Core.prop_diffs2(target_props, source_props)
end
def has_svn_prop?(props)
Core.prop_has_svn_prop(props)
end
alias_method :have_svn_prop?, :has_svn_prop?
module_function :have_svn_prop?
def valid_name?(name)
Core.prop_name_is_valid(name)
end
end
module Depth
module_function
def from_string(str)
return nil if str.nil?
Core.depth_from_word(str)
end
def to_string(depth)
Core.depth_to_word(depth)
end
def infinity_or_empty_from_recurse(depth_or_recurse)
case depth_or_recurse
when true then DEPTH_INFINITY
when false then DEPTH_EMPTY
else depth_or_recurse
end
end
def infinity_or_immediates_from_recurse(depth_or_recurse)
case depth_or_recurse
when true then DEPTH_INFINITY
when false then DEPTH_IMMEDIATES
else depth_or_recurse
end
end
end
module MimeType
module_function
def parse(source)
file = Tempfile.new("svn-ruby-mime-type")
file.print(source)
file.close
Core.io_parse_mimetypes_file(file.path)
end
def parse_file(path)
Core.io_parse_mimetypes_file(path)
end
def detect(path, type_map={})
Core.io_detect_mimetype2(path, type_map)
end
end
class CommitInfo
alias _date date
def date
Time.from_svn_format(_date)
end
end
# Following methods are also available:
#
# [action]
# Returns an action taken to the path at the revision.
# [copyfrom_path]
# If the path was added at the revision by the copy action from
# another path at another revision, returns an original path.
# Otherwise, returns +nil+.
# [copyfrom_rev]
# If the path was added at the revision by the copy action from
# another path at another revision, returns an original revision.
# Otherwise, returns <tt>-1</tt>.
class LogChangedPath
# Returns +true+ when the path is added by the copy action.
def copied?
Util.copy?(copyfrom_path, copyfrom_rev)
end
end
# For backward compatibility
class Prop
attr_accessor :name, :value
def initialize(name, value)
@name = name
@value = value
end
def ==(other)
other.is_a?(self.class) and
[@name, @value] == [other.name, other.value]
end
end
class MergeRange
def to_a
[self.start, self.end, self.inheritable]
end
def inspect
super.gsub(/>$/, ":#{to_a.inspect}>")
end
def ==(other)
to_a == other.to_a
end
end
class MergeInfo < Hash
class << self
def parse(input)
new(Core.mergeinfo_parse(input))
end
end
def initialize(info)
super()
info.each do |path, ranges|
self[path] = RangeList.new(*ranges)
end
end
def diff(to, consider_inheritance=false)
Core.mergeinfo_diff(self, to, consider_inheritance).collect do |result|
self.class.new(result)
end
end
def merge(changes)
self.class.new(Core.swig_mergeinfo_merge(self, changes))
end
def remove(eraser)
self.class.new(Core.mergeinfo_remove(eraser, self))
end
def sort
self.class.new(Core.swig_mergeinfo_sort(self))
end
def to_s
Core.mergeinfo_to_string(self)
end
end
class RangeList < Array
def initialize(*ranges)
super()
ranges.each do |range|
self << Svn::Core::MergeRange.new(*range.to_a)
end
end
def diff(to, consider_inheritance=false)
result = Core.rangelist_diff(self, to, consider_inheritance)
deleted = result.pop
added = result
[added, deleted].collect do |result|
self.class.new(*result)
end
end
def merge(changes)
self.class.new(*Core.swig_rangelist_merge(self, changes))
end
def remove(eraser, consider_inheritance=false)
self.class.new(*Core.rangelist_remove(eraser, self,
consider_inheritance))
end
def intersect(other, consider_inheritance=false)
self.class.new(*Core.rangelist_intersect(self, other,
consider_inheritance))
end
def reverse
self.class.new(*Core.swig_rangelist_reverse(self))
end
def to_s
Core.rangelist_to_string(self)
end
end
class LogEntry
alias_method(:revision_properties, :revprops)
alias_method(:has_children?, :has_children)
undef_method(:has_children)
end
end
end
|