Allow passing of an alternative CVSROOT via -d.
This is necessary if using CVS in an asymmetric fashion, i.e. when the CVSROOT you are checking out from differs from the CVSROOT you have to commit to. Signed-off-by: Simon 'corecode' Schubert <corecode@fs.ei.tum.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Simon 'corecode' Schubert committed
Feb 18, 2007 at 18:17 UTC
4a6b9bb60ab3cdb3a749ec43763845a7a60d40d4
2 files changed
+23
-11
Documentation/git-cvsexportcommit.txt
+6
-1
@@ -8,7 +8,7 @@ git-cvsexportcommit - Export a single commit to a CVS checkout
8
9
SYNOPSIS
10
--------
11
-'git-cvsexportcommit' [-h] [-v] [-c] [-P] [-p] [-a] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID
11
+'git-cvsexportcommit' [-h] [-v] [-c] [-P] [-p] [-a] [-d cvsroot] [-f] [-m msgprefix] [PARENTCOMMIT] COMMITID
12
13
14
DESCRIPTION
@@ -43,6 +43,11 @@ OPTIONS
43
Add authorship information. Adds Author line, and Committer (if
44
different from Author) to the message.
45
46
+-d::
47
+ Set an alternative CVSROOT to use. This corresponds to the CVS
48
+ -d parameter. Usually users will not want to set this, except
49
+ if using CVS in an asymmetric fashion.
50
+
51
-f::
52
Force the merge even if the files are not up to date.
53
git-cvsexportcommit.perl
+17
-10
@@ -15,14 +15,21 @@ unless ($ENV{GIT_DIR} && -r $ENV{GIT_DIR}){
15
die "GIT_DIR is not defined or is unreadable";
16
}
17
18
-our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m );
18
+our ($opt_h, $opt_P, $opt_p, $opt_v, $opt_c, $opt_f, $opt_a, $opt_m, $opt_d);
19
20
-getopts('hPpvcfam:');
20
+getopts('hPpvcfam:d:');
21
22
$opt_h && usage();
23
24
die "Need at least one commit identifier!" unless @ARGV;
25
26
+my @cvs;
27
+if ($opt_d) {
28
+ @cvs = ('cvs', '-d', $opt_d);
29
+} else {
30
+ @cvs = ('cvs');
31
+}
32
+
33
# setup a tempdir
34
our ($tmpdir, $tmpdirname) = tempdir('git-cvsapplycommit-XXXXXX',
35
TMPDIR => 1,
@@ -160,7 +167,7 @@ foreach my $f (@afiles) {
167
my $p = $1;
168
next if (grep { $_ eq $p } @dirs);
169
}
163
- my @status = grep(m/^File/, safe_pipe_capture('cvs', '-q', 'status' ,$f));
170
+ my @status = grep(m/^File/, safe_pipe_capture(@cvs, '-q', 'status' ,$f));
171
if (@status > 1) { warn 'Strange! cvs status returned more than one line?'};
172
if (-d dirname $f and $status[0] !~ m/Status: Unknown$/
173
and $status[0] !~ m/^File: no file /) {
@@ -173,7 +180,7 @@ foreach my $f (@afiles) {
180
foreach my $f (@files) {
181
next if grep { $_ eq $f } @afiles;
182
# TODO:we need to handle removed in cvs
176
- my @status = grep(m/^File/, safe_pipe_capture('cvs', '-q', 'status' ,$f));
183
+ my @status = grep(m/^File/, safe_pipe_capture(@cvs, '-q', 'status' ,$f));
184
if (@status > 1) { warn 'Strange! cvs status returned more than one line?'};
185
unless ($status[0] =~ m/Status: Up-to-date$/) {
186
$dirty = 1;
@@ -194,7 +201,7 @@ print "Applying\n";
201
print "Patch applied successfully. Adding new files and directories to CVS\n";
202
my $dirtypatch = 0;
203
foreach my $d (@dirs) {
197
- if (system('cvs','add',$d)) {
204
+ if (system(@cvs,'add',$d)) {
205
$dirtypatch = 1;
206
warn "Failed to cvs add directory $d -- you may need to do it manually";
207
}
@@ -202,9 +209,9 @@ foreach my $d (@dirs) {
209
210
foreach my $f (@afiles) {
211
if (grep { $_ eq $f } @bfiles) {
205
- system('cvs', 'add','-kb',$f);
212
+ system(@cvs, 'add','-kb',$f);
213
} else {
207
- system('cvs', 'add', $f);
214
+ system(@cvs, 'add', $f);
215
}
216
if ($?) {
217
$dirtypatch = 1;
@@ -213,7 +220,7 @@ foreach my $f (@afiles) {
220
}
221
222
foreach my $f (@dfiles) {
216
- system('cvs', 'rm', '-f', $f);
223
+ system(@cvs, 'rm', '-f', $f);
224
if ($?) {
225
$dirtypatch = 1;
226
warn "Failed to cvs rm -f $f -- you may need to do it manually";
@@ -223,7 +230,7 @@ foreach my $f (@dfiles) {
230
print "Commit to CVS\n";
231
print "Patch title (first comment line): $title\n";
232
my @commitfiles = map { unless (m/\s/) { '\''.$_.'\''; } else { $_; }; } (@files);
226
-my $cmd = "cvs commit -F .msg @commitfiles";
233
+my $cmd = join(' ', @cvs)." commit -F .msg @commitfiles";
234
235
if ($dirtypatch) {
236
print "NOTE: One or more hunks failed to apply cleanly.\n";
@@ -236,7 +243,7 @@ if ($dirtypatch) {
243
244
if ($opt_c) {
245
print "Autocommit\n $cmd\n";
239
- print safe_pipe_capture('cvs', 'commit', '-F', '.msg', @files);
246
+ print safe_pipe_capture(@cvs, 'commit', '-F', '.msg', @files);
247
if ($?) {
248
die "Exiting: The commit did not succeed";
249
}