From: Mikael P. <er...@us...> - 2010-08-29 17:17:27
|
Update of /cvsroot/clearcase-java/net.sourceforge.clearcase/src/commandline/net/sourceforge/clearcase In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv29092/src/commandline/net/sourceforge/clearcase Modified Files: ClearCaseCLIImpl.java Log Message: Added co state reserved/unreserved cc output handling. Index: ClearCaseCLIImpl.java =================================================================== RCS file: /cvsroot/clearcase-java/net.sourceforge.clearcase/src/commandline/net/sourceforge/clearcase/ClearCaseCLIImpl.java,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** ClearCaseCLIImpl.java 27 Aug 2010 14:14:12 -0000 1.79 --- ClearCaseCLIImpl.java 29 Aug 2010 17:17:17 -0000 1.80 *************** *** 39,42 **** --- 39,44 ---- import net.sourceforge.clearcase.commandline.output.strategy.ElementIsHijacked; import net.sourceforge.clearcase.commandline.output.strategy.ElementIsLink; + import net.sourceforge.clearcase.commandline.output.strategy.ElementIsReservedCheckout; + import net.sourceforge.clearcase.commandline.output.strategy.ElementIsUnReservedCheckout; import net.sourceforge.clearcase.commandline.output.strategy.IdenticalPredecessor; import net.sourceforge.clearcase.commandline.output.strategy.MostRecentNotPredecessor; *************** *** 343,346 **** --- 345,350 ---- matchComposite.addStrategy(new ElementIsHijacked()); matchComposite.addStrategy(new ElementIsDerivedObject()); + matchComposite.addStrategy(new ElementIsUnReservedCheckout()); + matchComposite.addStrategy(new ElementIsReservedCheckout()); matchComposite.addStrategy(new SuccessfulCheckin()); matchComposite.addStrategy(new SuccessfulCheckout()); *************** *** 735,739 **** } return cleartool; ! } /* --- 739,743 ---- } return cleartool; ! } /* *************** *** 1318,1323 **** if (isGraphical) { int graphicalTimeout = TIMEOUT_GRAPHICAL_TOOLS; ! // FIXME: mike 20100624 Check with fb ! try { graphicalTimeout = Integer.parseInt(System --- 1322,1327 ---- if (isGraphical) { int graphicalTimeout = TIMEOUT_GRAPHICAL_TOOLS; ! // FIXME: mike 20100624 Check with fb ! try { graphicalTimeout = Integer.parseInt(System *************** *** 1585,1591 **** * .String, java.lang.String, java.lang.String) */ ! public void setViewConfigSpec(String viewName, ! String configSpecFile, String workingDriectory, OperationListener listener) ! { if (null == viewName) { ClearCase.error(ClearCase.ERROR_NULL_ARGUMENT, --- 1589,1594 ---- * .String, java.lang.String, java.lang.String) */ ! public void setViewConfigSpec(String viewName, String configSpecFile, ! String workingDriectory, OperationListener listener) { if (null == viewName) { ClearCase.error(ClearCase.ERROR_NULL_ARGUMENT, *************** *** 1600,1613 **** .addOption("-force").addOption("-tag").addElement(viewName) .addElement(configSpecFile); ! ! if(workingDriectory != null) ! { setData(WORKING_DIR, new File(workingDriectory)); ! ((CleartoolCLICommandLine)cleartool).setNeedsWorkingDirectory(true); } ! // execute command launch(cleartool, listener); ! } --- 1603,1616 ---- .addOption("-force").addOption("-tag").addElement(viewName) .addElement(configSpecFile); ! ! if (workingDriectory != null) { setData(WORKING_DIR, new File(workingDriectory)); ! ((CleartoolCLICommandLine) cleartool) ! .setNeedsWorkingDirectory(true); } ! // execute command launch(cleartool, listener); ! } *************** *** 1753,1759 **** showVersionTree(element, null); } ! ! /* (non-Javadoc) ! * @see net.sourceforge.clearcase.ClearCaseInterface#showVersionTree(java.lang.String, java.io.File) */ @Override --- 1756,1766 ---- showVersionTree(element, null); } ! ! /* ! * (non-Javadoc) ! * ! * @see ! * net.sourceforge.clearcase.ClearCaseInterface#showVersionTree(java.lang ! * .String, java.io.File) */ @Override *************** *** 1765,1772 **** final CommandLine cleartool = new CleartoolCLICommandLine("lsvtree") .addOption("-graphical").addElement(element); ! ! if(workingDir != null) ! { ! ((CleartoolCLICommandLine) cleartool).setNeedsWorkingDirectory(true); setData(WORKING_DIR, workingDir); } --- 1772,1779 ---- final CommandLine cleartool = new CleartoolCLICommandLine("lsvtree") .addOption("-graphical").addElement(element); ! ! if (workingDir != null) { ! ((CleartoolCLICommandLine) cleartool) ! .setNeedsWorkingDirectory(true); setData(WORKING_DIR, workingDir); } *************** *** 1882,1906 **** CommandLine cleartool; ! ! if(element.contains("@@")) ! { cleartool = new CleartoolCLICommandLine("lshistory").addOption( ! "-long").addOption("-directory").addElement(element); ! } ! else ! { File f = new File(element); if (!f.exists()) { ClearCase.error(ClearCase.ERROR_NULL_ARGUMENT, ! "element must be an existing file or directory"); //$NON-NLS-1$ } if (f.isDirectory()) { cleartool = new CleartoolCLICommandLine("lshistory").addOption( ! "-long").addOption("-directory").addElement(element + "@@"); } else { cleartool = new CleartoolCLICommandLine("lshistory").addOption( ! "-long").addElement(element + "@@"); } } --- 1889,1911 ---- CommandLine cleartool; ! ! if (element.contains("@@")) { cleartool = new CleartoolCLICommandLine("lshistory").addOption( ! "-long").addOption("-directory").addElement(element); ! } else { File f = new File(element); if (!f.exists()) { ClearCase.error(ClearCase.ERROR_NULL_ARGUMENT, ! "element must be an existing file or directory"); //$NON-NLS-1$ } if (f.isDirectory()) { cleartool = new CleartoolCLICommandLine("lshistory").addOption( ! "-long").addOption("-directory").addElement( ! element + "@@"); } else { cleartool = new CleartoolCLICommandLine("lshistory").addOption( ! "-long").addElement(element + "@@"); } } *************** *** 1959,1975 **** } - - /** * Search Files that has been modified into a branch. * ! * @param branchName Name of the branch ! * @param workingDir Clearcase working directory * @return Files into the branch */ ! public String[] searchFilesInBranch(String branchName, File workingDir, OperationListener listener) ! { String[] output = null; ! if (null == branchName) { ClearCase.error(ClearCase.ERROR_NULL_ARGUMENT, --- 1964,1980 ---- } /** * Search Files that has been modified into a branch. * ! * @param branchName ! * Name of the branch ! * @param workingDir ! * Clearcase working directory * @return Files into the branch */ ! public String[] searchFilesInBranch(String branchName, File workingDir, ! OperationListener listener) { String[] output = null; ! if (null == branchName) { ClearCase.error(ClearCase.ERROR_NULL_ARGUMENT, *************** *** 1980,2031 **** "workingDir must not be null"); //$NON-NLS-1$ } ! final CommandLine cleartool = new CleartoolCLICommandLine("find") ! .addOption("-all").addOption("-print").addOption("-branch").addElement("\'brtype("+branchName+")\'"); ! ((CleartoolCLICommandLine) cleartool).setNeedsWorkingDirectory(true); setData(WORKING_DIR, workingDir); output = launch(cleartool, listener); ! return output; } - /** * Get list of branches available into a specific clearcase path. * ! * @param workingDir the current working directory * @return List of branches. */ ! public String[] loadBrancheList(File workingDir) ! { String[] output = null; ! ArrayList<String> result = new ArrayList<String> (); ! if (null == workingDir) { ClearCase.error(ClearCase.ERROR_NULL_ARGUMENT, "workingDir must not be null"); //$NON-NLS-1$ } ! final CommandLine cleartool = new CleartoolCLICommandLine("lstype") .addOption("-kind").addElement("brtype"); ! ((CleartoolCLICommandLine) cleartool).setNeedsWorkingDirectory(true); setData(WORKING_DIR, workingDir); output = launch(cleartool, null); ! ! Pattern branchPatern = Pattern.compile("^[-:A-Z0-6]+[^\"]+[\"](.*)[\"][^\"]*$"); Matcher m; for (String line : output) { ! if((m = branchPatern.matcher(line)).matches()) ! { ! if((m.group(1) == null) || m.group(1).equals("")) ! { System.err.println("error " + line); ! } ! else ! { result.add(m.group(1)); } --- 1985,2033 ---- "workingDir must not be null"); //$NON-NLS-1$ } ! final CommandLine cleartool = new CleartoolCLICommandLine("find") ! .addOption("-all").addOption("-print").addOption("-branch") ! .addElement("\'brtype(" + branchName + ")\'"); ! ((CleartoolCLICommandLine) cleartool).setNeedsWorkingDirectory(true); setData(WORKING_DIR, workingDir); output = launch(cleartool, listener); ! return output; } /** * Get list of branches available into a specific clearcase path. * ! * @param workingDir ! * the current working directory * @return List of branches. */ ! public String[] loadBrancheList(File workingDir) { String[] output = null; ! ArrayList<String> result = new ArrayList<String>(); ! if (null == workingDir) { ClearCase.error(ClearCase.ERROR_NULL_ARGUMENT, "workingDir must not be null"); //$NON-NLS-1$ } ! final CommandLine cleartool = new CleartoolCLICommandLine("lstype") .addOption("-kind").addElement("brtype"); ! ((CleartoolCLICommandLine) cleartool).setNeedsWorkingDirectory(true); setData(WORKING_DIR, workingDir); output = launch(cleartool, null); ! ! Pattern branchPatern = Pattern ! .compile("^[-:A-Z0-6]+[^\"]+[\"](.*)[\"][^\"]*$"); Matcher m; for (String line : output) { ! if ((m = branchPatern.matcher(line)).matches()) { ! if ((m.group(1) == null) || m.group(1).equals("")) { System.err.println("error " + line); ! } else { result.add(m.group(1)); } *************** *** 2033,2045 **** } output = new String[result.size()]; ! return result.toArray(output); } ! ! //TODO: mike 20100827 impl. missing. ! /** * ! * Implements a method in ClearCaseInterface. */ public String checkedOutType(String element) { if (null == element) { --- 2035,2048 ---- } output = new String[result.size()]; ! return result.toArray(output); } ! ! /* ! * (non-Javadoc) * ! * see net.sourceforge.clearcase.ClearCaseInterface#checkedOutType(String) */ + @Override public String checkedOutType(String element) { if (null == element) { *************** *** 2048,2053 **** } ! final CommandLine cleartool = new CleartoolCLICommandLine("describe") ! .addOption("-s").addOption("-pre").addElement(element); final String[] output = launch(cleartool, null); // check for result --- 2051,2057 ---- } ! final CommandLine cleartool = new CleartoolCLICommandLine("desc") ! .addOption("-fmt").addOption("\"\\\"\\tStatus: %Rf\\n\"") ! .addElement(element); final String[] output = launch(cleartool, null); // check for result *************** *** 2057,2062 **** return output[0]; } ! /* * (non-Javadoc) --- 2061,2067 ---- return output[0]; + } ! /* * (non-Javadoc) *************** *** 2073,2075 **** --- 2078,2142 ---- } + /* + * (non-Javadoc) + * @see net.sourceforge.clearcase.ClearCaseInterface#reserved(java.lang.String[], java.lang.String, int, net.sourceforge.clearcase.events.OperationListener) + */ + @Override + public ClearCaseElementState[] reserved(final String[] elements, + final String comment, final int flags, + final OperationListener operationListener) { + + if (0 == elements.length) { + ClearCase.error(ClearCase.ERROR_NULL_ARGUMENT, + "element must not be null"); //$NON-NLS-1$ + } + + final List<String> optionsList = new ArrayList<String>(); + + if (null == comment || "".equals(comment.trim())) { + optionsList.add("-nc"); //$NON-NLS-1$ + } else { + optionsList.add("-c"); + optionsList.add(Utils.escapeComment(comment)); + } + + + final String[] options = Utils.toArray(optionsList); + + return ccOperation("reserved", options, elements, null, operationListener); + + } + + /* + * (non-Javadoc) + * @see net.sourceforge.clearcase.ClearCaseInterface#unreserved(java.lang.String[], java.lang.String, int, net.sourceforge.clearcase.events.OperationListener) + */ + @Override + public ClearCaseElementState[] unreserved(final String[] elements, + final String comment, final int flags, + final OperationListener operationListener) { + + if (0 == elements.length) { + ClearCase.error(ClearCase.ERROR_NULL_ARGUMENT, + "element must not be null"); //$NON-NLS-1$ + } + + + + final List<String> optionsList = new ArrayList<String>(); + + if (null == comment || "".equals(comment.trim())) { + optionsList.add("-nc"); //$NON-NLS-1$ + } else { + optionsList.add("-c"); + optionsList.add(Utils.escapeComment(comment)); + } + + + final String[] options = Utils.toArray(optionsList); + + return ccOperation("unreserved", options, elements, null, operationListener); + + } + } |