use strict;
use warnings;
-use Carp;
+use Carp qw(croak confess);
use File::Glob qw(:glob);
use CIL::VCS::Factory;
VCS
UserName UserEmail
vcs hook
+ vcs_revision
));
my $defaults = {
$base = '' unless defined $base;
my $globpath = $self->IssueDir . "/${prefix}_${base}*.cil";
- my @filenames = bsd_glob($globpath);
+ my @filenames;
+ if ( $self->vcs_revision ) {
+ @filenames = $self->vcs->glob_rev($self->vcs_revision, $globpath);
+ }
+ else {
+ @filenames = bsd_glob($globpath);
+ }
my @entities;
foreach my $filename ( sort @filenames ) {
}
}
+sub file_exists {
+ my ($self, $filename) = @_;
+ if ( $self->vcs_revision ) {
+ $self->vcs->file_exists($self->vcs_revision, $filename);
+ }
+ else {
+ -f $filename;
+ }
+}
+
+sub dir_exists {
+ my ($self, $filename) = @_;
+ if ( $self->vcs_revision ) {
+ $self->vcs->dir_exists($self->vcs_revision, $filename);
+ }
+ else {
+ -f $filename;
+ }
+}
+
+sub parse_cil_file {
+ my ($self, $filename, $last_field) = @_;
+
+ if ( $self->vcs_revision ) {
+ my $fh = $self->vcs->get_fh($self->vcs_revision, $filename);
+ CIL::Utils->parse_from_fh($fh, $last_field);
+ }
+ else {
+ CIL::Utils->parse_cil_file($filename, $last_field);
+ }
+}
+
+sub save {
+ my ($self, $filename, $data, @fields) = @_;
+
+ if ( $self->vcs_revision ) {
+ confess "tried to ->save on alternate revision";
+ }
+ else {
+ CIL::Utils->write_cil_file( $filename, $data, @fields );
+ }
+}
+
## ----------------------------------------------------------------------------
1;
## ----------------------------------------------------------------------------
my $filename = $class->create_filename($cil, $name);
croak "filename '$filename' does no exist"
- unless -f $filename;
+ unless $cil->file_exists($filename);
- my $data = CIL::Utils->parse_cil_file($filename, $class->last_field);
+ my $data = $cil->parse_cil_file($filename, $class->last_field);
my $issue = $class->new_from_data( $name, $data );
return $issue;
}
my $filename = $self->create_filename($cil, $self->name);
my $fields = $self->fields();
- CIL::Utils->write_cil_file( $filename, $self->{data}, @$fields );
+
+ $cil->save( $filename, $self->{data}, @$fields );
}
sub as_output {