[m-dev.] Help committing

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jun 18 14:17:23 AEST 1998


On 18-Jun-1998, Warwick Harvey <wharvey at cs.monash.edu.au> wrote:
> I appear to be having some trouble committing my changes.  I think it's 
> mostly due to the fact that I'm using the repository remotely,

Yes, that's correct.

> but I thought I should check the intended behaviour before assuming this.
>
> I'm getting two kinds of messages.  The first is along the lines of
> 
> File `Mmakefile' has incorrect group.
> Fixed.
> 
> There is no group "mercury" on this machine, so not much I can do about 
> changing the group here.  I assume that since it has said, "Fixed." that 
> there is no real problem with this and that the commit will proceed if I fix 
> the other problem.

That's also correct.

> The other kind of message I'm getting is
> 
> File `max_test.exp' appears to have no copyright message
> Commit anyway? [n]
> 
> Except that it's not waiting for me to answer the question, it's just taking 
> the default of "n" and proceeding, which kinda leaves me stranded.

There is unfortunately no easy way for the commit check script to query
you interactively if you're using remote cvs.

The ideal fix for this would be to ... ah, never mind, it's nearly as easy
for me to do it as describe it.  I'll commit the following change now.
Please test it.

--------------------

Allow overriding of the commit checks over remote cvs.

CVSROOT/commitinfo:
	Pass the user variable ${=commit_opts} to check.pl.
	This variable can be set by invoking cvs
	with the `-s commit_opts=...' option, 
	e.g. `cvs -s commit_opts=--force commit ...',

CVSROOT/check.pl:
	Add support for a `--force' option is equivalent
	to answering "yes" to the "Commit anyway?" question.
	If `--force' is not specified, and the open of /dev/tty
	fails, then print a message telling the user that they
	can use `cvs -s commit_opts=--force commit ...' to override
	the pre-commit checks.

cvs diff  CVSROOT/check.pl CVSROOT/commitinfo
Index: CVSROOT/check.pl
===================================================================
RCS file: /home/mercury1/repository/CVSROOT/check.pl,v
retrieving revision 1.6
diff -u -r1.6 check.pl
--- check.pl	1997/09/10 10:59:03	1.6
+++ check.pl	1998/06/18 04:10:43
@@ -27,6 +27,12 @@
 #-----------------------------------------------------------------------------#
 
 $retval = 0;
+$force = 0;
+
+if ($ARGV[0] eq "--force") {
+	$force = 1;
+	shift @ARGV;
+}
 
 # the first argument is the CVS directory
 $directory = $ARGV[0];
@@ -105,11 +111,23 @@
 			print "File `$arg' appears to have no "
 				. "copyright message\n";
 		}
-		print "Commit anyway? [n] ";
-		if (open TTY, "/dev/tty" and <TTY> =~ /^y/i) {
-			print "OK, if you insist!\n";
+		if ($force) {
+			print "Forcing commit anyway.\n";
 		} else {
-			$retval = 1;
+			if (open TTY, "/dev/tty") {
+				print "Commit anyway? [n] ";
+				if (<TTY> =~ /^y/i) {
+					print "OK, if you insist!\n";
+				} else {
+					$retval = 1;
+				}
+			} else {
+				print "\nCan't read from your terminal.\n";
+				print "You appear to be using remote cvs.\n";
+				print "Use `cvs -s commit_opts=--force " .
+					"commit ...' to override.\n";
+				$retval = 1;
+			}
 		}
 	}
 }
Index: CVSROOT/commitinfo
===================================================================
RCS file: /home/mercury1/repository/CVSROOT/commitinfo,v
retrieving revision 1.4
diff -u -r1.4 commitinfo
--- commitinfo	1997/05/09 00:16:51	1.4
+++ commitinfo	1998/06/18 04:05:45
@@ -17,6 +17,6 @@
 # If the name ALL appears as a regular expression it is always used
 # in addition to the first matching regex or DEFAULT.
 #
-#^cvs			checkforcvsid
-DEFAULT			/home/mercury1/repository/CVSROOT/check.pl
-			# check group id and group read permission
+#^cvs		checkforcvsid
+DEFAULT		/home/mercury1/repository/CVSROOT/check.pl ${=commit_opts}
+		# check group id and group read permission
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list