package VCP::Branches ;
=head1 NAME
VCP::Branches - A collection of VCP::Rev objects.
=head1 SYNOPSIS
=head1 DESCRIPTION
Right now, all branches are kept in memory, but we will enable storing them to
disk and recovering them at some point so that we don't gobble huge
tracts of RAM.
=head1 METHODS
=over
=cut
$VERSION = 1 ;
use strict ;
use Carp ;
use VCP::Debug ":debug" ;
use VCP::Rev ;
use fields (
'BRANCHES', ## The branches, sorted or not
'SEEN', ## Oh, the branches we've seen
) ;
=item new
=cut
sub new {
my $class = CORE::shift ;
$class = ref $class || $class ;
my $self ;
{
no strict 'refs' ;
$self = bless [ \%{"$class\::FIELDS"} ], $class ;
}
$self->{BRANCHES} = [] ;
$self->{SEEN} = {} ;
return $self ;
}
=item add
$branches->add( $branch ) ;
$branches->add( $branch1, $branch2, ... ) ;
Adds a branch or branches to the collection, unless they are already present.
=cut
sub add {
my VCP::Branches $self = CORE::shift ;
for my $b ( @_ ) {
my $key = $b->branch_id;
next
if $self->{SEEN}->{$key} ;
debug( "vcp: queuing ", $b->as_string )
if debugging $self || debugging scalar caller;
$self->{SEEN}->{$key} = 1 ;
push @{$self->{BRANCHES}}, $b ;
}
}
=item get
@branches = $branches->get ;
Gets the list of branches in alphabetical order.
=cut
sub get {
my VCP::Branches $self = CORE::shift ;
# the @b is to work around a bug that seems to happen in perl5.6.1:
# sort() called in a scalar context doesn't return TRUE, not sure
# why.
my @b = sort { $a->branch_id cmp $b->branch_id } @{$self->{BRANCHES}} ;
return @b;
}
=head1 SUBCLASSING
This class uses the fields pragma, so you'll need to use base and
possibly fields in any subclasses.
=head1 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
L<vcp>.
=head1 AUTHOR
Barrie Slaymaker <barries@slaysys.com>
=cut
1
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #6 | 4008 | Barrie Slaymaker | - Remove abandoned code | ||
| #5 | 3155 | Barrie Slaymaker |
Convert to logging using VCP::Logger to reduce stdout/err spew. Simplify & speed up debugging quite a bit. Provide more verbose information in logs. Print to STDERR progress reports to keep users from wondering what's going on. Breaks test; halfway through upgrading run3() to an inline function for speed and for VCP specific features. |
||
| #4 | 2150 | Barrie Slaymaker | work around sort() in scalar context bug in perl5.6.1 | ||
| #3 | 2149 | Barrie Slaymaker | Return branches in sorted (sordid?) order | ||
| #2 | 2009 | Barrie Slaymaker |
lots of fixes, improve core support for branches and VCP::Source::cvs now supports branches. |
||
| #1 | 1998 | Barrie Slaymaker | Initial, revml and core VCP support for branches |