13 def from_apr_time(apr_time)
14 return apr_time if apr_time.is_a?(Time)
15 sec, usec = apr_time.divmod(MILLION)
19 def from_svn_format(str)
20 return nil if str.nil?
21 return str if str.is_a?(Time)
22 from_apr_time(Svn::Core.time_from_cstring(str))
25 def parse_svn_format(str)
26 return str if str.is_a?(Time)
27 matched, result = Svn::Core.parse_date(str, Time.now.to_apr_time)
41 Svn::Core.time_to_cstring(self.to_apr_time)
44 def to_svn_human_format
45 Svn::Core.time_to_human_cstring(self.to_apr_time)
51 Util.set_constants(Ext::Core, self)
52 Util.set_methods(Ext::Core, self)
55 Util.reset_message_directory
57 # for backward compatibility
58 SWIG_INVALID_REVNUM = INVALID_REVNUM
59 SWIG_IGNORED_REVNUM = IGNORED_REVNUM
62 alias binary_mime_type? mime_type_is_binary
63 alias prop_diffs2 prop_diffs
65 def prop_diffs(target_props, source_props)
66 Property.prop_diffs(target_props, source_props)
71 DEFAULT_CHARSET = default_charset
72 LOCALE_CHARSET = locale_charset
74 AuthCredSSLClientCert = AuthCredSslClientCert
75 AuthCredSSLClientCertPw = AuthCredSslClientCertPw
76 AuthCredSSLServerTrust = AuthCredSslServerTrust
79 constants.each do |name|
80 dirent_all |= const_get(name) if /^DIRENT_/ =~ name
82 DIRENT_ALL = dirent_all
84 Pool = Svn::Ext::Core::Apr_pool_wrapper_t
89 ObjectSpace.each_object(Pool) {}
93 alias _initialize initialize
95 def initialize(parent=nil)
108 if Core.const_defined?(:STREAM_CHUNK_SIZE)
109 CHUNK_SIZE = Core::STREAM_CHUNK_SIZE
115 Core.stream_write(self, data)
123 while len > CHUNK_SIZE
124 buf << _read(CHUNK_SIZE)
133 Core.stream_close(self)
136 def copy(other, &cancel_proc)
137 Core.stream_copy2(self, other, cancel_proc)
142 Core.stream_read(self, size)
147 while chunk = _read(CHUNK_SIZE)
156 attr_reader :providers, :parameters
158 alias _initialize initialize
160 def initialize(providers=[], parameters={})
161 _initialize(providers)
162 @providers = providers
163 self.parameters = parameters
167 Core.auth_get_parameter(self, name)
171 Core.auth_set_parameter(self, name, value)
172 @parameters[name] = value
175 def parameters=(params)
177 params.each do |key, value|
183 module Authenticatable
184 attr_accessor :auth_baton
186 def add_simple_provider
187 add_provider(Core.auth_get_simple_provider)
190 if Core.respond_to?(:auth_get_windows_simple_provider)
191 def add_windows_simple_provider
192 add_provider(Core.auth_get_windows_simple_provider)
196 if Core.respond_to?(:auth_get_keychain_simple_provider)
197 def add_keychain_simple_provider
198 add_provider(Core.auth_get_keychain_simple_provider)
202 def add_username_provider
203 add_provider(Core.auth_get_username_provider)
206 def add_ssl_client_cert_file_provider
207 add_provider(Core.auth_get_ssl_client_cert_file_provider)
210 def add_ssl_client_cert_pw_file_provider
211 add_provider(Core.auth_get_ssl_client_cert_pw_file_provider)
214 def add_ssl_server_trust_file_provider
215 add_provider(Core.auth_get_ssl_server_trust_file_provider)
218 if Core.respond_to?(:auth_get_windows_ssl_server_trust_provider)
219 def add_windows_ssl_server_trust_provider
220 add_provider(Core.auth_get_windows_ssl_server_trust_provider)
224 def add_simple_prompt_provider(retry_limit, prompt=Proc.new)
226 klass = AuthCredSimple
227 add_prompt_provider("simple", args, prompt, klass)
230 def add_username_prompt_provider(retry_limit, prompt=Proc.new)
232 klass = AuthCredUsername
233 add_prompt_provider("username", args, prompt, klass)
236 def add_ssl_server_trust_prompt_provider(prompt=Proc.new)
238 klass = AuthCredSSLServerTrust
239 add_prompt_provider("ssl_server_trust", args, prompt, klass)
242 def add_ssl_client_cert_prompt_provider(retry_limit, prompt=Proc.new)
244 klass = AuthCredSSLClientCert
245 add_prompt_provider("ssl_client_cert", args, prompt, klass)
248 def add_ssl_client_cert_pw_prompt_provider(retry_limit, prompt=Proc.new)
250 klass = AuthCredSSLClientCertPw
251 add_prompt_provider("ssl_client_cert_pw", args, prompt, klass)
255 def add_prompt_provider(name, args, prompt, credential_class)
256 real_prompt = Proc.new do |*prompt_args|
257 credential = credential_class.new
258 prompt.call(credential, *prompt_args)
261 method_name = "swig_rb_auth_get_#{name}_prompt_provider"
262 baton, provider = Core.send(method_name, real_prompt, *args)
263 provider.instance_variable_set("@baton", baton)
264 provider.instance_variable_set("@prompt", real_prompt)
265 add_provider(provider)
268 def add_provider(provider)
270 providers = auth_baton.providers
271 parameters = auth_baton.parameters
276 self.auth_baton = AuthBaton.new(providers + [provider], parameters)
280 class AuthProviderObject
287 Diff = SWIG::TYPE_p_svn_diff_t
289 attr_accessor :original, :modified, :latest, :ancestor
296 def file_diff(original, modified, options=nil)
297 options ||= Core::DiffFileOptions.new
298 diff = Core.diff_file_diff_2(original, modified, options)
300 diff.original = original
301 diff.modified = modified
306 def file_diff3(original, modified, latest, options=nil)
307 options ||= Core::DiffFileOptions.new
308 diff = Core.diff_file_diff3_2(original, modified, latest, options)
310 diff.original = original
311 diff.modified = modified
317 def file_diff4(original, modified, latest, ancestor, options=nil)
318 options ||= Core::DiffFileOptions.new
319 args = [original, modified, latest, ancestor, options]
320 diff = Core.diff_file_diff4_2(*args)
322 diff.original = original
323 diff.modified = modified
325 diff.ancestor = ancestor
331 def unified(orig_label, mod_label, header_encoding=nil)
332 header_encoding ||= Svn::Core.locale_charset
333 output = StringIO.new
335 output, self, @original, @modified,
336 orig_label, mod_label, header_encoding
338 Core.diff_file_output_unified2(*args)
343 def merge(conflict_original=nil, conflict_modified=nil,
344 conflict_latest=nil, conflict_separator=nil,
345 display_original_in_conflict=true,
346 display_resolved_conflicts=true)
347 header_encoding ||= Svn::Core.locale_charset
348 output = StringIO.new
350 output, self, @original, @modified, @latest,
351 conflict_original, conflict_modified,
352 conflict_latest, conflict_separator,
353 display_original_in_conflict,
354 display_resolved_conflicts,
356 Core.diff_file_output_merge(*args)
362 Core.diff_contains_conflicts(self)
366 Core.diff_contains_diffs(self)
370 class DiffFileOptions
380 args = args.first if args.size == 1 and args.first.is_a?(Array)
381 Svn::Core.diff_file_options_parse(self, args)
387 alias _initialize initialize
388 def initialize(major=nil, minor=nil, patch=nil, tag=nil)
390 self.major = major if major
391 self.minor = minor if minor
392 self.patch = patch if patch
397 valid? and other.valid? and Core.ver_equal(self, other)
400 def compatible?(other)
401 valid? and other.valid? and Core.ver_compatible(self, other)
405 (major and minor and patch and tag) ? true : false
415 [major, minor, patch, tag]
419 "#{major}.#{minor}.#{patch}#{tag}"
423 # Following methods are also available:
426 # Returns a revision at which the instance was last modified.
428 # Returns +true+ if the instance has properties.
430 # Returns an author who last modified the instance.
432 # Returns a size of the instance.
434 alias have_props? has_props
436 # Returns +true+ when the instance is none.
441 # Returns +true+ when the instance is a directory.
446 # Returns +true+ when the instance is a file.
451 # Returns +true+ when the instance is an unknown node.
456 # Returns a Time when the instance was last changed.
458 # Svn::Core::Dirent#time is replaced by this method, _deprecated_,
459 # and provided for backward compatibility with the 1.3 API.
462 __time && Time.from_apr_time(__time)
466 Config = SWIG::TYPE_p_svn_config_t
473 Core.config_get_config(path)
477 def read(file, must_exist=true)
478 Core.config_read(file, must_exist)
482 Core.config_ensure(dir)
485 def read_auth_data(cred_kind, realm_string, config_dir=nil)
486 Core.config_read_auth_data(cred_kind, realm_string, config_dir)
489 def write_auth_data(hash, cred_kind, realm_string, config_dir=nil)
490 Core.config_write_auth_data(hash, cred_kind,
491 realm_string, config_dir)
495 def merge(file, must_exist=true)
496 Core.config_merge(self, file, must_exist)
499 def get(section, option, default=nil)
500 Core.config_get(self, section, option, default)
503 def get_bool(section, option, default)
504 Core.config_get_bool(self, section, option, default)
507 def set(section, option, value)
508 Core.config_set(self, section, option, value)
510 alias_method :[]=, :set
512 def set_bool(section, option, value)
513 Core.config_set_bool(self, section, option, value)
517 each_section do |section|
518 each_option(section) do |name, value|
519 yield(section, name, value)
526 def each_option(section)
527 receiver = Proc.new do |name, value|
530 Core.config_enumerate2(self, section, receiver)
534 receiver = Proc.new do |name|
537 Core.config_enumerate_sections2(self, receiver)
540 def find_group(key, section)
541 Core.config_find_group(self, key, section)
544 def get_server_setting(group, name, default=nil)
545 Core.config_get_server_setting(self, group, name, default)
548 def get_server_setting_int(group, name, default)
549 Core.config_get_server_setting_int(self, group, name, default)
552 alias_method :_to_s, :to_s
555 each_section do |section|
556 result << "[#{section}]\n"
557 each_option(section) do |name, value|
558 result << "#{name} = #{value}\n"
566 "#{_to_s}#{to_hash.inspect}"
571 each do |section, name, value|
572 sections[section] ||= {}
573 sections[section][name] = value
579 other.is_a?(self.class) and to_hash == other.to_hash
586 kind, len = Core.property_kind(name)
587 [kind, name[0...len]]
591 Core.prop_is_svn_prop(name)
594 def needs_translation?(name)
595 Core.prop_needs_translation(name)
598 def categorize(props)
599 categorize2(props).collect do |categorized_props|
600 Util.hash_to_prop_array(categorized_props)
603 alias_method :categorize_props, :categorize
604 module_function :categorize_props
606 def categorize2(props)
607 Core.categorize_props(props)
610 def diffs(target_props, source_props)
611 Util.hash_to_prop_array(diffs2(target_props, source_props))
613 alias_method :prop_diffs, :diffs
614 module_function :prop_diffs
616 def diffs2(target_props, source_props)
617 Core.prop_diffs2(target_props, source_props)
620 def has_svn_prop?(props)
621 Core.prop_has_svn_prop(props)
623 alias_method :have_svn_prop?, :has_svn_prop?
624 module_function :have_svn_prop?
626 def valid_name?(name)
627 Core.prop_name_is_valid(name)
634 return nil if str.nil?
635 Core.depth_from_word(str)
639 Core.depth_to_word(depth)
642 def infinity_or_empty_from_recurse(depth_or_recurse)
643 case depth_or_recurse
644 when true : DEPTH_INFINITY
645 when false : DEPTH_EMPTY
646 else depth_or_recurse
650 def infinity_or_immediates_from_recurse(depth_or_recurse)
651 case depth_or_recurse
652 when true : DEPTH_INFINITY
653 when false : DEPTH_IMMEDIATES
654 else depth_or_recurse
662 file = Tempfile.new("svn-ruby-mime-type")
665 Core.io_parse_mimetypes_file(file.path)
669 Core.io_parse_mimetypes_file(path)
672 def detect(path, type_map={})
673 Core.io_detect_mimetype2(path, type_map)
680 Time.from_svn_format(_date)
684 # Following methods are also available:
687 # Returns an action taken to the path at the revision.
689 # If the path was added at the revision by the copy action from
690 # another path at another revision, returns an original path.
691 # Otherwise, returns +nil+.
693 # If the path was added at the revision by the copy action from
694 # another path at another revision, returns an original revision.
695 # Otherwise, returns <tt>-1</tt>.
697 # Returns +true+ when the path is added by the copy action.
699 Util.copy?(copyfrom_path, copyfrom_rev)
703 # For backward compatibility
705 attr_accessor :name, :value
706 def initialize(name, value)
712 other.is_a?(self.class) and
713 [@name, @value] == [other.name, other.value]
719 [self.start, self.end, self.inheritable]
723 super.gsub(/>$/, ":#{to_a.inspect}>")
731 class MergeInfo < Hash
734 new(Core.mergeinfo_parse(input))
740 info.each do |path, ranges|
741 self[path] = RangeList.new(*ranges)
745 def diff(to, consider_inheritance=nil)
746 Core.mergeinfo_diff(self, to, consider_inheritance).collect do |result|
747 self.class.new(result)
752 self.class.new(Core.swig_mergeinfo_merge(self, changes))
756 self.class.new(Core.mergeinfo_remove(eraser, self))
760 self.class.new(Core.swig_mergeinfo_sort(self))
764 Core.mergeinfo_to_string(self)
768 class RangeList < Array
769 def initialize(*ranges)
771 ranges.each do |range|
772 self << Svn::Core::MergeRange.new(*range.to_a)
776 def diff(to, consider_inheritance=nil)
777 result = Core.rangelist_diff(self, to, consider_inheritance)
780 [added, deleted].collect do |result|
781 self.class.new(*result)
786 self.class.new(*Core.swig_rangelist_merge(self, changes))
789 def remove(eraser, consider_inheritance=nil)
790 self.class.new(*Core.rangelist_remove(eraser, self, consider_inheritance))
794 self.class.new(*Core.rangelist_intersect(self, other))
798 self.class.new(*Core.swig_rangelist_reverse(self))
802 Core.rangelist_to_string(self)
807 alias_method(:revision_properties, :revprops)
808 alias_method(:has_children?, :has_children)
809 undef_method(:has_children)