PageRenderTime 27ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/usr/lib/perl5/vendor_perl/SVN/Fs.pm

https://gitlab.com/kinwei/IFE-task7
Perl | 503 lines | 382 code | 121 blank | 0 comment | 8 complexity | f1c17fdc63de905eece32f8dea44b9ce MD5 | raw file
  1. use strict;
  2. use warnings;
  3. package SVN::Fs;
  4. use SVN::Base qw(Fs svn_fs_);
  5. =head1 NAME
  6. SVN::Fs - Subversion filesystem functions
  7. =head1 DESCRIPTION
  8. SVN::Fs wraps the functions in svn_fs.h. The actual namespace
  9. for filesystem objects is C<_p_svn_fs_t>.
  10. =head1 FUNCTIONS
  11. =over
  12. =item SVN::Fs::berkeley_logfiles($path, $only_unused)
  13. =item SVN::Fs::berkeley_recover($path)
  14. =item SVN::Fs::check_related($id1, $id2)
  15. =item SVN::Fs::compare_ids($id1, $id2)
  16. =item SVN::Fs::contents_changed($root1, $path1, $root2, $path2)
  17. =item SVN::Fs::create($path, $config)
  18. =item SVN::Fs::delete_fs($path)
  19. =item SVN::Fs::deltify_revision($fs, $rev)
  20. =item SVN::Fs::get_file_delta_stream($source_root, $source_path, $target_root, $target_path)
  21. =item SVN::Fs::hotcopy($src_path, $dest_path, $clean)
  22. =item SVN::Fs::initialize($pool)
  23. =item SVN::Fs::merge($source_root, $source_path, $target_root, $target_path, $ancestor_root, $ancestor_path)
  24. =item SVN::Fs::open($path, $config)
  25. =item SVN::Fs::path($fs)
  26. =item SVN::Fs::print_modules($s)
  27. TODO - doesn't work, segfaults if $s is null, doesn't do anything if
  28. its an empty string
  29. =item SVN::Fs::props_changed($root1, $path1, $root2, $path2)
  30. See also C<SVN::Fs::contents_changed>
  31. =item SVN::Fs::purge_txn($fs, $txn_id)
  32. Cleanup the transaction C<$txn_id>, removing it completely from
  33. the filesystem C<$fs>.
  34. =item SVN::Fs::set_warning_func($fs, $code, $baton)
  35. =item SVN::Fs::unparse_id($id)
  36. Return a string containing the unparsed form of the node or node
  37. revision id $id, which must be a C<_p_svn_fs_id_t> object.
  38. TODO - why isn't this a method of that object?
  39. =item SVN::Fs::version()
  40. TODO - what can we do with the _p_svn_version_t value returned?
  41. =item SVN::Fs::create_access($username)
  42. Return a new C<_p_svn_fs_access_t> object representing C<$username>.
  43. C<$username> is presumed to have been authenticated by the caller.
  44. =back
  45. =cut
  46. package _p_svn_fs_t;
  47. =head1 _p_svn_fs_t
  48. =over
  49. =item $fs-E<gt>begin_txn($rev)
  50. Creates a new transaction in the repository, and returns a
  51. C<_p_svn_fs_txn_t> object representing it. The new transaction's
  52. base revision will be $rev, which should be a number.
  53. =item $fs-E<gt>change_rev_prop
  54. =item $fs-E<gt>generate_lock_token()
  55. Generate a unique lock-token using C<$fs>.
  56. TODO - translate this to apply to Perl:
  57. This can be used in to populate lock-E<gt>token before calling
  58. svn_fs_attach_lock().
  59. =item $fs-E<gt>get_access()
  60. The filesystem's current access context, as a C<_p_svn_fs_access_t>
  61. object. Returns undef if no access context has been set with
  62. the C<set_access()> method.
  63. =item $fs-E<gt>get_lock
  64. =item $fs-E<gt>get_locks
  65. =item $fs-E<gt>get_uuid()
  66. The UUID associated with C<$fs>.
  67. =item $fs-E<gt>list_transactions()
  68. A reference to an array of all currently active transactions in the
  69. filesystem. Each one is a string containing the transaction's ID,
  70. suitable for passing to C<$fs-E<gt>open_txn()>.
  71. =item $fs-E<gt>lock
  72. =item $fs-E<gt>open_txn($name)
  73. Get a transaction in the repository by name. Returns a
  74. C<_p_svn_fs_txn_t> object.
  75. =item $fs-E<gt>revision_prop($rev, $propname)
  76. The value of revision property C<$propname> in revision C<$rev>.
  77. =item $fs-E<gt>revision_proplist($rev)
  78. A hashref containing the names and values of all revision properties
  79. from revision C<$rev>.
  80. =item $fs-E<gt>revision_root
  81. =item $fs-E<gt>set_access($access)
  82. Associate an access context with an open filesystem.
  83. This method can be run multiple times on the same open
  84. filesystem, in order to change the filesystem access context for
  85. different filesystem operations. C<$access> should be
  86. a C<_p_svn_fs_access_t> object, or undef to disassociate the
  87. current access context from the filesystem.
  88. =item $fs-E<gt>set_uuid($uuid)
  89. Associate C<$uuid> with C<$fs>.
  90. =item $fs-E<gt>unlock
  91. =item $fs-E<gt>youngest_rev()
  92. Return the number of the youngest revision in the filesystem.
  93. The oldest revision in any filesystem is numbered zero.
  94. =back
  95. =cut
  96. our @methods = qw/ youngest_rev revision_root revision_prop revision_proplist
  97. change_rev_prop list_transactions open_txn begin_txn
  98. get_uuid set_uuid set_access get_access
  99. lock unlock get_lock get_locks generate_lock_token path /;
  100. for (@methods) {
  101. no strict 'refs';
  102. *{$_} = *{"SVN::Fs::$_"};
  103. }
  104. package _p_svn_fs_root_t;
  105. =head1 _p_svn_fs_root_t
  106. =over
  107. =item $root-E<gt>apply_text
  108. =item $root-E<gt>apply_textdelta
  109. =item $root-E<gt>change_node_prop($path, $propname, $value)
  110. =item $root-E<gt>check_path($path)
  111. Kind of node at C<$path>. A number which matches one of these constants:
  112. $SVN::Node::none, $SVN::Node::file,
  113. $SVN::Node::dir, $SVN::Node::unknown.
  114. =item $root-E<gt>close_root
  115. =item $root-E<gt>closest_copy
  116. =item $root-E<gt>copied_from
  117. =item $root-E<gt>copy
  118. =item $root-E<gt>delete
  119. =item $root-E<gt>dir_entries
  120. =item $root-E<gt>file_contents
  121. =item $root-E<gt>file_length
  122. =item $root-E<gt>file_md5_checksum
  123. =item $root-E<gt>fs()
  124. The filesystem to which C<$root> belongs, as a C<_p_svn_fs_t> object.
  125. =item $root-E<gt>is_dir($path)
  126. True if there is a node at C<$path> which is a directory.
  127. =item $root-E<gt>is_file($path)
  128. True if there is a node at C<$path> which is a file.
  129. =item $root-E<gt>is_revision_root()
  130. True if the root comes from a revision (i.e., the contents has already been
  131. committed).
  132. =item $root-E<gt>is_txn_root()
  133. True if the root comes from a transaction.
  134. =item $root-E<gt>make_dir
  135. =item $root-E<gt>make_file
  136. =item $root-E<gt>node_created_path($path)
  137. =item $root-E<gt>node_created_rev($path)
  138. =item $root-E<gt>node_history($path)
  139. TODO - _p_svn_fs_history_t
  140. =item $root-E<gt>node_id($path)
  141. =item $root-E<gt>node_prop($path, $propname)
  142. =item $root-E<gt>node_proplist($path)
  143. =item $root-E<gt>paths_changed()
  144. A reference to a hash indicating what changes are made in the root.
  145. The keys are the paths of the files changed, starting with C</> to
  146. indicate the top-level directory of the repository. The values
  147. are C<_p_svn_fs_path_change_t> objects which contain information about
  148. what kind of changes are made.
  149. =item $root-E<gt>revision_link
  150. =item $root-E<gt>revision_root_revision
  151. Revision number of the revision the root comes from.
  152. For transaction roots, returns C<$SVN::Core::INVALID_REVNUM>.
  153. =back
  154. =cut
  155. our @methods = qw/ apply_textdelta apply_text change_node_prop
  156. check_path close_root copied_from copy
  157. dir_entries delete file_contents closest_copy
  158. file_length file_md5_checksum is_dir is_file
  159. is_revision_root is_txn_root make_dir make_file
  160. node_created_rev node_history node_id node_prop
  161. node_proplist paths_changed revision_link
  162. revision_root_revision /;
  163. *fs = *SVN::Fs::root_fs;
  164. *txn_name = *_p_svn_fs_txn_t::root_name;
  165. for (@methods) {
  166. no strict 'refs';
  167. *{$_} = *{"SVN::Fs::$_"};
  168. }
  169. package _p_svn_fs_history_t;
  170. use SVN::Base qw(Fs svn_fs_history_);
  171. =head1 _p_svn_fs_history_t
  172. =over
  173. =item $history-E<gt>location()
  174. In list context, a list of two items: the path to the node whose history
  175. this is, and the revision number in which it exists. In scalar context
  176. returns only the revision number.
  177. =item $history-E<gt>prev($cross_copies)
  178. =back
  179. =cut
  180. package _p_svn_fs_txn_t;
  181. use SVN::Base qw(Fs svn_fs_txn_);
  182. =head1 _p_svn_fs_txn_t
  183. =over
  184. =item $txn-E<gt>abort()
  185. Abort the transaction. Any changes made in C<$txn> are discarded, and
  186. the filesystem is left unchanged.
  187. Note: This function first sets the state of C<$txn> to 'dead', and
  188. then attempts to purge it and any related data from the filesystem.
  189. If some part of the cleanup process fails, C<$txn> and some portion
  190. of its data may remain in the database after this function returns.
  191. Use C<$fs-E<gt>purge_txn()> to retry the transaction cleanup.
  192. =item $txn-E<gt>base_revision()
  193. The transaction's base revision number.
  194. =item $txn-E<gt>change_prop($name, $value)
  195. Add, change, or remove a property from the transaction.
  196. If C<$value> is C<undef> then the property C<$name> is removed,
  197. if it exists. Otherwise the property C<$name> is set to the
  198. new value.
  199. =item $txn-E<gt>commit
  200. =item $txn-E<gt>name()
  201. Full name of the revision, in the same format as can be passed
  202. to C<$fs-E<gt>open_txn()>.
  203. =item $txn-E<gt>prop($name)
  204. The value of the transaction's C<$name> property.
  205. =item $txn-E<gt>proplist()
  206. A reference to a hash containing all the transaction's properties,
  207. keyed by name.
  208. =item $txn-E<gt>root()
  209. The root directory of the transaction, as a C<_p_svn_fs_root_t> object.
  210. =back
  211. =cut
  212. *commit = *SVN::Fs::commit_txn;
  213. *abort = *SVN::Fs::abort_txn;
  214. *change_prop = *SVN::Fs::change_txn_prop;
  215. package _p_svn_fs_access_t;
  216. use SVN::Base qw(Fs svn_fs_access_);
  217. =head1 _p_svn_fs_access_t
  218. =head2 SYNOPSIS
  219. my $access = SVN::Fs::create_access($username);
  220. my $access = $fs->get_access;
  221. $fs->set_access($access);
  222. my $username = $access->get_username;
  223. $access->add_lock_token($token);
  224. =head2 METHODS
  225. =over
  226. =item $access-E<gt>add_lock_token($token)
  227. Push a lock-token into the access context. The
  228. context remembers all tokens it receives, and makes them available
  229. to fs functions.
  230. =item $access-E<gt>get_username
  231. The username represented by the access context.
  232. =back
  233. =cut
  234. package _p_svn_fs_dirent_t;
  235. use SVN::Base qw(Fs svn_fs_dirent_t_);
  236. =head1 svn_fs_dirent_t
  237. An object representing a directory entry. Values of this type are returned
  238. as the values in the hash returned by C<$root-E<gt>dir_entries()>. They
  239. are like L<svn_dirent_t|SVN::Core/svn_dirent_t> objects, but have less
  240. information.
  241. =over
  242. =item $dirent-E<gt>id()
  243. TODO
  244. =item $dirent-E<gt>kind()
  245. Node kind. A number which matches one of these constants:
  246. $SVN::Node::none, $SVN::Node::file,
  247. $SVN::Node::dir, $SVN::Node::unknown.
  248. =item $dirent-E<gt>name()
  249. The filename of the directory entry.
  250. =back
  251. =cut
  252. package _p_svn_fs_path_change_t;
  253. use SVN::Base qw(Fs svn_fs_path_change_t_);
  254. =head1 _p_svn_fs_path_change_t
  255. =over
  256. =item $change-E<gt>change_kind()
  257. The type of change made. A number which matches one of the following:
  258. =over
  259. =item $SVN::Fs::PathChange::modify
  260. Content at path modified.
  261. =item $SVN::Fs::PathChange::add
  262. Path added in transaction.
  263. =item $SVN::Fs::PathChange::delete
  264. Path removed in transaction.
  265. =item $SVN::Fs::PathChange::replace
  266. Path removed and re-added in transaction.
  267. =item $SVN::Fs::PathChange::reset
  268. Ignore all previous change items for path (internal-use only).
  269. =back
  270. =item $change-E<gt>node_rev_id()
  271. Node revision id of changed path. A C<_p_svn_fs_id_t> object.
  272. =item $change-E<gt>prop_mod()
  273. True if the properties were modified.
  274. =item $change-E<gt>text_mod()
  275. True if the text (content) was modified.
  276. =back
  277. =head1 COPYRIGHT
  278. Licensed to the Apache Software Foundation (ASF) under one
  279. or more contributor license agreements. See the NOTICE file
  280. distributed with this work for additional information
  281. regarding copyright ownership. The ASF licenses this file
  282. to you under the Apache License, Version 2.0 (the
  283. "License"); you may not use this file except in compliance
  284. with the License. You may obtain a copy of the License at
  285. http://www.apache.org/licenses/LICENSE-2.0
  286. Unless required by applicable law or agreed to in writing,
  287. software distributed under the License is distributed on an
  288. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  289. KIND, either express or implied. See the License for the
  290. specific language governing permissions and limitations
  291. under the License.
  292. =cut
  293. package SVN::Fs::PathChange;
  294. use SVN::Base qw(Fs svn_fs_path_change_);
  295. 1;