18 |
my $HOME = $ENV{'HOME'} || die "can't get home directory!"; |
my $HOME = $ENV{'HOME'} || die "can't get home directory!"; |
19 |
|
|
20 |
# cvsroot directory |
# cvsroot directory |
|
#my $CVSROOT="$HOME/x/cvsroot"; |
|
21 |
my $CVSROOT=':pserver:dpavlin@cvs.tigris.org:/cvs'; |
my $CVSROOT=':pserver:dpavlin@cvs.tigris.org:/cvs'; |
22 |
# name of cvs repository to commit to |
# name of cvs repository to commit to |
23 |
my $CVSREP="svn2cvs/src"; |
my $CVSREP="svn2cvs/src"; |
24 |
|
|
25 |
|
$CVSROOT="$HOME/x/cvsroot"; |
26 |
|
$CVSREP="svn2cvs/src"; |
27 |
|
|
28 |
# svnroot directory |
# svnroot directory |
29 |
my $SVNROOT="file://$HOME/private/svn/svn2cvs"; |
my $SVNROOT="file://$HOME/private/svn/svn2cvs"; |
30 |
# name of respository |
# name of respository |
43 |
# cvs command with root |
# cvs command with root |
44 |
my $cvs="cvs -d $CVSROOT"; |
my $cvs="cvs -d $CVSROOT"; |
45 |
|
|
|
|
|
46 |
# |
# |
47 |
# sub to do logging and system calls |
# sub to do logging and system calls |
48 |
# |
# |
61 |
|
|
62 |
die "commit_svnrev needs revision" if (! defined($rev)); |
die "commit_svnrev needs revision" if (! defined($rev)); |
63 |
|
|
64 |
open(SVNREV,"> $CVSREP/.svnrev") || die "can't open $TMPDIR/$CVSREP/.svnrev: $!"; |
open(SVNREV,"> .svnrev") || die "can't open $TMPDIR/$CVSREP/.svnrev: $!"; |
65 |
print SVNREV $rev; |
print SVNREV $rev; |
66 |
close(SVNREV); |
close(SVNREV); |
67 |
|
|
68 |
my $path=".svnrev"; |
my $path=".svnrev"; |
69 |
|
|
70 |
if ($add_new) { |
if ($add_new) { |
71 |
system "$cvs add $CVSREP/$path" || die "cvs add of $path failed: $!"; |
system "$cvs add $path" || die "cvs add of $path failed: $!"; |
72 |
} else { |
} else { |
73 |
my $msg="subversion revision $rev commited to CVS"; |
my $msg="subversion revision $rev commited to CVS"; |
74 |
print "$msg\n"; |
print "$msg\n"; |
75 |
system "$cvs commit -m \"$msg\" $CVSREP/$path" || die "cvs commit of $path failed: $!"; |
system "$cvs commit -m \"$msg\" $path" || die "cvs commit of $path failed: $!"; |
76 |
} |
} |
77 |
} |
} |
78 |
|
|
|
|
|
79 |
# ok, now do the checkout |
# ok, now do the checkout |
80 |
|
|
81 |
log_system("$cvs -q checkout $CVSREP","cvs checkout failed"); |
log_system("$cvs -q checkout $CVSREP","cvs checkout failed"); |
82 |
|
|
83 |
|
chdir($CVSREP) || die "can't cd to $TMPDIR/$CVSREP: $!"; |
84 |
|
|
85 |
|
|
86 |
my $rev; |
my $rev; |
87 |
|
|
88 |
# check if svnrev exists |
# check if svnrev exists |
89 |
if (! -e "$CVSREP/.svnrev") { |
if (! -e ".svnrev") { |
90 |
print <<_USAGE_; |
print <<_USAGE_; |
91 |
|
|
92 |
Your CVS repository doesn't have .svnrev file! |
Your CVS repository doesn't have .svnrev file! |
116 |
commit_svnrev($rev,1); # create new |
commit_svnrev($rev,1); # create new |
117 |
} |
} |
118 |
} else { |
} else { |
119 |
open(SVNREV,"$CVSREP/.svnrev") || die "can't open $TMPDIR/$CVSREP/.svnrev: $!"; |
open(SVNREV,".svnrev") || die "can't open $TMPDIR/$CVSREP/.svnrev: $!"; |
120 |
$rev = <SVNREV>; |
$rev = <SVNREV>; |
121 |
chomp($rev); |
chomp($rev); |
122 |
close(SVNREV); |
close(SVNREV); |
162 |
foreach my $e (@{$xml->{'logentry'}}) { |
foreach my $e (@{$xml->{'logentry'}}) { |
163 |
die "BUG: revision from .svnrev ($rev) greater than from subversion (".$e->{'revision'}.")" if ($rev > $e->{'revision'}); |
die "BUG: revision from .svnrev ($rev) greater than from subversion (".$e->{'revision'}.")" if ($rev > $e->{'revision'}); |
164 |
$rev = $e->{'revision'}; |
$rev = $e->{'revision'}; |
165 |
log_system("svn export --force -q -r $rev $SVNROOT/$SVNREP $CVSREP", "svn export of revision $rev failed"); |
log_system("svn export --force -q -r $rev $SVNROOT/$SVNREP $TMPDIR/$CVSREP", "svn export of revision $rev failed"); |
166 |
|
|
167 |
printf($fmt, $e->{'revision'}, $e->{'author'}, $e->{'date'}, $e->{'msg'}); |
printf($fmt, $e->{'revision'}, $e->{'author'}, $e->{'date'}, $e->{'msg'}); |
168 |
foreach my $p (@{$e->{'paths'}->{'path'}}) { |
foreach my $p (@{$e->{'paths'}->{'path'}}) { |
173 |
# prepare path and message |
# prepare path and message |
174 |
my $file = $path; |
my $file = $path; |
175 |
$path =~ s,^/$SVNREP/*,, || die "BUG: can't strip SVNREP from path"; |
$path =~ s,^/$SVNREP/*,, || die "BUG: can't strip SVNREP from path"; |
176 |
|
|
177 |
|
if (! $path) { |
178 |
|
print "NOTICE: skipped this operation. Probably trunk creation\n"; |
179 |
|
next; |
180 |
|
} |
181 |
|
|
182 |
my $msg = $e->{'msg'}; |
my $msg = $e->{'msg'}; |
183 |
$msg =~ s/"/\\"/g; # quote " |
$msg =~ s/"/\\"/g; # quote " |
184 |
|
|
185 |
if ($action =~ /M/) { |
if ($action =~ /M/) { |
186 |
print "svn2cvs: modify $path -- nop\n"; |
print "svn2cvs: modify $path -- nop\n"; |
187 |
} elsif ($action =~ /A/) { |
} elsif ($action =~ /A/) { |
188 |
log_system("$cvs add -m \"$msg\" $CVSREP/$path", "cvs add of $path failed"); |
log_system("$cvs add -m \"$msg\" $path", "cvs add of $path failed"); |
189 |
} elsif ($action =~ /D/) { |
} elsif ($action =~ /D/) { |
190 |
log_system("$cvs delete -m \"$msg\" $CVSREP/$path", "cvs delete of $path failed"); |
log_system("$cvs delete -m \"$msg\" $path", "cvs delete of $path failed"); |
191 |
} else { |
} else { |
192 |
print "WARNING: action $action not implemented on $path. Bug or missing feature of $0\n"; |
print "WARNING: action $action not implemented on $path. Bug or missing feature of $0\n"; |
193 |
} |
} |
194 |
|
|
195 |
# now commit changes |
# now commit changes |
196 |
log_system("$cvs commit -m \"$msg\" $CVSREP/$path", "cvs commit of $path failed"); |
log_system("$cvs commit -m \"$msg\" $path", "cvs commit of $path failed"); |
197 |
|
|
198 |
} |
} |
199 |
|
|