10 Util.set_constants(Ext::Fs, self)
11 Util.set_methods(Ext::Fs, self)
13 @@fs_pool = Svn::Core::Pool.new
22 @@alias_targets = %w(create delete open hotcopy recover)
24 @@alias_targets.each do |target|
25 alias_method "_#{target}", target
28 @@alias_targets.each do |target|
29 alias_method "_#{target}", target
34 def create(path, config={}, &block)
35 _create(path, config, &block)
42 def open(path, config={}, &block)
43 _open(path, config, &block)
46 def hotcopy(src, dest, clean=false)
47 _hotcopy(src, dest, clean)
50 def recover(path, &cancel_func)
51 _recover(path, cancel_func)
54 FileSystem = SWIG::TYPE_p_svn_fs_t
57 # For backward compatibility
58 def create(*args, &block)
59 Fs.create(*args, &block)
62 def delete(*args, &block)
63 Fs.delete(*args, &block)
66 def open(*args, &block)
67 Fs.open(*args, &block)
71 def hotcopy(*args, &block)
72 Fs.hotcopy(*args, &block)
75 def recover(*args, &block)
76 Fs.recover(*args, &block)
80 def set_warning_func(&func)
81 Fs.set_warning_func_wrapper(self, func)
89 Fs.open_txn(self, name)
93 Fs.purge_txn(self, id)
96 def transaction(rev=nil, flags=0)
97 txn = Fs.begin_txn2(self, rev || youngest_rev, flags)
101 txn.commit if transactions.include?(txn.name)
107 def youngest_revision
108 Fs.youngest_rev(self)
110 alias_method :youngest_rev, :youngest_revision
112 def deleted_revision(path, start_rev, end_rev)
113 Repos.deleted_rev(self, path, start_rev, end_rev)
115 alias_method :deleted_rev, :deleted_revision
117 def prop(name, rev=nil)
118 value = Fs.revision_prop(self, rev || youngest_rev, name)
119 if value and name == Svn::Core::PROP_REVISION_DATE
120 Time.parse_svn_format(value)
126 def set_prop(name, value, rev=nil)
127 Fs.change_rev_prop(self, rev || youngest_rev, name, value)
130 def proplist(rev=nil)
131 list = Fs.revision_proplist(self, rev || youngest_rev)
132 date_str = list[Svn::Core::PROP_REVISION_DATE]
134 list[Svn::Core::PROP_REVISION_DATE] = Time.parse_svn_format(date_str)
140 Fs.list_transactions(self)
144 Fs.revision_root(self, rev || youngest_rev)
151 def access=(new_access)
152 Fs.set_access(self, new_access)
155 def deltify_revision(rev=nil)
156 Fs.deltify_revision(self, rev || youngest_rev)
164 Fs.set_uuid(self, new_uuid)
167 def lock(path, token=nil, comment=nil, dav_comment=true,
168 expiration_date=nil, current_rev=nil, steal_lock=false)
170 expiration_date = expiration_date.to_apr_time
174 current_rev ||= youngest_rev
175 Fs.lock(self, path, token, comment, dav_comment,
176 expiration_date, current_rev, steal_lock)
179 def unlock(path, token, break_lock=false)
180 Fs.unlock(self, path, token, break_lock)
183 def generate_lock_token
184 Fs.generate_lock_token(self)
188 Fs.get_lock(self, path)
193 receiver = Proc.new do |lock|
195 yield(lock) if block_given?
197 Fs.get_locks(self, path, receiver)
201 def history(path, start_rev, end_rev,
202 cross_copies=true, authz_read_func=nil)
204 history_func = Proc.new do |path, revision|
205 yield(path, revision) if block_given?
206 hist << [path, revision]
208 Repos.history2(self, path, history_func,
209 authz_read_func, start_rev, end_rev,
214 def trace_node_locations(fs_path, location_revisions,
215 peg_rev=nil, &authz_read_func)
216 peg_rev ||= youngest_rev
217 Repos.trace_node_locations(self, fs_path, peg_rev,
223 Access = SWIG::TYPE_p_svn_fs_access_t
227 Fs.create_access(username)
232 Fs.access_get_username(self)
235 def add_lock_token(token)
236 Fs.access_add_lock_token(self, token)
240 Transaction = SWIG::TYPE_p_svn_fs_txn_t
248 value = Fs.txn_prop(self, name)
249 if name == Svn::Core::PROP_REVISION_DATE and value
250 value = Time.parse_svn_format(value)
255 def set_prop(name, value, validate=true)
257 Repos.fs_change_txn_prop(self, name, value)
259 Fs.change_txn_prop(self, name, value)
264 Fs.txn_base_revision(self)
272 list = Fs.txn_proplist(self)
273 date_str = list[Svn::Core::PROP_REVISION_DATE]
274 if list[Svn::Core::PROP_REVISION_DATE]
275 list[Svn::Core::PROP_REVISION_DATE] = Time.parse_svn_format(date_str)
285 result = Fs.commit_txn(self)
286 if result.is_a?(Array)
295 Root = SWIG::TYPE_p_svn_fs_root_t
300 Fs.is_dir(self, path)
304 Fs.is_file(self, path)
308 Fs.txn_root_base_revision(self)
312 Fs.revision_root_revision(self)
316 Fs.txn_root_name(self)
320 Fs.root_fs_wrapper(self)
324 Fs.node_id(self, path)
327 def node_created_rev(path)
328 Fs.node_created_rev(self, path)
331 def node_created_path(path)
332 Fs.node_created_path(self, path)
335 def node_prop(path, key)
336 Fs.node_prop(self, path, key)
339 def set_node_prop(path, key, value, validate=true)
341 Repos.fs_change_node_prop(self, path, key, value)
343 Fs.change_node_prop(self, path, key, value)
347 def node_proplist(path)
348 Fs.node_proplist(self, path)
350 alias node_prop_list node_proplist
353 Fs.check_path(self, path)
356 def file_length(path)
357 Fs.file_length(self, path)
360 def file_md5_checksum(path)
361 Fs.file_md5_checksum(self, path)
364 def file_contents(path)
365 stream = Fs.file_contents(self, path)
381 def dir_entries(path)
383 Fs.dir_entries(self, path).each do |name, entry|
384 entries[name] = entry
389 def dir_delta(src_path, src_entry, tgt_root, tgt_path,
390 editor, text_deltas=false, recurse=true,
391 entry_props=false, ignore_ancestry=false,
393 Repos.dir_delta(self, src_path, src_entry, tgt_root,
394 tgt_path, editor, authz_read_func,
395 text_deltas, recurse, entry_props,
399 def replay(editor, base_dir=nil, low_water_mark=nil, send_deltas=false,
402 low_water_mark ||= Core::INVALID_REVNUM
403 Repos.replay2(self, base_dir, low_water_mark, send_deltas,
407 def copied_from(path)
408 Fs.copied_from(self, path)
416 Fs.is_revision_root(self)
420 Fs.paths_changed(self)
423 def node_history(path)
424 Fs.node_history(self, path)
427 def props_changed?(path1, root2, path2)
428 Fs.props_changed(self, path1, root2, path2)
431 def merge(target_path, source_root, source_path,
432 ancestor_root, ancestor_path)
433 Fs.merge(source_root, source_path, self, target_path,
434 ancestor_root, ancestor_path)
438 Fs.make_dir(self, path)
442 Fs._delete(self, path)
445 def copy(to_path, from_root, from_path)
446 Fs.copy(from_root, from_path, self, to_path)
449 def revision_link(from_root, path)
450 Fs.revision_link(from_root, self, path)
454 Fs.make_file(self, path)
457 def apply_textdelta(path, base_checksum=nil, result_checksum=nil)
458 handler, handler_baton = Fs.apply_textdelta(self, path,
461 handler.baton = handler_baton
465 def apply_text(path, result_checksum=nil)
466 Fs.apply_text(self, path, result_checksum)
469 def contents_changed?(path1, root2, path2)
470 Fs.contents_changed(self, path1, root2, path2)
473 def file_delta_stream(arg1, arg2, target_path)
474 if arg1.is_a?(self.class)
483 Fs.get_file_delta_stream(source_root, source_path,
484 target_root, target_path)
488 Repos.stat(self, path)
491 def committed_info(path)
492 Repos.get_committed_info(self, path)
495 def closest_copy(path)
496 Fs.closest_copy(self, path)
499 def mergeinfo(paths, inherit=nil, include_descendants=false)
500 paths = [paths] unless paths.is_a?(Array)
501 Fs.get_mergeinfo(self, paths, inherit, include_descendants)
504 def change_mergeinfo(path, info)
505 Fs.change_mergeinfo(self, path, info)
509 History = SWIG::TYPE_p_svn_fs_history_t
513 Fs.history_location(self)
516 def prev(cross_copies=true)
517 Fs.history_prev(self, cross_copies)
522 DirectoryEntry = Dirent
524 Id = SWIG::TYPE_p_svn_fs_id_t
535 Fs.compare_ids(self, other)
539 Fs.check_related(self, other)
545 change_kind == Svn::Fs::PATH_CHANGE_MODIFY
549 change_kind == Svn::Fs::PATH_CHANGE_ADD
559 def initialize(root1, path1, root2, path2)
573 @binary = _binary?(@root1, @path1)
574 @binary ||= _binary?(@root2, @path2)
581 [@tempfile1, @tempfile2]
583 @tempfile1 = Tempfile.new("svn_fs")
584 @tempfile2 = Tempfile.new("svn_fs")
586 dump_contents(@tempfile1, @root1, @path1)
587 dump_contents(@tempfile2, @root2, @path2)
589 [@tempfile1, @tempfile2]
595 @diff ||= Core::Diff.file_diff(@tempfile1.path, @tempfile2.path)
598 def unified(label1, label2)
599 if diff and diff.diff?
600 diff.unified(label1, label2)
607 def dump_contents(tempfile, root, path)
611 root.file_contents(path) do |stream|
612 tempfile.print(stream.read)
620 def _binary?(root, path)
622 prop = root.node_prop(path, Core::PROP_MIME_TYPE)
623 prop and Core.binary_mime_type?(prop)