#!/usr/local/bin/perl -w =head1 NAME vcp - Copy versions of files between repositories and/or RevML =head1 SYNOPSIS vcp [vcp_opts] src[:files] [src_opts] [dest:[<location>]] [dest_opts] vcp cvs:/mymodule/... -r1.1: p4://depot/mymodule vcp p4://depot/mainbranch/...@100-105 revml: vcp help vcp revml: --dtd <foo.dtd> --save_dtd =head1 STATUS Alpha code. Please report bugs to revml@perforce.com. =head1 DESCRIPTION vcp ('version copy') copies versions and version ranges of files from one repository to another, translating as much as possible along the way. This allows you to copy and translate ranges of revisions of files between different vendors' revision storage systems. Inputs and output classes currently available are: Class Source Destination cvs x x p4 x x revml x x The general syntax of the vcp command line is: vcp [vcp_opts] <source> [src_opts] <dest> [dest_opts] where C<E<lt>sourceE<gt>> and C<E<lt>destE<gt>> look like scheme:user(view):password@server:filespec where scheme is a repository type ('p4', 'cvs', 'revml'), or special command ('help', 'save_dtd'). user, view, and password are settings required for repository access. CVS does not use (view). For p4, (view) is the client setting (P4CLIENT or -c option). server is the repository spec, CVSROOT for CVS or P4PORT for p4. filespec is the file specification for the files to move. As much as possible, this spec is similar to the native filespecs used by the repository indicated by the scheme. Filespecs are often omitted from the destination, in which case the colon is also optional. =head2 OPTIONS All general options to vcp must precede the command. Command-specific options must come after the command. Command specific options are documented in the appropriate VCP::Source::... or VCP::Dest::... man pages for now. At some point, the help command will be extended to be able to display them. =over =item --debug [spec], -d [spec] Enables display of debugging information. Default is to enable all debugging if no spec is provided. A debug spec is part or all of a module name like C<source::revml> or a shell-like regular expression to be compared to a module name. All are compared case insensitively. Any debug specs you provide that did not happen to cause any messages to be emitted by the time vcp exits. vcp will also list all of the internal names that might have matched but didn't to give you a clue as to what specs might be useful. The special name 'what' is guaranteed to not match anything, so you can do vcp -d what ... to see the list of names that might be useful for the arguments '...' . This list may change from run to run based on what modules asked to see if they should emit debugging information. You may use multiple C<-d> options or provide a comma separated list to enable debugging within that module. Debugging messages are emitted to stderr. =item --help, -h, -? These are all equivalent to C<p4 help>. =back =head1 ARGUMENTS Commands are either built in to vcp or are the names of repository sources. These are brief descrioptions, see the rest of this page for more details on the more complicated ones. =over =item help Displays the full help text. =item save_dtd [<how>] Outputs the DTD to stdout if <version> is C<->, or to a file named like v1_000.pm if <how> looks like a version number, or in a module named after <how> if <how> contains '::'. This file is placed in ./lib/RevML/DTD or ./RevML/DTD or ./, whichever is found first. No directories will be created. =back =head1 ENVIRONMENT The environment is often used to set context for the source and destination by way of variables like P4USER, P4CLIENT, CVSROOT, etc. There is also one environment variable that is used to enable command line debugging. The VCPDEBUG variable acts just like a leading "-d=$VCPDEBUG" was present on the command line. VCPDEBUG=main,p4 (see L</--debug, -d> for more info). =cut use strict ; use Getopt::Long ; use File::Basename ; use File::Spec ; use VCP ; use VCP::Debug qw( :debug ) ; use XML::Doctype ; { my $pname = basename( $0 ) ; my $dtd_spec ; my $arg = 'help' ; usage_and_exit() unless @ARGV ; enable_debug( split /,/, $ENV{VCPDEBUG} ) if defined $ENV{VCPDEBUG} ; ## Parse up to the first non-option, then let sources & dests parse ## from there. Getopt::Long::Configure( qw( no_auto_abbrev no_bundling no_permute ) ) ; GetOptions( 'debug|d=s' => sub { enable_debug( length $_[1] ? split /,/, $_[1] : () ) }, 'help|h|?' => \&help_and_exit, ) or options_and_exit() ; usage_and_exit() unless @ARGV ; $arg = shift ; help_and_exit() if $arg eq 'help' ; my @errors ; ## We pass \@ARGV to the constructors for source and dest so that ## they may parse some of @ARGV and leave the rest. Actually, that's ## only important for sources, since the dests should consume it all ## anyway. But, for consistency's sake, I do the same to both. my $source ; if ( defined $arg ) { my ( $scheme, $spec ) = $arg =~ /^(.*?)(?::(.*))?$/ ; if ( defined $spec && ! length $spec && @ARGV && ( $ARGV[0] eq '-' || substr( $ARGV[0], 0, 1 ) ne '-' ) && index( $ARGV[0], ':' ) < 0 ) { $spec = shift ; } $spec = defined $spec ? "$scheme:$spec" : $scheme ; eval { $source = load_module( "VCP::Source::$scheme", $spec, \@ARGV ); die "unknown source scheme '$scheme', try ", list_modules( "VCP::Source" ), "\n" unless defined $source ; } ; push @errors, $@ if $@ ; } my $dest ; if ( defined $source ? $source->dest_expected : @ARGV ) { my $scheme ; my $spec = '' ; if ( @ARGV ) { ( $scheme, $spec ) = shift =~ /^(.*?)(?::(.*))?$/ ; if ( defined $spec && ! length $spec && @ARGV && ( $ARGV[0] eq '-' || substr( $ARGV[0], 0, 1 ) ne '-' ) && index( $ARGV[0], ':' ) < 0 ) { $spec = shift ; } } else { $scheme = 'revml' ; } $spec = defined $spec ? "$scheme:$spec" : $scheme ; eval { $dest = load_module("VCP::Dest::$scheme", $spec, \@ARGV ); die "unknown destination scheme '$scheme', try ", list_modules( "VCP::Dest" ), "\n" unless defined $dest ; } ; push @errors, $@ if $@ ; @ARGV = () ; } elsif ( @ARGV ) { push @errors, "extra parameters: " . join( ' ', @ARGV ) . "\n" ; } if ( debugging ) { debug 'vcp: no dest expected' unless ! $source || $source->dest_expected ; debug 'vcp: $source is ', $source ; debug 'vcp: $dest is ', $dest ; } unless ( @errors ) { my $cp = VCP->new( $source, $dest ) ; my $header = {} ; my $footer = {} ; $cp->copy_all( $header, $footer ) ; } if ( @errors ) { my $errors = join( '', @errors ) ; $errors =~ s/^/$pname: /mg ; die $errors ; } } ############################################################################### ############################################################################### sub load_module { my ( $name, @args ) = @_ ; my $filename = $name ; $filename =~ s{::}{/}g ; my $x ; { local $@ ; my $v = eval "require '$filename.pm'; 1" ; return undef if $@ && $@ =~ /^Can't locate / ; $x = $@ ; } die $x if $x ; debug "vcp: loaded '$name' from '", $INC{"$filename.pm"}, "'" if debugging 'main', $name ; return $name->new( @args ) ;#if $v == 1 ; } sub list_modules { my ( $prefix ) = @_ ; my $dirname = $prefix . '::' ; $dirname =~ s{(::)+}{/}g ; my %seen ; for ( @INC ) { my $dir = File::Spec->catdir( $_, $dirname ) ; opendir( D, $dir ) or next ; my @files = grep $_ !~ /^\.\.?$/ && s/\.pm$//, readdir D ; closedir D ; $seen{$_} = 1 for @files ; } my $list = join( ', ', sort keys %seen ) ; $list =~ s/,([^,]*)$/ or$1/ ; return $list ; } sub usage_and_exit { require Pod::Usage ; Pod::Usage::pod2usage( -message => shift, -verbose => 0, -exitval => 1 ) ; } sub options_and_exit { require Pod::Usage ; Pod::Usage::pod2usage( -verbose => 1, -exitval => 1 ) ; } sub help_and_exit { require Pod::Usage ; Pod::Usage::pod2usage( -verbose => 2, -exitval => 0 ) ; } =head1 AUTHOR Barrie Slaymaker <barries@slaysys.com> =head1 COPYRIGHT Copyright 2000, Perforce Software, Inc. All Rights Reserved This will be licensed under a suitable license at a future date. Until then, you may use this for evaluation purposes. Besides which, it's alpha code, so you shouldn't depend on it anyway. =cut
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#80 | 4969 | barrie_slaymaker |
- Added a special command line macro "default_filters:" added to allow easy tests of, for instance, cvs to p4. |
||
#79 | 4967 | barrie_slaymaker |
- Removed "-d", leaving only "--debug" so that "-d" is properly passed through to plugins (esp. VCP::Source::cvs). |
||
#78 | 4581 | barrie_slaymaker | - user prompts have been improved, but not tested | ||
#77 | 4498 | barrie_slaymaker | Work around odd bug on RH8, perl5.8.3 | ||
#76 | 4493 | barrie_slaymaker | - Attempted to work around perl5.8.4 Bizarre copy of ARRAY bug | ||
#75 | 4482 | barrie_slaymaker | - spurious banner quieted | ||
#74 | 4404 | barrie_slaymaker | - Added -q option (mostly to suppress banner & progress bars for test suite) | ||
#73 | 4236 | barrie_slaymaker | - banner not emitted when writing revml to STDOUT | ||
#72 | 4232 | barrie_slaymaker | - bin/vcp now prints a version info banner | ||
#71 | 4154 | barrie_slaymaker | - dist/vcp.exe passes almost all tests | ||
#70 | 4150 | barrie_slaymaker | - bin/vcp can now be tested away from its lib/ dir | ||
#69 | 4148 | barrie_slaymaker | - scan_modules() returns a list, dummy | ||
#68 | 4143 | barrie_slaymaker | - Further adaptation to vcp.exe packaging format | ||
#67 | 4141 | barrie_slaymaker | - Adapt online help and html generation to vcp.exe environment | ||
#66 | 4065 | barrie_slaymaker |
- bin/vcp no longer whinges about undefined values when running the interactive UI. |
||
#65 | 3855 | barrie_slaymaker |
- vcp scan, filter, transfer basically functional - Need more work in re: storage format, etc, but functional |
||
#64 | 3779 | barrie_slaymaker |
- bin/vcp has nascent support for 3 stage transfers: - scan the source - filter the metadata (modify or prune) - transfer the filtered results - PRELIMINARY |
||
#63 | 3725 | barrie_slaymaker | - Minor spelling correction | ||
#62 | 3697 | barrie_slaymaker | - Write out new source if editing .vcp file changed source | ||
#61 | 3676 | barrie_slaymaker |
- The user interface should no longer append a second Dest: section. |
||
#60 | 3672 | barrie_slaymaker | - vcp emits more meaningful errors when fed a 0 length .vcp file | ||
#59 | 3666 | barrie_slaymaker | - vcp can now edit existing .vcp files, for VSS sources and revml dests | ||
#58 | 3663 | barrie_slaymaker |
- Yes/no questions may be answered 'y' or 'n' (case insensitive) - Multiple choice questions may be answered by typing in full text of an answer (case insensitive) |
||
#57 | 3649 | barrie_slaymaker | - Stray DB::single = 1s removed | ||
#56 | 3644 | barrie_slaymaker | - Add Save & Run options to end of UI | ||
#55 | 3640 | barrie_slaymaker |
- xmllint no longer require to build UI - UI now offers multiple choices where appropriate |
||
#54 | 3636 | barrie_slaymaker | - --terse option description improved | ||
#53 | 3567 | john_fetkovich |
- added the field UIManager in VCP::UI::Text.pm - added the fields UIImplementation and TersePrompts in UI.pm - removed Source and Dest fields in VCP::UI.pm - UI.pm now returns the result of running the UI implementation. - VCP::UI::Text->run return a list of (source, dest) all future UI implementations must do the same. - bin/vcp gets (source, dest) list from VCP::UI->run. - added --terse (or -t) command line option to vcp to remove verbose help from interactive UI. |
||
#52 | 3548 | john_fetkovich | Load default filters when vcp interactive ui is run. | ||
#51 | 3495 | john_fetkovich | improved help message at start of interactive vcp | ||
#50 | 3488 | john_fetkovich | move init of each plugin after writing config file | ||
#49 | 3487 | barrie_slaymaker | - Add --dont-convert option to bin/vcp | ||
#48 | 3486 | john_fetkovich | moved (source or dest)->init calls to bin/vcp | ||
#47 | 3481 | john_fetkovich |
intro text moved out of state machine to bin/vcp. no longer requires user interaction to move on. |
||
#46 | 3479 | john_fetkovich | doc fix | ||
#45 | 3468 | barrie_slaymaker |
- get --output-config-file working with ui (if ui completes, which may not happen if the user enters invalid input). - Note various UI issue in TODO. |
||
#44 | 3466 | barrie_slaymaker |
- --output-config-file now usable with vcp:- specification - --output-config-file now tested - VCP::{Source,Dest}::null now sets a repo_scheme so they may be emitted to config files. - Dest: is now emitted right after Source: when there are filters to dump. |
||
#43 | 3464 | barrie_slaymaker |
- Create VCP::ConfigFileUtils and move bin/vcp::parse_config_file in to it. - Add VCP::ConfigFileUtils::write_config_file() - Add --output-vcp-file to bin/vcp. - Add VCP::Driver::repo_spec_as_string() - Add VCP::Driver::config_file_section_as_string() - VCP::Driver::parse_repo_spec() now clears any settings that are not set by a given spec string (so old values don't remain after a call to it). |
||
#42 | 3441 | barrie_slaymaker | - Add some debugging code | ||
#41 | 3406 | barrie_slaymaker | - bin/vcp tries harder to keep backslashes for Win32 compat | ||
#40 | 3364 | john_fetkovich | clean up code flow in options parsing/interactive-ui calling section | ||
#39 | 3363 | john_fetkovich | cleanup code flow, remove some debugging statements | ||
#38 | 3362 | john_fetkovich | revml source and dest now works through interactive UI | ||
#37 | 3271 | john_fetkovich |
Added stub init() in VCP/Plugin.pm, and call to it in load_module in bin/vcp. This is in preparation for Sources and Dests to have parts of their current constructors split out into init() functions which will facilitate setting of fields from the interative ui code. |
||
#36 | 3244 | barrie_slaymaker |
Integrate VCP::UI with bin/vcp. Type 'vcp' to run the UI. |
||
#35 | 3167 | barrie_slaymaker |
Add profiling report that details various chunks of time taken. |
||
#34 | 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. |
||
#33 | 3018 | barrie_slaymaker |
fix command line parsing: options were not being cleansed from @ARGV properly. |
||
#32 | 2844 | john_fetkovich | Made VCP help aware of PAGER environment variable. | ||
#31 | 2711 | barrie_slaymaker | remove debugging statement, fix spurios error message | ||
#30 | 2708 | barrie_slaymaker | Add support for Options: in .vcp files, improve testing of CLI | ||
#29 | 2705 | barrie_slaymaker | Clean up comments | ||
#28 | 2688 | barrie_slaymaker |
Add back $ENV{VCPDEBUG} and augment with turning on debugging for IPC::Run3. |
||
#27 | 2639 | john_fetkovich |
Added profiling to be made active when VCPPROFILE environment variable turned on. writes profile info to filename defined in VCPPROFILE. Put some profiling statements (activated at compile time) in vcp and p4.pm. |
||
#26 | 2453 | john_fetkovich | removed compilation of revml. will be making that a separate executable. | ||
#25 | 2354 | barrie_slaymaker | favor .pod files over .pm files in the vcp help system. | ||
#24 | 2307 | barrie_slaymaker | get VCP::Filter::map working, update docs | ||
#23 | 2306 | barrie_slaymaker | tweak error text | ||
#22 | 2304 | barrie_slaymaker | VCP::Filter::map docs and infrastructure | ||
#21 | 2302 | barrie_slaymaker | test, debug filter chain CLI parsing | ||
#20 | 2301 | barrie_slaymaker | A chain of plugins instead of source & dest | ||
#19 | 2297 | barrie_slaymaker | Adapt cvs, revml to a more realistic branching structure | ||
#18 | 2293 | barrie_slaymaker | Update CHANGES, TODO, improve .vcp files, add --init-cvs | ||
#17 | 2282 | barrie_slaymaker | Add in support for *.vcp files | ||
#16 | 2014 | barrie_slaymaker |
Give helpful error messages if the vcp command can't read/write RevML due to a missing required module. |
||
#15 | 2013 | barrie_slaymaker | Reenable vcp as a unixy command line filter processing revml | ||
#14 | 1759 | barrie_slaymaker | Don't try to keep parsing cmd line after unknown scheme | ||
#13 | 1506 | barrie_slaymaker | tweaks | ||
#12 | 1367 | barrie_slaymaker | lots of docco updates | ||
#11 | 1359 | barrie_slaymaker | Revamp the help system, clean up and add POD | ||
#10 | 703 | barrie_slaymaker | VCP::Source::p4 now uses VCP::Utils::p4::parse_p4_repo_spec() | ||
#9 | 692 | barrie_slaymaker |
Add VCP::Utils::p4 and use it to get VCP::Dest::p4 to create it's own client view as needed. |
||
#8 | 688 | barrie_slaymaker | Fixed docos for --debug. | ||
#7 | 628 | barrie_slaymaker | Cleaned up POD in bin/vcp, added BSD-style license. | ||
#6 | 627 | barrie_slaymaker | Beef up CVS log file parsing. | ||
#5 | 624 | barrie_slaymaker | Add a space to bin/vcp SYNOPSIS after the cvs -r option. | ||
#4 | 613 | barrie_slaymaker | Tweak README and documentation. | ||
#3 | 480 | barrie_slaymaker |
0.06 Wed Dec 20 23:19:15 EST 2000 - bin/vcp: Added --versions, which loads all modules and checks them for a $VERSION and print the results out. This should help with diagnosing out-of-sync modules. - Added $VERSION vars to a few modules :-). Forgot to increment any $VERSION strings. - VCP::Dest::cvs: The directory "deeply" was not being `cvs add`ed on paths like "a/deeply/nested/file", assuming "deeply" had no files in it. - VCP::Dest::revml: fixed a bug that was causing files with a lot of linefeeds to be emitted in base64 instead of deltaed. This means most text files. - Various minor cleanups of diagnostics and error messages, including exposing "Can't locate Foo.pm" when a VCP::Source or VCP::Dest module depends on a module that's not installed, as reported by Jeff Anton. |
||
#2 | 468 | barrie_slaymaker |
- VCP::Dest::p4 now does change number aggregation based on the comment field changing or whenever a new revision of a file with unsubmitted changes shows up on the input stream. Since revisions of files are normally sorted in time order, this should work in a number of cases. I'm sure we'll need to generalize it, perhaps with a time thresholding function. - t/90cvs.t now tests cvs->p4 replication. - VCP::Dest::p4 now doesn't try to `p4 submit` when no changes are pending. - VCP::Rev now prevents the same label from being applied twice to a revision. This was occuring because the "r_1"-style label that gets added to a target revision by VCP::Dest::p4 could duplicate a label "r_1" that happened to already be on a revision. - Added t/00rev.t, the beginnings of a test suite for VCP::Rev. - Tweaked bin/gentrevml to comment revisions with their change number instead of using a unique comment for every revision for non-p4 t/test-*-in-0.revml files. This was necessary to test cvs->p4 functionality. |
||
#1 | 467 | barrie_slaymaker | Version 0.01, initial checkin in perforce public depot. |