metadb.pm #3

  • //
  • guest/
  • perforce_software/
  • revml/
  • lib/
  • VCP/
  • Source/
  • metadb.pm
  • View
  • Commits
  • Open Download .zip Download (3 KB)
package VCP::Source::metadb ;

=head1 NAME

VCP::Source::metadb - Read SCM metadata from a metadb file

=head1 SYNOPSIS

## Mostly used internally by the vcp filter and vcp transfer commands

=head1 DESCRIPTION

This source driver allows L<vcp|vcp> to read a set of revisions from
a metadata database written by VCP::Dest::metadb.

NOTE: passing a reference in the options array to new:

    $s = VCP::Source::metadb->new( $spec, [ $real_source ] );

sets the metadb's source to point to the real repository it should
get revisions from.  This should only be necessary for a transfer
operation, as filtering does not need to access the source repository.

=cut


use strict ;

use VCP::Logger qw( pr BUG );
use VCP::Utils qw( empty );

use vars qw( $VERSION $debug ) ;

$VERSION = 0.1 ;

use base qw( VCP::Source VCP::Utils::metadb ) ;

use fields (
   'META_DB',        ## The bulk data file with the revisions
   'REAL_SOURCE',    ## The *real* source to use if transferring revs
) ;


#=item new
#
#Creates a new instance.  The only parameter is '-dtd', which overrides
#the default DTD found by searching for modules matching RevML::DTD:v*.pm.
#
#=cut

sub new {
   my VCP::Source::metadb $self = shift->SUPER::new;

   my ( $spec, $options ) = @_ ;

   $self->parse_repo_spec( $spec )
      unless empty $spec;

   ## grep out the REAL_SOURCE option
   @$options = grep
      !ref || ( ( $self->{REAL_SOURCE} = $_ ) && 0 ),
      @$options;

   $self->parse_options( $options );

   return $self;
}


sub init {
   my VCP::Source::metadb $self = shift ;

   $self->SUPER::init;

   $self->real_source->init
      if $self->real_source;

   die "VCP::Source::metadb::repo_server not set"
      if empty $self->repo_server;

   $self->repo_id( "metadb:" . $self->repo_server );

   $self->meta_db->open_db;

   return $self ;
}


sub dest {
   my VCP::Source::metadb $self = shift ;

   return $self->SUPER::dest( @_ );
}


sub handle_header {
   my VCP::Source::metadb $self = shift ;

   $self->dest->handle_header( $self->read_header )
      if $self->dest;
}


sub real_source {
   my VCP::Source::metadb $self = shift ;
    return $self->{REAL_SOURCE};
}


sub get_rev {
   my VCP::Source::metadb $self = shift ;
   BUG "metadb can't get a rev without a real source"
      unless $self->{REAL_SOURCE};

   return $self->{REAL_SOURCE}->get_rev( @_ );
}


sub copy_revs {
   my VCP::Source::metadb $self = shift ;

   $self->meta_db->foreach_record_do(
      sub {
         my $r = VCP::Rev->deserialize( @_ );
         $self->send_rev( $r );
      }
   );

}


=head1 AUTHOR

Barrie Slaymaker <barries@slaysys.com>

=head1 COPYRIGHT

Copyright (c) 2000, 2001, 2002 Perforce Software, Inc.
All rights reserved.

See L<VCP::License|VCP::License> (C<vcp help license>) for the terms of use.

=cut

1 ;
# Change User Description Committed
#4 4021 Barrie Slaymaker - Remove all phashes and all base & fields pragmas
- Work around SWASHGET error
#3 4012 Barrie Slaymaker - Remove dependance on pseudohashes (deprecated Perl feature)
#2 3855 Barrie Slaymaker - vcp scan, filter, transfer basically functional
    - Need more work in re: storage format, etc, but functional
#1 3778 Barrie Slaymaker - VCP::*::metadb allows metadata to be queued on disk
           - PRELIMINARY