Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2005, 2007 IBM Corporation and others. |
2 |
* Copyright (c) 2005, 2008 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 11-17
Link Here
|
11 |
package org.eclipse.team.internal.ccvs.ui.operations; |
11 |
package org.eclipse.team.internal.ccvs.ui.operations; |
12 |
|
12 |
|
13 |
import java.io.*; |
13 |
import java.io.*; |
14 |
import java.util.*; |
14 |
import java.util.HashSet; |
|
|
15 |
import java.util.Iterator; |
15 |
|
16 |
|
16 |
import org.eclipse.compare.patch.WorkspacePatcherUI; |
17 |
import org.eclipse.compare.patch.WorkspacePatcherUI; |
17 |
import org.eclipse.core.resources.*; |
18 |
import org.eclipse.core.resources.*; |
Lines 254-260
Link Here
|
254 |
|
255 |
|
255 |
for (Iterator iter = newFiles.iterator(); iter.hasNext();) { |
256 |
for (Iterator iter = newFiles.iterator(); iter.hasNext();) { |
256 |
ICVSFile cvsFile = (ICVSFile) iter.next(); |
257 |
ICVSFile cvsFile = (ICVSFile) iter.next(); |
257 |
addFileToDiff(getNewFileRoot(cvsFile), cvsFile,stream,format); |
258 |
addFileToDiff(getNewFileRoot(cvsFile), cvsFile,stream,format); |
258 |
} |
259 |
} |
259 |
} |
260 |
} |
260 |
|
261 |
|
Lines 323-329
Link Here
|
323 |
//ignore |
324 |
//ignore |
324 |
} |
325 |
} |
325 |
} |
326 |
} |
326 |
|
327 |
|
327 |
// Ignore empty files |
328 |
// Ignore empty files |
328 |
if (lines == 0) |
329 |
if (lines == 0) |
329 |
return; |
330 |
return; |
Lines 368-380
Link Here
|
368 |
printStream.println("***************"); //$NON-NLS-1$ |
369 |
printStream.println("***************"); //$NON-NLS-1$ |
369 |
printStream.println("*** 0 ****"); //$NON-NLS-1$ |
370 |
printStream.println("*** 0 ****"); //$NON-NLS-1$ |
370 |
} |
371 |
} |
371 |
|
372 |
|
372 |
printStream.println(positionInfo); |
373 |
printStream.println(positionInfo); |
373 |
|
374 |
|
374 |
for (int i = 0; i < lines; i++) { |
375 |
for (int i = 0; i < lines - 1; i++) { |
375 |
printStream.print(linePrefix); |
376 |
printStream.print(linePrefix); |
376 |
printStream.println(fileReader.readLine()); |
377 |
printStream.println(fileReader.readLine()); |
377 |
} |
378 |
} |
|
|
379 |
|
380 |
printStream.print(linePrefix); |
381 |
readLastLine(fileReader, printStream); |
378 |
} catch (IOException e) { |
382 |
} catch (IOException e) { |
379 |
throw CVSException.wrapException(file.getIResource(), NLS.bind(CVSMessages.CVSTeamProvider_errorAddingFileToDiff, new String[] { pathString }), e); |
383 |
throw CVSException.wrapException(file.getIResource(), NLS.bind(CVSMessages.CVSTeamProvider_errorAddingFileToDiff, new String[] { pathString }), e); |
380 |
} finally { |
384 |
} finally { |
Lines 385-390
Link Here
|
385 |
} |
389 |
} |
386 |
} |
390 |
} |
387 |
|
391 |
|
|
|
392 |
// based on org.eclipse.compare.internal.core.patch.LineReader.readLine() |
393 |
private void readLastLine(BufferedReader reader, PrintStream printStream) |
394 |
throws IOException { |
395 |
boolean sawCRorLF = false; |
396 |
boolean sawEOF = false; |
397 |
boolean ignoreSingleCR = false; |
398 |
while (!sawEOF) { |
399 |
int c = reader.read(); |
400 |
if (c == -1) { |
401 |
sawEOF = true; |
402 |
break; |
403 |
} |
404 |
printStream.print((char) c); |
405 |
if (c == '\n') { |
406 |
sawCRorLF = true; |
407 |
break; |
408 |
} |
409 |
if (c == '\r') { |
410 |
sawCRorLF = true; |
411 |
c = reader.read(); |
412 |
if (c == -1) { |
413 |
sawEOF = true; |
414 |
break; // EOF |
415 |
} |
416 |
if (c != '\n') { |
417 |
if (ignoreSingleCR) { |
418 |
sawCRorLF = false; |
419 |
printStream.append((char) c); |
420 |
continue; |
421 |
} |
422 |
} else { // '\n' |
423 |
printStream.append((char) c); |
424 |
} |
425 |
break; |
426 |
} |
427 |
} |
428 |
if (!sawCRorLF) { |
429 |
printStream.println(); |
430 |
printStream.print("\\ No newline at end of file"); //$NON-NLS-1$ |
431 |
} |
432 |
} |
433 |
|
388 |
public void setStream(PrintStream stream) { |
434 |
public void setStream(PrintStream stream) { |
389 |
this.stream = new CustomizableEOLPrintStream(stream); |
435 |
this.stream = new CustomizableEOLPrintStream(stream); |
390 |
} |
436 |
} |