CatalystX-CMS
view release on metacpan or search on metacpan
lib/CatalystX/CMS/File.pm view on Meta::CPAN
)
{
$self->debug and warn "no status for $dir";
unshift( @to_add, $dir );
$dir = $dir->parent;
$dir_status = $dir->status;
$self->debug and warn "dir $dir status = $dir_status";
# avoid infinite loops
if ( $dir eq '/' ) {
croak "infinite loop looking up svn workdir tree for $self";
}
}
# found one that svn knows about
if ( $dir_status eq '?' or $dir_status eq 'A' ) {
unshift( @to_add, $dir );
}
$self->debug and warn "to_add: " . dump \@to_add;
# we 'add' each dir non-recursively
# so that we do not add unaffected files (like lock files) by mistake.
for my $d (@to_add) {
$d->add( ['-N'] ) unless $d->status eq 'A';
my @opts = '-N';
if ($username) {
push( @opts, "--username $username" );
}
$d->commit( "new directory", \@opts )
or croak "add directory $d failed: " . $d->errstr;
}
# now check the stat of the file itself
my $stat = $self->status;
if ( $stat && $stat eq '?' ) {
$self->add;
}
my $ret;
# is file modified at all?
if ( $self->modified ) {
$ret = $self->commit($message);
}
else {
# no attempt made to commit unmodified file
$ret = -1;
}
unless ($leave_lock) {
$self->unlock or croak "can't unlock $self: $!";
}
return $ret;
}
=head2 escape_tt
Returns content() with all TT code wrapped in special XHTML tagset
<code class="tt">
This is to allow for such code to be escaped online or otherwise parsed
with a XML parser.
=cut
sub escape_tt {
my $self = shift;
my $content = $self->content;
$content =~ s/\[\%/<code class="tt">\[\%/g;
$content =~ s/\%\]/\%\]<\/code>/g;
return $content;
}
# this isn't currently used but could be.
#sub as_chunks {
# my $self = shift;
# my $escape = shift || 0;
#
# # NOTE the regex keeps the surrounding whitespace WITH the PROCESS
# # line so that it is preserved in the web interaction.
# my @chunks = split( m!(\s*\[\%\ +PROCESS tt/share/\S+\ +\%\]\s*)!s,
# $self->content );
#
# # turn into array of hashrefs
# my @hashes;
#
# #carp "raw chunks: " . dump \@chunks;
#
# for my $chunk (@chunks) {
# my $h = { content => $chunk };
#
# # editable text
# unless ( $chunk =~ m/^\s*\[\%\s+PROCESS/ ) {
# $h->{editable} = 1;
#
# # wrap TT instructions in <pre> tags so they show verbatim
# if ($escape) {
# $h->{content} =~ s,\[\%,<pre class="tt">\[\%,g;
# $h->{content} =~ s,\%\],\%\]</pre>,g;
# }
#
# }
#
# # shared text -- render it as TT would but just that chunk.
# else {
# $h->{editable} = 0;
# }
#
# push( @hashes, $h );
# }
#
# return \@hashes;
#}
#
#=head2 save_chunk( I<chunk_id>, I<new_text>, I<message> )
( run in 2.546 seconds using v1.01-cache-2.11-cpan-600a1bdf6e4 )