- eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
- & eval 'exec perl -S $0 $argv:q'
- if 0;
- # THE PRECEEDING STUFF EXECS perl via $PATH
- # -*-Fundamental-*-
- # $Id: //guest/richard_geiger/utils/cvs2p4/bin/genmetadata#14 $
- #
- # Richard Geiger
- #
- require 5.000;
- use bytes;
- sub dirname
- {
- local($dir) = @_;
- $dir =~ s%^$%.%; $dir = "$dir/";
- if ($dir =~ m%^/[^/]*//*$%) { return "/"; }
- if ($dir =~ m%^.*[^/]//*[^/][^/]*//*$%)
- { $dir =~ s%^(.*[^/])//*[^/][^/]*//*$%$1%; { return $dir; } }
- return ".";
- }
- use Carp; # ...or flounder. (This will fail unless 'perl' is a perl5!)
- $| = 1;
- ($Myname = $0) =~ s%^.*/%%;
- $Mydir = &dirname($0);
- $Here = `/bin/pwd`; chop $Here;
- if ($Mydir ne ".") { chdir "$Mydir" || die "$Myname: can't chdir \"$Mydir\": $!"; }
- chdir ".." || die "$Myname: can't chdir \"..\": $!";
- $Mydir = `/bin/pwd`; chop $Mydir;
- chdir $Here || die "$Myname: can't chdir \"$Here\": $!";
- require "$Mydir/lib/util.pl";
- $Usage = <<LIT;
- $Myname: usage: $Myname
- LIT
- sub usage
- {
- print STDERR $Usage;
- exit 1;
- }
- sub help
- {
- print STDERR <<LIT;
- $Usage
- $Myname is not done yet. Be patient.
- LIT
- exit 1;
- }
- sub mklabel
- {
- my ($label, @Revs) = @_;
- if ( !WANTTAGS || !defined($WANTTAGS{$label}) ) { return; }
- print "make label: $label\n";
- $label = &atq($label);
- my $time = time;
- print DBLBLS "\@pv\@ 2 \@db.domain\@ $label 108 \@\@ \@\@ ".
- "\@cvs2p4\@ $time $time 8 0 \@Created by cvs2p4.\@\n";
- foreach my $rev (@Revs)
- {
- my ($f, $r) = ($rev =~ /^(.*)#(\d+)$/);
- $f = &p4_esc($f);
- $f = &atq($f);
- print DBLBLS "\@pv\@ 0 \@db.label\@ $label $f $r\n";
- }
- }
- # option switch variables get defaults here...
- $Convdir = "";
- $Boolopt = 0;
- $Valopt = 0;
- while ($#ARGV >= 0)
- {
- if ($ARGV[0] eq "-boolopt") { $Boolopt = 1; shift; next; }
- elsif ($ARGV[0] eq "-valopt")
- {
- shift; if ($ARGV[0] < 0) { &usage; }
- $Valopt = $ARGV[0]; shift; next;
- }
- elsif ($ARGV[0] eq "-help")
- { &help; }
- elsif ($ARGV[0] =~ /^-/) { &usage; }
- push(@Args, $ARGV[0]);
- shift;
- }
- if ($#Args ne 0) { &usage; }
- $Convdir = $Args[0];
- #chdir $Convdir || die "$Myname: can't chdir \"$Convdir\": $!";
- #$Convdir = `/bin/pwd`; chop $Convdir;
- #chdir $Here || die "$Myname: can't chdir \"$Here\": $!";
- require "$Convdir/config";
- $Metadata = "$Convdir/metadata";
- $Labels = "$Convdir/labels";
- $Rrevmap = "$Convdir/rrevmap";
- $DBlbls = "$P4ROOT/dblbls";
- $CheckpointGz = "checkpoint_after_dblbls.gz";
- # Path the the p4 client command
- #
- if (! defined($P4)) { $P4 = "/usr/local/bin/p4"; }
- if (! -x ($P4))
- { print "$Myname: No executable \"p4\" command at \"$P4\".\n"; exit 1; }
- $P4 = "$P4 -p $P4PORT -c cvs2p4 -u $P4USER";
- use DB_File;
- $DBMCLASS="DB_File";
- $myhashinfo = new DB_File::HASHINFO;
- $myhashinfo->{bsize} = 65536;
- if (! tie(%RREVMAP, $DBMCLASS, $Rrevmap, O_RDONLY, 0444, $myhashinfo))
- { print "$Myname: can't tie \"$Rrevmap\": $!\n"; exit 1; }
- if (! open(LABELS, "<$Labels"))
- { print "$Myname: can't open \">$Labels\": $!\n"; exit 1; }
- # Open the db metadata (journal format) file we will write
- #
- if (! open(DBLBLS, ">$DBlbls"))
- { print "$Myname: can't open \"$DBlbls\": $!\n"; exit 1; }
- ################################################################################
- #
- # branch_for_tag()
- #
- # Due to differences in the way Perforce and RCS/CVS work, Perforce
- # cannot know, by looking at the RCS archive alone, which branch(s) a
- # given label applies to. The default, in essence, is to make tags
- # for ALL branches to which it _could_ apply. This results in huge
- # numbers of often useless labels, and long "dolabels" phases.
- #
- # Often, however, the day can be saved, IF the user can provide a
- # mapping function that can take a label name and map it to a branch
- # name, along with a function that can take a Perforce revision
- # (pathname and revision number), and a branch name, and return an
- # indication of whether the revision given is in fact on the branch
- # given. (The latter function is usually trivially easy).
- #
- # If you want to use this feature, you will need to uncomment and
- # modify the following two functions to match your data.
- #
- # The first takes an RCS revision tag, and returns the name of the
- # branch that the revision is associated with:
- #
- #sub branch_for_tag
- #{
- # my ($tag) = @_;
- #
- # # These are a couple of example mappings, in this case based
- # # on the format of the tag names themselves (but your function
- # # is free to use any method you can devise):
- # #
- # # if ($tag =~ /^v(\d+)_(\d+)_([dab])_(\d)+$/) { return "main"; }
- # # if ($tag =~ /^(branch_.*)_\d\d\d$/) { return $1; }
- #
- # # ADD YOUR CODE HERE
- #
- # # Sorry, can't map this one I guess.
- # #
- # return "";
- #}
- # The second function you need to pay attention to is rev_on_branch().
- #
- # Usually, this will be just as shown here, where it involves
- # comparing a component of the revision's pathname (i.e., the
- # "branch-level directory" in Perforce, with the given $tag_branch.
- # The result of the comparison is the result of the function.
- #
- # If your conversion uses the default arrangement in the cvs2p4
- # config file, so that the third pathname component is the branch
- # name, e.g.,
- #
- # //depot/<module>/<branch>/...
- #
- # you won't need to change this at all:
- #
- #sub rev_on_branch
- #{
- # my ($rev, $tag_branch) = @_;
- # my ($branch) = ($rev =~ /^\/\/depot\/[^\/]+\/([^\/]+)\//);
- # return ($branch eq $tag_branch);
- #}
- #
- # End of branch_for_tag() stuff...
- #
- ################################################################################
- @Revs = ();
- while (<LABELS>)
- {
- if (/^([^\s]+)/)
- {
- if ($#Revs >= 0) { &mklabel($label, @Revs); }
- $label = $1;
- @Revs = ();
- }
- elsif (/^ (.*)/)
- {
- $tag = $1;
- if ($revs = $RREVMAP{$tag})
- {
- # GOAL: determine the branch this tag is for
- # (which is encoded in the tag name),
- # and only do the push for the revision
- # in $revs that is on the branch it belongs
- # to....
- #
- if (defined(&branch_for_tag))
- {
- $tag_branch = &branch_for_tag($label);
- if (! $tag_branch) { next; }
- }
- foreach $rev (split(/\001/, $revs))
- {
- if ((! defined(&branch_for_tag)) || &rev_on_branch($rev, $tag_branch))
- { push (@Revs, $rev); }
- }
- }
- }
- }
- if ($#Revs >= 0) { &mklabel($label, @Revs); }
- close DBLBLS;
- close LABELS;
- untie %RREVMAP;
- $DBlbls =~ s%^.*/%%;
- $P4D = "$P4D -r .";
- if (&s("cd $P4ROOT && $P4D -jr $DBlbls"))
- { print "$Myname: \"$P4D -jr $DBlbls\" failed.\n"; exit 1; }
- if (&s("cd $P4ROOT && rm -f $CheckpointGz; $P4D -jd -z $CheckpointGz"))
- { print "$Myname: \"$P4D -jd -z $CheckpointGz\" failed.\n"; exit 1; }
- exit 0;
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 5210 | Naveen Patil | MERGE - Merged from CVS2P4 2.5.5 * includes purely merged files that resol...ved automatically with [-am] « |
19 years ago | |
#5 | 5134 | Naveen Patil | Added ability to specify CVS symbolic tags that need to be imported as Perforce labels &n...bsp; * convdir/config can define WANTTAGS and list of CVS symbolic tags * bin/genmetadata generates list of CVS symbolic tags in convdir/labels.lst, which can be used to configure the WANTTAGS list in convdir/config * if WANTTAGS is defined, bin/dolabels only imports the CVS symbolic tags listed in convdir/config « |
19 years ago | |
#4 | 5131 | Naveen Patil | Fix from Rich Geiger to correctly handle labeling for filenames having the # character in ... them, which caused bin/dolabels to abort with the following error: Journal file 'dblbls' replay failed at line 7452184! Word too big for a number! « |
19 years ago | |
#3 | 5129 | Naveen Patil | Increase bsize of HASHINFO structure from 4096 to 65536 to fix "file size exceeded" error ... from bin/dochanges, as suggested by Marc Tooley (Perforce Support); not really sure what this does, but worked! « |
19 years ago | |
#2 | 5128 | Naveen Patil | Use "p4d -z" to gzip checkpoint(s) by do{changes,labels}, and save both for... possible recovery from them « |
19 years ago | |
#1 | 5127 | Naveen Patil | BRANCH - Branched //public/perforce/utils/cvs2p4/... | 19 years ago | |
//guest/perforce_software/utils/cvs2p4/bin/dolabels | |||||
#8 | 4354 | Richard Geiger | Integrate 2.4 changes. | 21 years ago | |
#7 | 3711 | Richard Geiger | release 2.3.7 | 21 years ago | |
#6 | 2063 | rmg | Publish 2.3.2 | 23 years ago | |
#5 | 1989 | Richard Geiger | Public 2.3.1 | 23 years ago | |
#4 | 1786 | rmg | Publish 2.0 | 23 years ago | |
#3 | 1410 | rmg | Publish 1.3.2 | 23 years ago | |
#2 | 1205 | Richard Geiger | Publish 1.3.1 | 23 years ago | |
#1 | 1187 | Richard Geiger |
1.3. Mainly, support for labels! |
23 years ago | |
//guest/richard_geiger/utils/cvs2p4/bin/dolabels | |||||
#1 | 1185 | Richard Geiger |
Changes for 1.3 (Labels!) |
23 years ago |