NAME

VCP::Source - A base class for repository sources


SYNOPSIS


DESCRIPTION


OPTIONS

--bootstrap

  --bootstrap=pattern

Forces all files matching the given shell regular expression (may use wildcards like "*", "?", and "...") to have their first revisions transferred as complete copies instead of deltas. This is useful when you want to transfer a revision other than the first revision as the first revision in the target repository. It is also useful when you want to skip some revisions in the target repository (although the Map filter has superceded this use).

--continue

Tells VCP to continue where it left off from last time. This will not detect new branches of already transferred revisions (this limitation should be lifted, but results in an expensive rescan of metadata), but will detect updates to already transferred revisions.


SUBCLASSING

This class uses the fields pragma, so you'll need to use base and possibly fields in any subclasses. See VCP::Plugin for methods often needed in subclasses.

Subclass utility API

options_spec

Adds common VCP::Source options to whatever options VCP::Plugin parses:

dest

Sets/Gets a reference to the VCP::Dest object. The source uses this to call handle_header(), handle_rev(), and handle_end() methods.

continue

Sets/Gets the CONTINUE field (which the user sets via the --continue flag)

real_source

Returns the reference to be used when sending revisions to the destination.

Each revision has a pointer to the source that sends it so that filters and destinations can call get_source_file().

Most sources return $self; Sources that spool data, such as VCP::Source::metadb, need to specify a real source. They do so by overloading this method. VCP::Source::revml does not do this, as it supplies a get_source_file().

rev_mode

    my $mode = $self->rev_mode( $filebranch_id, $rev_id );

Returns FALSE, "base", or "normal" as a function of the filebranch and rev_id. Do not queue the revision if this returns FALSE (you may also skip any preceding revisions). Queue it only as a base revision if it returns "base", and queue it as a full revision otherwise.

Not all base revs will be sent; base revs that have no child revs will not be sent.

Always returns "normal" when not in continue mode.

queue_rev

Some revs can't be sent immediately. They get queued. Once queued, the revision may not be altered. All revisions must be queued before being sent. All revs from the source repository should be queued, --continue processing is automatic. Placeholders should be inserted for all branches, even empty ones.

This updates last_rev and last_rev_for_filebranch.

Returns FALSE if the rev cannot be queued, for instance if it's already been queued once.

rev_mode() should be called before creating a rev, or at least before queue_rev()ing it in order to see if and in what form the rev should be sent.

queued_rev

    $self->queued_rev( $id );

Returns a queued rev by id.

Sources where revs can arrive willy-nilly, like VCP::Source::revml, queue up all revs and need to randomly access them.

last_rev

Returns the last revision queued.

last_rev_for_filebranch

    $self->last_rev_for_filebranch( $filebranch_id );

Returns the last revision queued on the indicated filebranch.

set_last_rev_in_filebranch_previous_id

    $self->set_last_rev_in_filebranch_previous_id( $r );

If there is a last_rev_for_filebranch for $r->filebranch_id, sets its previous_id to point to $r. This is useful for sources which scan in most-recent-first order.

already_queued

    $self->already_queued( $id );

Returns true if the indicated id was queued.

queued_rev_count

Returns (does not set) the number of revs queued so far.

Replaces the deprecated function sent_rev_count().

store_cached_revs

    $self->store_cached_revs;

For parsers which read history one file at a time and branch in rev_id space, like VCP::Source::cvs, it's possible to flush all revs to disk after each file is parsed. This method takes the last VCP::Rev in each filebranch and stores it to disk, freeing memory.

send_revs

    $self->send_revs;

Removes and sends all revs accumulated so far. Called automatically after scan_metadata().


SUBCLASS OVERLOADS

These methods should be overridded in any subclasses.

scan_metadata

This is called to scan the metadata for the source repository. It should call rev_mode() for each revision found (including any that need to be concocted to make up for collapsed metadata in the source, like VSS or CVS deletes or CVS branch creation) and if that returns TRUE, then queue_rev() should be called.

If rev_mode() returns "base", then the transfer is in --continue mode and this rev should be built as or converted to a base revision. The easiest way to do this is to build it normally and then call $r->base_revify().

If the metadata source returns metadata from most recent to oldest, as do most file history reports, the previous_id() need not be set until the next revision in a filebranch is scanned. The most recent rev passed to queue_rev() is available by calling last_rev(), if the metadata is one branch at a time, and the last rev in each filebranch is available by calling last_rev_for_filebranch().

If the metadata is scanned one file or filebranch at a time and branched are all created by the time the end of a file's metadata arrives, calling store_cached_revs() will flush all queued revs from the last_rev() and last_rev_for_filebranch() in-memory caches to the disk cache (all other revs are flushed as their successors arrive).

There is no easy way to handle randomly ordered metadata at this time, typically a source will accumulate as little as it can in memory and queue the rest. See VCP::Source::cvs for an example of this.

Once scan_metadata() is complete, send_revs() will be called automatically.

get_source_file

All sources must provide a way for the destination to fetch a revision.

handle_header

REQUIRED OVERLOAD.

Subclasses must add all repository-specific info to the $header, at least including rep_type and rep_desc.

   $header->{rep_type} => 'p4',
   $self->p4( ['info'], \$header->{rep_desc} ) ;

The subclass must pass the $header on to the dest:

   $self->dest->handle_header( $header )
      if $self->dest;

This may be called when dest is null to allow the source to initialize itself when it won't be scanning the real source. So the if $self->dest is important.

That's not the case for copy_revs().

handle_footer

Not a required overload, as the footer carries no useful information at this time. Overriding methods must call this method to pass the $footer on:
   $self->SUPER::handle_footer( $footer ) ;

parse_time

   $time = $self->parse_time( $timestr ) ;

Parses "[cc]YY/MM/DD[ HH[:MM[:SS]]]".

Will add ability to use format strings in future. HH, MM, and SS are assumed to be 0 if not present.

Returns a time suitable for feeding to localtime or gmtime.

Assumes local system time, so no good for parsing times in revml, but that's not a common thing to need to do, so it's in VCP::Source::revml.pm.

bootstrap

Sets (and parses) or gets the bootstrap spec.

Can be called plain:

   $self->bootstrap( $bootstrap_spec ) ;

See the command line documentation for the format of $bootstrap_spec.

is_bootstrap_mode

   ... if $self->is_bootstrap_mode( $file ) ;

Compares the filename passed in against the list of bootstrap regular expressions set by /bootstrap.

The file should be in a format similar to the command line spec for whatever repository is passed in, and not relative to rev_root, so "//depot/foo/bar" for p4, or "module/foo/bar" for cvs.

This is typically called in the subbase class only after looking at the revision number to see if it is a first revision (in which case the subclass should automatically put it in bootstrap mode).


COPYRIGHT

Copyright 2000, Perforce Software, Inc. All Rights Reserved.

This module and the VCP package are licensed according to the terms given in the file LICENSE accompanying this distribution, a copy of which is included in vcp.


AUTHOR

Barrie Slaymaker <barries@slaysys.com>


Last updated: Fri Jun 4 14:21:32 2004