File: DefaultFilters.pm

package info (click to toggle)
libvcp-perl 0.9-20050110-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,608 kB
  • ctags: 827
  • sloc: perl: 18,194; makefile: 42; sh: 11
file content (111 lines) | stat: -rw-r--r-- 2,577 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package VCP::DefaultFilters;

=head1 NAME

VCP::DefaultFilters - Class for determining default filters
to install for a given source and dest.

=head1 SYNOPSIS

   require VCP::DefaultFilters;
   my $df = VCP::DefaultFilters->new;
   my @filter_args = $df->create_default_filters( $source, $dest );

=head1 DESCRIPTION

Given references to a vcp source and destination, determines the default
filters which would be appropriate, builds and returns a list of
arguments that should look like the portion of @ARGV (command line
arguments) that specify filters.

=cut


## There should be a default filter wizard sub of the form
## <source-scheme>2<dest-scheme>_default_filters for each source -> dest
## combination that requires default filters to be loaded.  If no default
## filters are required for a source -> dest combination, no wizard sub
## need be defined by that name.
## 
## The @args array definition in the following subs looks like .vcp config
## file format, but it's not parsed by that.  we're just using qw() to put
## the args into an array.

$VERSION = 0.1 ;

use strict;
use Carp;
use VCP::Debug qw( :debug );
use VCP::Logger qw( lg BUG );


sub new {
   my $class = shift;
   $class = ref $class || $class;

   my $self = {};
   return bless $self;
}


sub create_default_filters {
   my $self = shift;

   croak "usage create_default_filters <source>, <dest>"
      unless @_ == 2;
   my ($source, $dest) = ( $_[0]->repo_scheme, $_[1]->repo_scheme );
   my $wizard = "${source}2${dest}_default_filters";

   my @filters;
   eval {
      lg "calling $wizard to set default filters";
      @filters = $self->$wizard;
   };
   if( $@ =~ /Can't locate object method "$wizard" via/i ) {
      lg "no default filters defined for $source to $dest conversion";
   }
   else {
      BUG "create_default_filters: $@\n" if $@;
   }

   return @filters;
}

##-------------------------------------------------------------------------##
## default filter wizards below


sub cvs2p4_default_filters {
   my @args = qw( 
      Map:
         (...)<>      main/$1
         (...)<(*)>   $2/$1
   );
   return @args;
}


sub p42cvs_default_filters {
   ## ASSumes directories under //depot/foo/ are the main and branch
   ## dirs.
   my @args = qw( 
      Map:
        */(...)<(...)>  $1<$2>
   );
   return @args;
}


=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>.

=cut


1;