[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index] [Home]

[jcvs] CVSProject EOL bug and fix


looks like the list is back up.  here goes again. :)

If you use cvsc to check-out files, NewLineReader has a flaw that
assumes eol markers to be always present at the end of a file which it
thinks should be ascii.  So if you have either 1) binary files checked
in without -kb (bad i know), or 2) ascii files without a final eol at
eof (it happens), then cvsc would always add a final eol byte to the end
of the checked-out file when writing to the local project directory.
This means the file is now immediately different compared to the
repository
version.

The attached patch fixes this and incorporates changes submitted by
Matthias for making sure non-pertinent files are deleted.

Note that it's obviously not diffed against 1.1 - I checked in the cvsc
distro to our local repository without realizing I'd clobber the
versioning.

cheers, nick
Index: CVSProject.java
===================================================================
RCS file: /cvsroot/Source/Java/ThirdParty/com/ice/cvsc/CVSProject.java,v
retrieving revision 1.1
diff -u -r1.1 CVSProject.java
--- CVSProject.java	13 Jun 2001 11:58:19 -0000	1.1
+++ CVSProject.java	7 Nov 2001 17:10:41 -0000
@@ -775,6 +775,10 @@
 				if ( noteLine == null )
 					break;
 
+				// Now need this because NewLineReader.readLine
+				// returns an eol.
+				noteLine = noteLine.trim();
+
 				CVSNotifyItem notifyItem =
 					parseNotifyLine( noteLine );
 
@@ -2813,8 +2817,26 @@
 					( item.getRepositoryName() );
 
 			result = parentEntry.removeEntry( entryName );
+
+			// Taken from patch submitted by mtt.
+			// Fixes the problem in which the file is left
+			// undeleted.
+
+			if (item.getType() == CVSResponseItem.REMOVED)
+				{
+				String pathName = item.getPathName();
+				File file = new File(pathName + entryName);
+				if (!file.delete())
+					{
+					CVSTracer.traceWithStack
+					("CVSProject.removeEntriesItem: Could not delete file " +
+					pathName + entryName);
+				 	}
+				}
 			}
 
+			// End patch
+
 		return result;
 		}
 
@@ -4573,7 +4595,11 @@
 					if ( line == null ) break;
 
 					out.write( line );
-					out.newLine();
+					// Removed by nick - readLine now
+					// returns the EOL too.  Stops cvsc
+					// adding EOL to binaries checked in
+					// as ascii and files without eol at eof
+					// out.newLine();
 					}
 				catch ( IOException ex )
 					{
@@ -4751,6 +4777,10 @@
 					ch = (char) inByte;
 					if ( ch == 0x0A )
 						{
+						// Added by nick - we need to
+						// not wrongly assumed later
+						// the line always ends in eol
+						line.append( ch	);
 						break;
 						}