[m-dev.] for review: improve cvspatch

Tyson Dowd trd at cs.mu.OZ.AU
Wed Nov 17 18:19:17 AEDT 1999


Hi,

I personally don't like the 
	cvs diff: Diffing <directory name>
messages in my diffs, and don't use them a lot of the time.

So this modification lets cvspatch accept cvs created diffs that
don't have those lines. 

===================================================================


Estimated hours taken: 1

Improve cvspatch.

tools/cvspatch:
	Allow cvspatch to accept input without relying on 
		cvs diff: Diffing <directory name>
	This is output on stderr when you run cvs diff.
	Sometimes you don't capture stderr it when redirecting to a
	file.  Also the diff format is a little different when using cvs
	client/server anyway.

	Instead look for
		Index: <directory name>/<filename>
	and grab the directory name from there.

	Both methods work at once, whichever method one gets the first match 
	will be used to process the rest of the file.

	Also fix a bug where "=" was used instead of "==".


Index: tools/cvspatch
===================================================================
RCS file: /home/mercury1/repository/mercury/tools/cvspatch,v
retrieving revision 1.1
diff -u -r1.1 cvspatch
--- cvspatch	1999/11/11 00:27:10	1.1
+++ cvspatch	1999/11/17 07:11:46
@@ -11,14 +11,27 @@
 BEGIN	{
 		startline = 1;
 		dirname = ".";
+		useindex = 0;
+		usecvsdiff = 0;
 	}
-$1 = "cvs" && $2 == "diff:" && $3 == "Diffing" {
+useindex != 1 && $1 == "cvs" && $2 == "diff:" && $3 == "Diffing" {
 		if (startline != NR) {
 			printf "%s %d %d\n", dirname, startline, NR - 1;
 		}
+		usecvsdiff = 1;
+	}
+usecvsdiff != 1 && $1 == "Index:" {
+		i = match($2, ".*\/");
+		if (i > 0) {
+			newdirname = substr($2, i, RLENGTH);
 
-		dirname = $4;
-		startline = NR + 1;
+			if (newdirname != dirname) {
+				printf "%s %d %d\n", dirname, startline, NR - 1;
+				dirname = newdirname;
+				startline = NR + 1;
+			}
+		}
+		useindex = 1;
 	}
 END	{
 		NR++;


-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't eveyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list