⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 log.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: Log.java * * Copyright (c) 2003 Sun Microsystems and Static Free Software * * Electric(tm) is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Electric(tm) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Electric(tm); see the file COPYING.  If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, Mass 02111-1307, USA. */package com.sun.electric.tool.cvspm;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.Library;import com.sun.electric.database.variable.ElectricObject;import com.sun.electric.database.text.TextUtils;import com.sun.electric.tool.user.dialogs.CVSLog;import com.sun.electric.tool.user.User;import com.sun.electric.tool.Job;import com.sun.electric.tool.io.input.LibraryFiles;import com.sun.electric.tool.io.output.DELIB;import java.util.List;import java.util.ArrayList;import java.util.HashMap;import java.io.ByteArrayOutputStream;import java.io.ByteArrayInputStream;import java.io.LineNumberReader;import java.io.InputStreamReader;import java.io.File;import java.io.IOException;import java.io.Serializable;/** * User: gainsley * Date: Mar 23, 2006 */public class Log {    public static void showLog(Cell cell) {        if (!CVS.isDELIB(cell.getLibrary())) {            System.out.println("Cannot show log file for non-DELIB library");            return;        }        if (!CVS.isFileInCVS(CVS.getCellFile(cell))) {            System.out.println("Cell "+cell.describe(false)+" is not in CVS");            return;        }        List<Cell> cells = new ArrayList<Cell>();        cells.add(cell);        String useDir = CVS.getUseDir(null, cells);        StringBuffer cellsBuf = CVS.getCellFiles(cells, useDir);        ByteArrayOutputStream out = new ByteArrayOutputStream();        CVS.runCVSCommand("status "+cellsBuf, "Show CVS Status", useDir, out);        LineNumberReader reader = new LineNumberReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray())));        String workingVersion = getWorkingRevision(reader);        out = new ByteArrayOutputStream();        CVS.runCVSCommand("log "+cellsBuf, "Show CVS Log", useDir, out);        reader = new LineNumberReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray())));        System.out.println("Show CVS Log complete.");        Log log = new Log(cell);        log.parseLogOutput(reader);        CVSLog dialog = new CVSLog(log.entries, "CVS Log for "+cell.libDescribe(), workingVersion);        dialog.setVisible(true);    }    public static void showLog(Library lib) {        if (!CVS.isFileInCVS(TextUtils.getFile(lib.getLibFile()))) {            System.out.println("Library "+lib.getName()+" is not in CVS");            return;        }        List<Library> libs = new ArrayList<Library>();        libs.add(lib);        String useDir = CVS.getUseDir(libs, null);        StringBuffer libsBuf;        if (CVS.isDELIB(lib)) {            // show log for header file            libsBuf = new StringBuffer();            File libFile = TextUtils.getFile(lib.getLibFile());            if (libFile == null) return;            String file = libFile.getPath();            if (file.startsWith(useDir)) {                file = file.substring(useDir.length()+1, file.length());            }            libsBuf.append(file+File.separator+DELIB.getHeaderFile()+" ");        } else {            libsBuf = CVS.getLibraryFiles(libs, useDir);        }        ByteArrayOutputStream out = new ByteArrayOutputStream();        CVS.runCVSCommand("status "+libsBuf, "Show CVS Status", useDir, out);        LineNumberReader reader = new LineNumberReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray())));        String workingVersion = getWorkingRevision(reader);        out = new ByteArrayOutputStream();        CVS.runCVSCommand("log "+libsBuf, "Show CVS Log", useDir, out);        reader = new LineNumberReader(new InputStreamReader(new ByteArrayInputStream(out.toByteArray())));        System.out.println("Show CVS Log complete.");        Log log = new Log(lib);        log.parseLogOutput(reader);        CVSLog dialog = new CVSLog(log.entries, "CVS Log for "+lib.getName(), workingVersion);        dialog.setVisible(true);    }    /**     * Compare the specified version with the local copy     * @param entry     */    public static void compareWithLocal(LogEntry entry) {        StringBuffer args;        String useDir;        if (entry.obj instanceof Cell) {            List<Cell> cells = new ArrayList<Cell>();            cells.add((Cell)entry.obj);            useDir = CVS.getUseDir(null, cells);            args = CVS.getCellFiles(cells, useDir);        } else if (entry.obj instanceof Library) {            List<Library> libs = new ArrayList<Library>();            libs.add((Library)entry.obj);            useDir = CVS.getUseDir(libs, null);            args = CVS.getLibraryFiles(libs, useDir);        } else {            System.out.println("Cannot compare Electric Object "+entry.obj);            return;        }        String version = entry.version;        CVS.runCVSCommand("diff -r "+version+" "+args, "Compare with Local", useDir, System.out);        System.out.println("Compare with Local complete.");    }    public static void compare(LogEntry entry1, LogEntry entry2) {        StringBuffer args;        String useDir;        if (entry1.obj instanceof Cell) {            List<Cell> cells = new ArrayList<Cell>();            cells.add((Cell)entry1.obj);            useDir = CVS.getUseDir(null, cells);            args = CVS.getCellFiles(cells, useDir);        } else if (entry1.obj instanceof Library) {            List<Library> libs = new ArrayList<Library>();            libs.add((Library)entry1.obj);            useDir = CVS.getUseDir(libs, null);            args = CVS.getLibraryFiles(libs, useDir);        } else {            System.out.println("Cannot compare Electric Object "+entry1.obj);            return;        }        String version1 = entry1.version;        String version2 = entry2.version;        CVS.runCVSCommand("diff -r "+version1+" -r "+version2+" "+args, "Compare Versions", useDir, System.out);        System.out.println("Compare Versions complete.");    }    public static void getVersion(LogEntry entry) {        (new RevertToVersion(entry)).startJob();    }    public static class RevertToVersion extends Job {        private LogEntry entry;        public RevertToVersion(LogEntry entry) {            super("Revert to CVS Version", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);            this.entry = entry;        }        public boolean doIt() {            String version = entry.version;            StringBuffer args;            String useDir;            if (entry.obj instanceof Cell) {                List<Cell> cells = new ArrayList<Cell>();                cells.add((Cell)entry.obj);                useDir = CVS.getUseDir(null, cells);                args = CVS.getCellFiles(cells, useDir);            } else if (entry.obj instanceof Library) {                List<Library> libs = new ArrayList<Library>();                libs.add((Library)entry.obj);                useDir = CVS.getUseDir(libs, null);                args = CVS.getLibraryFiles(libs, useDir);            } else {                System.out.println("Cannot compare Electric Object "+entry.obj);                return false;            }            File aFile = new File(useDir, args.toString().trim());            File aFileBackup = new File(useDir, args.toString().trim()+"___version"+version);            String aFilePath = aFile.getPath();//            String aFileBackupPath = aFileBackup.getPath();            if (!aFile.exists()) {                System.out.println("Error: File does not exist: "+aFile.getPath());                return false;            }            CVS.runCVSCommand("update -r "+version+" "+args, "Get Version", useDir, System.out);            // copy old file away            if (aFileBackup.exists()) {                if (!aFileBackup.delete()) {                    System.out.println("Error: Could not delete backup file: "+aFileBackup.getPath());                    return false;                }            }            if (!aFile.renameTo(aFileBackup)) {                System.out.println("Error: Could not rename file "+aFile.getPath()+" to "+aFileBackup.getPath());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -