9 date 2008.01.22.03.21.26; author TWikiContributor; state Exp;
14 date 2007.01.16.04.12.04; author TWikiContributor; state Exp;
19 date 2006.06.25.16.26.33; author TWikiContributor; state Exp;
24 date 2006.02.01.12.01.25; author TWikiContributor; state Exp;
39 @---+ Package =TWiki::Store::RcsFile=
41 This class is PACKAGE PRIVATE to Store, and should never be
42 used from anywhere else. It is the base class of implementations of stores
43 that manipulate RCS format files.
45 The general contract of the methods on this class and its subclasses
46 calls for errors to be signalled by Error::Simple exceptions.
48 Refer to Store.pm for models of usage.
53 ---++ ClassMethod *new* <tt>($session,$web,$topic,$attachment)</tt>
55 Constructor. There is one object per stored file.
57 Note that $web, $topic and $attachment must be untainted!
61 ---++ ObjectMethod *finish* <tt>()</tt>
62 Break circular references.
66 ---++ ObjectMethod *getRevisionInfo* <tt>($version) -> ($rev,$date,$user,$comment)</tt>
68 * =$version= if 0 or undef, or out of range (version number > number of revs) will return info about the latest revision.
70 Returns (rev, date, user, comment) where rev is the number of the rev for which the info was recovered, date is the date of that rev (epoch s), user is the login name of the user who saved that rev, and comment is the comment associated with the rev.
72 Designed to be overridden by subclasses, which can call up to this method
73 if file-based rev info is required.
77 ---++ ObjectMethod *getLatestRevision* <tt>() -> $text</tt>
79 Get the text of the most recent revision
83 ---++ ObjectMethod *getLatestRevisionTime* <tt>() -> $text</tt>
85 Get the time of the most recent revision
89 ---++ ObjectMethod *getWorkArea* <tt>($key) -> $directorypath</tt>
91 Gets a private directory uniquely identified by $key. The directory is
92 intended as a work area for plugins.
94 The standard is a directory named the same as "key" under
95 $TWiki::cfg{WorkingDir}/work_areas
99 ---++ ObjectMethod *getTopicNames* <tt>() -> @@topics</tt>
101 Get list of all topics in a web
102 * =$web= - Web name, required, e.g. ='Sandbox'=
103 Return a topic list, e.g. =( 'WebChanges', 'WebHome', 'WebIndex', 'WebNotify' )=
107 ---++ ObjectMethod *getWebNames* <tt>() -> @@webs</tt>
109 Gets a list of names of subwebs in the current web
113 ---++ ObjectMethod *searchInWebContent* <tt>($searchString,$web,\@@topics,\%options) -> \%map</tt>
115 Search for a string in the content of a web. The search must be over all
116 content and all formatted meta-data, though the latter search type is
117 deprecated (use searchMetaData instead).
119 * =$searchString= - the search string, in egrep format if regex
120 * =$web= - The web to search in
121 * =\@@topics= - reference to a list of topics to search
122 * =\%options= - reference to an options hash
123 The =\%options= hash may contain the following options:
124 * =type= - if =regex= will perform a egrep-syntax RE search (default '')
125 * =casesensitive= - false to ignore case (defaulkt true)
126 * =files_without_match= - true to return files only (default false)
128 The return value is a reference to a hash which maps each matching topic
129 name to a list of the lines in that topic that matched the search,
130 as would be returned by 'grep'. If =files_without_match= is specified, it will
131 return on the first match in each topic (i.e. it will return only one
132 match per topic, and will not return matching lines).
136 ---++ ObjectMethod *searchInWebMetaData* <tt>($query,\@@topics) -> \%matches</tt>
138 Search for a meta-data expression in the content of a web. =$query= must be a =TWiki::Query= object.
140 Returns a reference to a hash that maps the names of topics that all matched
141 to the result of the query expression (e.g. if the query expression is
142 'TOPICPARENT.name' then you will get back a hash that maps topic names
145 SMELL: this is *really* inefficient!
149 ---++ ObjectMethod *moveWeb* <tt>($newWeb)</tt>
155 ---++ ObjectMethod *getRevision* <tt>($version) -> $text</tt>
157 Get the text for a given revision. The version number must be an integer.
159 *Virtual method* - must be implemented by subclasses
163 ---++ ObjectMethod *storedDataExists* <tt>() -> $boolean</tt>
165 Establishes if there is stored data associated with this handler.
169 ---++ ObjectMethod *getTimestamp* <tt>() -> $integer</tt>
171 Get the timestamp of the file
172 Returns 0 if no file, otherwise epoch seconds
176 ---++ ObjectMethod *restoreLatestRevision* <tt>($user)</tt>
178 Restore the plaintext file from the revision at the head.
182 ---++ ObjectMethod *removeWeb* <tt>($web)</tt>
184 * =$web= - web being removed
186 Destroy a web, utterly. Removed the data and attachments in the web.
188 Use with great care! No backup is taken!
192 ---++ ObjectMethod *moveTopic* <tt>($newWeb,$newTopic)</tt>
198 ---++ ObjectMethod *copyTopic* <tt>($newWeb,$newTopic)</tt>
204 ---++ ObjectMethod *moveAttachment* <tt>($newWeb,$newTopic,$newAttachment)</tt>
206 Move an attachment from one topic to another. The name is retained.
210 ---++ ObjectMethod *copyAttachment* <tt>($newWeb,$newTopic)</tt>
212 Copy an attachment from one topic to another. The name is retained.
216 ---++ ObjectMethod *isAsciiDefault* <tt>() -> $boolean</tt>
218 Check if this file type is known to be an ascii type file.
222 ---++ ObjectMethod *setLock* <tt>($lock,$user)</tt>
224 Set a lock on the topic, if $lock, otherwise clear it.
227 SMELL: there is a tremendous amount of potential for race
228 conditions using this locking approach.
232 ---++ ObjectMethod *isLocked* <tt>() -> ($user,$time)</tt>
234 See if a twiki lock exists. Return the lock user and lock time if it does.
238 ---++ ObjectMethod *setLease* <tt>($lease)</tt>
240 * =$lease= reference to lease hash, or undef if the existing lease is to be cleared.
242 Set an lease on the topic.
246 ---++ ObjectMethod *getLease* <tt>() -> $lease</tt>
248 Get the current lease on the topic.
252 ---++ ObjectMethod *removeSpuriousLeases* <tt>($web)</tt>
254 Remove leases that are not related to a topic. These can get left behind in
255 some store implementations when a topic is created, but never saved.
259 ---++ ObjectMethod *getStream* <tt>() -> \*STREAM</tt>
261 Return a text stream that will supply the text stored in the topic.
265 ---++ ObjectMethod *numRevisions* <tt>() -> $integer</tt>
267 Must be provided by subclasses.
269 Find out how many revisions there are. If there is a problem, such
270 as a nonexistent file, returns 0.
272 *Virtual method* - must be implemented by subclasses
276 ---++ ObjectMethod *initBinary* <tt>()</tt>
278 Initialise a binary file.
280 Must be provided by subclasses.
282 *Virtual method* - must be implemented by subclasses
286 ---++ ObjectMethod *initText* <tt>()</tt>
288 Initialise a text file.
290 Must be provided by subclasses.
292 *Virtual method* - must be implemented by subclasses
296 ---++ ObjectMethod *addRevisionFromText* <tt>($text,$comment,$user,$date)</tt>
298 Add new revision. Replace file with text.
299 * =$text= of new revision
300 * =$comment= checkin comment
301 * =$user= is a wikiname.
302 * =$date= in epoch seconds; may be ignored
304 *Virtual method* - must be implemented by subclasses
308 ---++ ObjectMethod *addRevisionFromStream* <tt>($fh,$comment,$user,$date)</tt>
310 Add new revision. Replace file with contents of stream.
311 * =$fh= filehandle for contents of new revision
312 * =$comment= checkin comment
313 * =$user= is a wikiname.
314 * =$date= in epoch seconds; may be ignored
316 *Virtual method* - must be implemented by subclasses
320 ---++ ObjectMethod *replaceRevision* <tt>($text,$comment,$user,$date)</tt>
322 Replace the top revision.
323 * =$text= is the new revision
324 * =$date= is in epoch seconds.
325 * =$user= is a wikiname.
326 * =$comment= is a string
328 *Virtual method* - must be implemented by subclasses
332 ---++ ObjectMethod *deleteRevision* <tt>()</tt>
334 Delete the last revision - do nothing if there is only one revision
336 *Virtual method* - must be implemented by subclasses
340 ---++ ObjectMethod *revisionDiff* <tt>($rev1,$rev2,$contextLines) -> \@@diffArray</tt>
342 rev2 newer than rev1.
343 Return reference to an array of [ diffType, $right, $left ]
345 *Virtual method* - must be implemented by subclasses
351 ---++ ObjectMethod *getRevisionAtTime* <tt>($time) -> $rev</tt>
353 Get a single-digit version number for the rev that was alive at the
354 given epoch-secs time, or undef it none could be found.
356 *Virtual method* - must be implemented by subclasses
360 ---++ ObjectMethod *getAttachmentAttributes* <tt>($web,$topic,$attachment)</tt>
362 returns [stat] for any given web, topic, $attachment
363 SMELL - should this return a hash of arbitrary attributes so that
364 SMELL + attributes supported by the underlying filesystem are supported
365 SMELL + (eg: windows directories supporting photo "author", "dimension" fields)
369 ---++ ObjectMethod *getAttachmentList* <tt>($web,$topic)</tt>
371 returns {} of filename => { key => value, key2 => value } for any given web, topic
372 Ignores files starting with _ or ending with ,v
376 ---++ ObjectMethod *stringify* <tt>()</tt>
378 Generate string representation for debugging
382 ---++ ObjectMethod *recordChange* <tt>($user,$rev,$more)</tt>
383 Record that the file changed
387 ---++ ObjectMethod *eachChange* <tt>($since) -> $iterator</tt>
389 Return iterator over changes - see Store for details
402 used from anywhere else. Base class of implementations of stores
405 ---++ ObjectMethod *readMetaData* <tt>($name) -> $text</tt>
407 Get a meta-data block for this web
413 $TWiki::cfg{RCS}{WorkAreaDir}
417 ---++ ObjectMethod *saveMetaData* <tt>($web,$name) -> $text</tt>
419 Write a named meta-data string. If web is given the meta-data
420 is stored alongside a web.
424 ---++ ObjectMethod *restoreLatestRevision* <tt>($wikiname)</tt>
426 sub _constructAttributesForAutoAttached
427 as long as stat is defined, return an emulated set of attributes for that attachment.
468 ---++ ObjectMethod *restoreLatestRevision* <tt>()</tt>