1 22 package org.netbeans.lib.cvsclient.response; 23 24 import java.io.*; 25 import java.util.*; 26 import java.text.*; 27 28 import org.netbeans.lib.cvsclient.admin.*; 29 import org.netbeans.lib.cvsclient.event.*; 30 import org.netbeans.lib.cvsclient.file.*; 31 import org.netbeans.lib.cvsclient.util.*; 32 33 38 class RcsDiffResponse implements Response { 39 40 private static final boolean DEBUG = false; 41 42 45 private String localPath; 46 47 50 private String repositoryPath; 51 52 55 private String entryLine; 56 57 60 private String mode; 61 62 65 protected String localFile; 66 67 71 private DateFormat dateFormatter; 72 73 81 public void process(LoggedDataInputStream dis, ResponseServices services) 82 throws ResponseException { 83 try { 84 localPath = dis.readLine(); 85 repositoryPath = dis.readLine(); 86 entryLine = dis.readLine(); 87 mode = dis.readLine(); 88 89 String nextLine = dis.readLine(); 90 91 boolean useGzip = (nextLine.charAt(0) == 'z'); 92 93 int length = Integer.parseInt(useGzip ? nextLine.substring(1) 94 : nextLine); 95 96 if (DEBUG) { 97 System.err.println("Got update response."); System.err.println("LocalPath is : " + localPath); System.err.println("Repository path is : " + repositoryPath); System.err.println("Entries line is : " + entryLine); System.err.println("Mode is : " + mode); System.err.println("Next line (length) is : " + nextLine); System.err.println("File length is : " + length); } 105 106 final String filePath = services.convertPathname(localPath, 108 repositoryPath); 109 110 final File newFile = new File(filePath); 111 112 if (services.getGlobalOptions().isExcluded(newFile)) { 113 while (length > 0) { 114 length -= dis.skip(length); 115 } 116 return; 117 } 118 119 localFile = newFile.getAbsolutePath(); 120 final Entry entry = new Entry(entryLine); 121 122 FileHandler fileHandler = useGzip ? services.getGzipFileHandler() 123 : services.getUncompressedFileHandler(); 124 fileHandler.setNextFileDate(services.getNextFileDate()); 127 128 if (entry.isBinary()) { 130 } 133 else { 134 fileHandler.writeRcsDiffFile(filePath, mode, dis, length); 135 } 136 137 String conflictString = null; 143 if ((entry.getConflict() != null) && 144 (entry.getConflict().charAt(0) == Entry.HAD_CONFLICTS)) { 145 if (entry.getConflict().charAt(1) == 146 Entry.TIMESTAMP_MATCHES_FILE) { 147 final Date d = new Date(newFile.lastModified()); 148 conflictString = getEntryConflict(d, true); 149 } 150 else { 151 conflictString = entry.getConflict().substring(1); 152 } 153 } 154 else { 155 final Date d = new Date(newFile.lastModified()); 156 conflictString = getEntryConflict(d, false); 157 } 158 entry.setConflict(conflictString); 159 160 services.updateAdminData(localPath, repositoryPath, entry); 162 163 FileUpdatedEvent e = new FileUpdatedEvent(this, filePath); 164 services.getEventManager().fireCVSEvent(e); 165 } 167 catch (IOException e) { 168 throw new ResponseException(e); 169 } 170 } 171 172 180 protected String getEntryConflict(Date date, boolean hadConflicts) { 181 return getDateFormatter().format(date); 182 } 183 184 189 public boolean isTerminalResponse() { 190 return false; 191 } 192 193 198 protected DateFormat getDateFormatter() { 199 if (dateFormatter == null) { 200 dateFormatter = new SimpleDateFormat(Entry.getLastModifiedDateFormatter().toPattern(), Locale.US); 201 dateFormatter.setTimeZone(Entry.getTimeZone()); 202 } 203 return dateFormatter; 204 } 205 206 } 207 | Popular Tags |