📄 log.java
字号:
return false; } // update with current version, remove sticky tag CVS.runCVSCommand("update -A "+args, "Remove Sticky Tag", useDir, System.out); // delete updated file, and move back old version file File oldCellFile = new File(aFilePath); if (!oldCellFile.delete()) { System.out.println("Error: Could not delete file: "+aFile.getPath()); return false; } if (!aFileBackup.renameTo(new File(aFilePath))) { System.out.println("Error: Could not rename file "+aFileBackup.getPath()+" to "+aFilePath); return false; } // reload cell //LibraryFiles.reloadLibraryCells(cells); if (entry.obj instanceof Cell) LibraryFiles.reloadLibrary(((Cell)entry.obj).getLibrary()); else if (entry.obj instanceof Library) LibraryFiles.reloadLibrary((Library)entry.obj); System.out.println("Get Version complete."); return true; } public void terminateOK() { if (entry.obj instanceof Cell) { Cell cell = (Cell)entry.obj; Library newLib = Library.findLibrary(cell.getLibrary().getName()); if (newLib == null) return; Cell newCell = newLib.findNodeProto(cell.noLibDescribe()); if (newCell == null) return; showLog(newCell); CVS.fixStaleCellReferences(cell.getLibrary()); } else if (entry.obj instanceof Library) { Library lib = (Library)entry.obj; Library newLib = Library.findLibrary(lib.getName()); if (newLib == null) return; showLog(newLib); CVS.fixStaleCellReferences(lib); } } } // ------------------------------------------------------- private HashMap<String,String> versionsToTags; private List<LogEntry> entries; private ElectricObject obj; private String headVersion; /** * Create a new log for either a Cell or Library * @param obj the library or cell */ private Log(ElectricObject obj) { this.obj = obj; versionsToTags = new HashMap<String,String>(); entries = new ArrayList<LogEntry>(); headVersion = ""; } private void parseLogOutput(LineNumberReader reader) { try { parseLog(reader); } catch (IOException e) { System.out.println(e.getMessage()); return; } } private void parseLog(LineNumberReader reader) throws IOException { // parse header, don't care about stuff until symbolic names (tags) for (;;) { String line = reader.readLine(); if (line == null) return; if (line.equals("")) continue; if (line.startsWith("head:")) { headVersion = line.substring(5).trim(); } if (line.startsWith("symbolic names:")) { parseSymbolicNames(reader); } if (line.startsWith("revision")) { LogEntry entry = parseLogEntry(line, reader); if (entry != null) entries.add(entry); } } } private void parseSymbolicNames(LineNumberReader reader) throws IOException { for (;;) { String line = reader.readLine(); if (line == null) return; if (line.equals("")) continue; if (line.startsWith("keyword substitution")) return; String parts[] = line.trim().split(":\\s+"); if (parts.length != 2) { System.out.println("Bad format for symbolic name: "+line); continue; } versionsToTags.put(parts[1], parts[0]); } } private LogEntry parseLogEntry(String line, LineNumberReader reader) throws IOException { // get revision String parts[] = line.trim().split("\\s+"); if (parts.length != 2) { System.out.println("Bad revision line format: "+line); return null; } String version = parts[1]; String tag = versionsToTags.get(version); if (tag == null) tag = ""; line = reader.readLine(); if (line == null) { System.out.println("Unexpected end of file"); return null; } parts = line.trim().split(";\\s+"); String branch = ""; String date = ""; String author = ""; String state = ""; StringBuffer commitMessage = new StringBuffer(); for (int i=0; i<parts.length; i++) { if (parts[i].startsWith("date: ")) { date = parts[i].substring(6); } else if (parts[i].startsWith("author: ")) { author = parts[i].substring(7).trim(); } else if (parts[i].startsWith("state: ")) { state = parts[i].substring(6).trim(); } } line = reader.readLine(); while (!line.startsWith("-----------------------") && !line.startsWith("==========================")) { if (line.startsWith("branches: ")) { branch = line.substring(9).trim(); line = reader.readLine(); continue; } // commit message...may span multiple lines commitMessage.append(line+"\n"); line = reader.readLine(); } return new LogEntry(obj, version, branch, date, author, commitMessage.toString(), state, tag, headVersion); } public static class LogEntry implements Serializable { public final ElectricObject obj; public final String version; public final String branch; public final String date; public final String author; public final String commitMessage; public final String state; public final String tag; public final String headVersion; // latest available version in cvs private LogEntry(ElectricObject obj, String version, String branch, String date, String author, String commitMessage, String state, String tag, String headVersion) { this.obj = obj; this.version = version; this.branch = branch; this.date = date; this.author = author; this.commitMessage = commitMessage; this.state = state; this.tag = tag; this.headVersion = headVersion; } public void print() { System.out.println(version + "\t" + branch + "\t" + date + "\t" + author + "\t" + commitMessage.replaceAll("\\n", " ") + state + "\t" + tag); } } // get the working revision from a cvs status output private static String getWorkingRevision(LineNumberReader reader) { try { for (;;) { String line = reader.readLine(); if (line == null) return ""; if (line.equals("")) continue; line = line.trim(); if (line.startsWith("Working revision:")) { String parts[] = line.trim().split("\t"); if (parts.length >= 2) { return parts[1].trim(); } } } } catch (IOException e) { System.out.println(e.getMessage()); } return ""; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -