Skip to content

Commit

Permalink
Item12477: Partial changes for review
Browse files Browse the repository at this point in the history
 - Documentation changes
 - copyAttachment  / saveAttachment now log the attachment name & rev

These are visually tested against the changes file contents.  Unit tests
pass, but don't test the actual changes.

Still needs a lot of work.
  • Loading branch information
gac410 committed Dec 15, 2014
1 parent 5332586 commit d7fc140
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 9 deletions.
18 changes: 17 additions & 1 deletion PlainFileStoreContrib/lib/Foswiki/Store/PlainFile.pm
Expand Up @@ -1139,7 +1139,23 @@ sub _writeMetaFile {
---++ ObjectMethod recordChange(%args)
See Foswiki::Store for documentation
See Foswiki::Store for calling conventions
Records changes in a plain text file, fields separated by tab delimiters
| Topic | cUID | revision | more (minor delRev repRev) | verb | Attachment | attachRev | Other Web.Topic | OtherAttachemnt |
| y | y | y | | update | ? | ? | | |
| y | y | y | | insert | ? | ? | (if move) | (if move) |
| y | y | y | | remove | ? | ? | (if move) | (if move) |
This extends the file format from 1.1.x. All fields past the "more" are new in version 1.2
* Topic, cUID, revision and verb are always provided. more is empty or provided if needed.
* Attachment name & rev are provided for attachment changes
* Other Web.Topic and other Attachment are provided for "move" operations
* "remove", the "other" fields are the new locations/names
* "insert", the "other" fields are the previous location/names
=cut

Expand Down
28 changes: 26 additions & 2 deletions RCSStoreContrib/lib/Foswiki/Store/Rcs/Handler.pm
Expand Up @@ -1441,7 +1441,23 @@ sub hidePath {
---++ ObjectMethod recordChange(%args)
See Foswiki::Store for documentation
See Foswiki::Store for calling conventions
Records changes in a plain text file, fields separated by tab delimiters
| Topic | cUID | revision | more (minor delRev repRev) | verb | Attachment | attachRev | Other Web.Topic | OtherAttachemnt |
| y | y | y | | update | ? | ? | | |
| y | y | y | | insert | ? | ? | (if move) | (if move) |
| y | y | y | | remove | ? | ? | (if move) | (if move) |
This extends the file format from 1.1.x. All fields past the "more" are new in version 1.2
* Topic, cUID, revision and verb are always provided. more is empty or provided if needed.
* Attachment name & rev are provided for attachment changes
* Other Web.Topic and other Attachment are provided for "move" operations
* "remove", the "other" fields are the new locations/names
* "insert", the "other" fields are the previous location/names
=cut

Expand Down Expand Up @@ -1495,9 +1511,17 @@ sub recordChange {
or die("RCSStore: failed to binmode $file: $!");
}

my $attachment = '';
my $attachRev = '';
if ( $args{verb} eq 'update' || $args{verb} eq 'insert' ) {
$attachment = $args{newattachment} || '';
$attachRev = ( defined $args{newattachrev} ) ? $args{newattachrev} : '';
}

# Add the new change to the end of the file
$text .= $args{_meta}->topic || '.';
$text .= "\t$args{cuid}\t$t\t$args{revision}\t$args{more}\n";
$text .= "\t$args{cuid}\t$t\t$args{revision}\t$args{more}";
$text .= "\t$args{verb}\t$attachment\t$attachRev\n";

# Write out the contents. The lock is released on close
print $fh $text
Expand Down
24 changes: 20 additions & 4 deletions RCSStoreContrib/lib/Foswiki/Store/Rcs/Store.pm
Expand Up @@ -191,9 +191,15 @@ sub moveAttachment {
my $handler =
$this->getHandler( $oldTopicObject->web, $oldTopicObject->topic,
$oldAttachment );


if ( $handler->storedDataExists() ) {
$handler->moveAttachment( $this, $newTopicObject->web,
$newTopicObject->topic, $newAttachment );




$this->recordChange(
_meta => $oldTopicObject,
_handler => $handler,
Expand Down Expand Up @@ -222,14 +228,19 @@ sub copyAttachment {
if ( $handler->storedDataExists() ) {
$handler->copyAttachment( $this, $newTopicObject->web,
$newTopicObject->topic, $newAttachment );

my $thandler = $this->getHandler( $oldTopicObject->web, $oldTopicObject->topic );
my $trev = $thandler->getLatestRevisionID();

$this->recordChange(
_meta => $newTopicObject,
_handler => $handler,
cuid => $cUID,
revision => 0,
revision => $trev,
verb => 'insert',
newmeta => $newTopicObject,
newattachment => $newAttachment
newattachment => $newAttachment,
newattachrev => 0,
);
}
}
Expand Down Expand Up @@ -439,16 +450,20 @@ sub saveAttachment {
$handler->addRevisionFromStream( $stream, $comment, $cUID,
$options->{forcedate} );

my $thandler = $this->getHandler( $topicObject->web, $topicObject->topic );
my $trev = $thandler->getLatestRevisionID();

my $rev = $handler->getLatestRevisionID();
$this->recordChange(
_meta => $topicObject,
_handler => $handler,

cuid => $cUID,
revision => $rev,
revision => $trev,
verb => $verb,
newmeta => $topicObject,
newattachment => $name
newattachment => $name,
newattachrev => $rev
);

return $rev;
Expand Down Expand Up @@ -558,6 +573,7 @@ sub delRev {

cuid => $cUID,
revision => $rev,
more => 'delrev',
verb => 'update',
newmeta => $topicObject
);
Expand Down
6 changes: 4 additions & 2 deletions core/lib/Foswiki/Store.pm
Expand Up @@ -736,16 +736,18 @@ chain in to eveavesdrop on Store events
* =update= - a web, topic or attachment has been modified
* =insert= - a web, topic or attachment is being inserted
* =remove= - a topic or attachment is being removed
* =autoattach= - special case of =insert= for autoattachments
* =autoattach= - special case of =insert= for autoattachments (Not implemented by all stores)
* more - descriptive text containing store-specific flags
* minor - Minor change not reported
* delRev - Remove the head revision
* repRev - Replace the head revision
* Provided but never used:
* Other data provided:
* newmeta - Foswiki::Meta object for the new object (not remove)
* newattachment - attachment name (not remove)
* newattachmentrev - Revision of the
* oldmeta - Foswiki::Meta object for the origin of a move (move, remove only)
* oldattachment - origin of move (move, remove only)
* oldattachmentrev - Revision of the attachment
=cut
Expand Down

0 comments on commit d7fc140

Please sign in to comment.