20 |
# cvsroot directory |
# cvsroot directory |
21 |
my $CVSROOT="$HOME/x/cvsroot"; |
my $CVSROOT="$HOME/x/cvsroot"; |
22 |
# name of cvs repository to commit to |
# name of cvs repository to commit to |
23 |
my $CVSREP="webpac"; |
my $CVSREP="svn2cvs"; |
24 |
|
|
25 |
# svnroot directory |
# svnroot directory |
26 |
my $SVNROOT="file://$HOME/private/svn/webpac/"; |
my $SVNROOT="file://$HOME/private/svn/svn2cvs"; |
27 |
# name of respository |
# name of respository |
28 |
my $SVNREP="trunk"; |
my $SVNREP="trunk"; |
29 |
|
|
30 |
|
# webpac example |
31 |
|
#$CVSROOT="$HOME/x/cvsroot"; |
32 |
|
#$CVSREP="webpac"; |
33 |
|
#$SVNROOT="file://$HOME/private/svn/webpac/"; |
34 |
|
#$SVNREP="trunk"; |
35 |
|
|
36 |
my $TMPDIR=tempdir( "/tmp/checkoutXXXXX", CLEANUP => 1 ); |
my $TMPDIR=tempdir( "/tmp/checkoutXXXXX", CLEANUP => 1 ); |
37 |
|
|
38 |
chdir($TMPDIR) || die "can't cd to $TMPDIR: $!"; |
chdir($TMPDIR) || die "can't cd to $TMPDIR: $!"; |
40 |
# cvs command with root |
# cvs command with root |
41 |
my $cvs="cvs -d $CVSROOT"; |
my $cvs="cvs -d $CVSROOT"; |
42 |
|
|
43 |
|
|
44 |
# |
# |
45 |
# sub to do logging and system calls |
# sub to do logging and system calls |
46 |
# |
# |
50 |
system $cmd || die "$errmsg: $!"; |
system $cmd || die "$errmsg: $!"; |
51 |
} |
} |
52 |
|
|
53 |
|
# |
54 |
|
# sub to commit .svn rev file later |
55 |
|
# |
56 |
|
sub commit_svnrev { |
57 |
|
my $rev = shift @_; |
58 |
|
my $add_new = shift @_; |
59 |
|
|
60 |
# ok, now do the checkout |
die "commit_svnrev needs revision" if (! defined($rev)); |
61 |
|
|
62 |
log_system("$cvs checkout $CVSREP","cvs checkout failed"); |
open(SVNREV,"> $CVSREP/.svnrev") || die "can't open $TMPDIR/$CVSREP/.svnrev: $!"; |
63 |
|
print SVNREV $rev; |
64 |
|
close(SVNREV); |
65 |
|
|
66 |
# check if svnrev exists |
my $path=".svnrev"; |
67 |
|
|
68 |
if (! -e "$CVSREP/.svnrev") { |
if ($add_new) { |
69 |
print <<_USAGE_; |
system "$cvs add $CVSREP/$path" || die "cvs add of $path failed: $!"; |
70 |
|
} |
71 |
|
|
72 |
Your CVS repository doesn't have $TMPDIR/$CVSREP/.svnrev file! |
my $msg="subversion revision $rev commited to CVS"; |
73 |
|
print "$msg\n"; |
74 |
|
system "$cvs commit -m \"$msg\" $CVSREP/$path" || die "cvs commit of $path failed: $!"; |
75 |
|
} |
76 |
|
|
|
This file is used to commit changes to CVS repository with correct |
|
|
logs from Subversion. |
|
77 |
|
|
78 |
Please create .svnrec file with currect svn revision which |
# ok, now do the checkout |
|
corresponds to version of checkouted tree and commit that file |
|
|
to CVS repository, e.g. |
|
|
|
|
|
echo 233 > .svnrev |
|
|
cvs add .svnrev |
|
|
cvs commit -m "subversion repository revision sync file" .svnrev |
|
79 |
|
|
80 |
_USAGE_ |
log_system("$cvs -q checkout $CVSREP","cvs checkout failed"); |
|
print "CVS Repository left in $TMPDIR/$CVSREP\n"; |
|
|
exit 1; |
|
|
} |
|
81 |
|
|
82 |
|
my $rev; |
83 |
|
|
84 |
open(SVNREV,"$CVSREP/.svnrev") || die "can't open $TMPDIR/$CVSREP/.svnrev: $!"; |
# check if svnrev exists |
85 |
my $rev = <SVNREV>; |
if (! -e "$CVSREP/.svnrev") { |
86 |
chomp($rev); |
print <<_USAGE_; |
|
close(SVNREV); |
|
87 |
|
|
88 |
print "Starting after revision $rev\n"; |
Your CVS repository doesn't have .svnrev file! |
|
$rev++; |
|
89 |
|
|
90 |
|
This file is used to keep CVS repository and SubVersion in sync, so |
91 |
|
that only newer changes will be commited. |
92 |
|
|
93 |
# |
It's quote possible that this is first svn2cvs run for this repository. |
94 |
# sub to commit .svn rev file later |
If so, you will have to identify correct svn revision which |
95 |
# |
corresponds to current version of CVS repository that has just |
96 |
|
been checkouted. |
97 |
|
|
98 |
|
If you migrated your cvs repository to svn using cvs2svn, this will be |
99 |
|
last SubVersion revision. If this is initial run of conversion of |
100 |
|
SubVersion repository to CVS, correct revision is 0. |
101 |
|
|
102 |
sub commit_svnrev($) { |
_USAGE_ |
|
my $rev = shift @_ || die "commit_svnrev needs revision"; |
|
103 |
|
|
104 |
open(SVNREV,"> $CVSREP/.svnrev") || die "can't open $TMPDIR/$CVSREP/.svnrev: $!"; |
print "svn revision corresponding to CVS [abort]: "; |
105 |
print SVNREV $rev; |
my $in = <STDIN>; |
106 |
|
chomp($in); |
107 |
|
if ($in !~ /^\d+$/) { |
108 |
|
print "Aborting: revision not a number\n"; |
109 |
|
exit 1; |
110 |
|
} else { |
111 |
|
$rev = $in; |
112 |
|
commit_svnrev($rev,1); # create new |
113 |
|
} |
114 |
|
} else { |
115 |
|
open(SVNREV,"$CVSREP/.svnrev") || die "can't open $TMPDIR/$CVSREP/.svnrev: $!"; |
116 |
|
my $rev = <SVNREV>; |
117 |
|
chomp($rev); |
118 |
close(SVNREV); |
close(SVNREV); |
|
|
|
|
my $msg="subversion revision $rev commited to CVS"; |
|
|
my $path=".svnrev"; |
|
|
print "$msg\n"; |
|
|
system "$cvs commit -m \"$msg\" $CVSREP/$path" || die "cvs commit of $path failed: $!"; |
|
119 |
} |
} |
120 |
|
|
121 |
|
print "Starting after revision $rev\n"; |
122 |
|
$rev++; |
123 |
|
|
124 |
|
|
125 |
# |
# |
126 |
# FIXME!! HEAD should really be next verison and loop because this way we |
# FIXME!! HEAD should really be next verison and loop because this way we |
127 |
# loose multiple edits of same file and corresponding messages. On the |
# loose multiple edits of same file and corresponding messages. On the |