pax_global_header00006660000000000000000000000064120356374750014526gustar00rootroot0000000000000052 comment=8e876bdb828259f8b41004ac74d7f023c21662c2 svnclientadapter-1.8.16/000077500000000000000000000000001203563747500151715ustar00rootroot00000000000000svnclientadapter-1.8.16/.classpath000066400000000000000000000014631203563747500171600ustar00rootroot00000000000000 svnclientadapter-1.8.16/.project000066400000000000000000000005671203563747500166500ustar00rootroot00000000000000 svnClientAdapter org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature svnclientadapter-1.8.16/.settings/000077500000000000000000000000001203563747500171075ustar00rootroot00000000000000svnclientadapter-1.8.16/.settings/org.eclipse.jdt.core.prefs000066400000000000000000000011511203563747500240670ustar00rootroot00000000000000#Tue Apr 19 14:27:05 EDT 2011 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve org.eclipse.jdt.core.compiler.compliance=1.6 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.source=1.6 svnclientadapter-1.8.16/.settings/org.eclipse.jdt.ui.prefs000066400000000000000000000141201203563747500235540ustar00rootroot00000000000000#Mon Aug 27 10:19:17 EDT 2007 eclipse.preferences.version=1 instance/org.eclipse.core.net/org.eclipse.core.net.hasMigrated=true org.eclipse.jdt.ui.ignorelowercasenames=true org.eclipse.jdt.ui.importorder=java;javax;org;com; org.eclipse.jdt.ui.ondemandthreshold=99 org.eclipse.jdt.ui.staticondemandthreshold=99 org.eclipse.jdt.ui.text.custom_code_templates= svnclientadapter-1.8.16/.settings/org.eclipse.mylar.tasklist.prefs000066400000000000000000000002231203563747500253370ustar00rootroot00000000000000#Wed May 23 09:36:33 EDT 2007 eclipse.preferences.version=1 project.repository.kind=issuezilla project.repository.url=http\://subclipse.tigris.org svnclientadapter-1.8.16/build.properties000066400000000000000000000035261203563747500204140ustar00rootroot00000000000000# ----------------------------------------------------------------------------- # build.properties # This file is referenced by the build.xml file. # # $Id$ # ----------------------------------------------------------------------------- # compile with debug on or off debug=on targetJvm=1.5 # svnClientAdapter version svnClientAdapter.buildRev=r5494 svnClientAdapter.version=1.7.0 # ----------------------------------------------------------------------------- # locations for directories # ----------------------------------------------------------------------------- src.main.dir=src/main src.javahl.dir=src/javahl src.svnkit.dir=src/svnkit src.cmdline.dir=src/commandline src.samples.dir=src/samples src.tests.dir=src/testcases build.dir=build build.distrib.dir=${build.dir}/distrib build.classes.dir=${build.dir}/classes/main build.testClasses.dir=${build.dir}/classes/testcases build.lib.dir=${build.dir}/lib build.cache.dir=${build.dir}/depcache build.javadoc.dir=${build.dir}/javadoc test.lib.dir=test/lib # ----------------------------------------------------------------------------- # all jar needed # ----------------------------------------------------------------------------- lib.dir=lib svnjavahl.jar=${lib.dir}/svn-javahl.jar svnkit.jar=${lib.dir}/svnkit/svnkit-1.7.5-v1.jar svnkitjavahl.jar=${lib.dir}/svnkit/svnkit-javahl16-1.7.5-v1.jar # ----------------------------------------------------------------------------- # JavaHL win32 lib dir # ----------------------------------------------------------------------------- javahl_win32.lib.dir=${lib.dir}/javahl_win32 # ----------------------------------------------------------------------------- # Test properties # ----------------------------------------------------------------------------- emma.enabled=true emma.instrClasses.dir=${build.dir}/coverage/instrClasses coverage.dir=${build.dir}/coverage svnclientadapter-1.8.16/build.xml000066400000000000000000000236031203563747500170160ustar00rootroot00000000000000
svnclientadapter-1.8.16/changelog.txt000066400000000000000000000063361203563747500176710ustar00rootroot00000000000000- #1231: implemented the method 'CmdLineClientAdapter#copy(SVNUrl,SVNUrl,String,SVNRevision,boolean)' - added ISVNStatus#isWcLocked() and ISVNStatus#isSwitched() - removed the getRepositoryRoot() method from adapter interface - added logMessage(url, paths[], ...) - fixed the local->UTF-8 log message conversion problems - added ISVNStatus#getUrlString() - added ISVNClientAdapter#getStatus with ignoreExternals parameter * July 12, 2006 - relicense under EPL * 0.9.35 - removed dependency on jakarta-regexp - commandline now executed with locale explicitely set - SVNRevision.getRevision() now takes as argument also a date format * 0.9.34 - removed dependency on commons-lang - updated to JavaSVN 0.9.2 - updated to jakarta-regexp-1.4 - win32 javahl dlls updated to 1.2.3 - several untracked additions and changes to API done meanwhile * 0.9.23 - dlls updated using svn-win32-1.1.0.zip, libsvnjavahl-1.dll and svn-javahl.jar updated using svn-win32-1.1.0_javahl.zip - new junit tests adapted from http://svn.collab.net/viewcvs/svn/trunk/subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/tests/ - JhlClientAdapter.annotate now uses JhlAnnotations instead of CmdLineAnnotations - Bugs correction : > many bugs corrected concerning command line interface > absolute path used instead of canonical path (Fix for issues 142 and 147) > Fix for issue 151 : CmdLineLogMessage.createLogMessages, correction to avoid NPE in HistoryTableProvider > Cache available flag for client adapters. This gives an improvement of about 150ms for the CmdLineClientAdapter. > Fixed ordering of dependencies to stop libdb42.dll not found messages on windows > JhlNotificationHandler : Update messages were printing numbers instead of characters for content and property statuses. > JhlClientAdapter.getStatus now uses a new parameter for status : no-ignore because we want to retrieve all entries including ignored-ones when getAll is true - API Additions : ISVNClientAdapter.getInfo ISVNLogMessage.getChangePaths ISVNClientAdapter.switchToUrl * 0.9.13 - API Additions: ISVNClientAdapter.getStatus(File path, boolean descend, boolean getAll, boolean contactServer) ISVNStatus.getRepositoryTextStatus() ISVNStatus.getRepositoryPropStatus() ISVNNotifyListener.logRevision(long revision) ISVNClientAdapter.createRepository (Currently implemented for command line interface) ISVNClientAdapter.getList(File,SVNRevision,boolean) ISVNClientAdapter.getDirEntry(File, SVNRevision) * 0.9.4 - svnjavahl.dll, svnjavahl.jar updated to "Javahl bindings for Subversion 1.0.5 on Win32." - bug in date parser for command line corrected - password not shown anymore when logging - bug corrected : paths was not always correct during notifications - new method in ISVNClientAdapter to get the svn properties - should compile using JDK 1.3 now * 0.9.1 - svnjavahl.dll, svnjavahl.jar updated to "Javahl bindings for Subversion 1.0.0 on Win32." - getDirEntry added to ISVNClientAdapter.java - CmdLineClientAdapter.getStatus bug corrected (the topmost directory of a working copy was always considered as unversioned) - many modifications to CmdLineStatus * 0.8.6 - modifications to command line interface. Should work better now on Linux * 0.8.5 - * 0.1.0 - Initial Release svnclientadapter-1.8.16/license.txt000066400000000000000000000267151203563747500173670ustar00rootroot00000000000000SVNClientAdapter Library License This license applies to all portions of SVNClientAdapter library, which are not externally-maintained libraries (e.g. JavaHL or SVNKit). Such libraries have their own licenses; we recommend you read them, as their terms may differ from the terms below. ============================================================================= Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. svnclientadapter-1.8.16/readme.txt000066400000000000000000000017741203563747500172000ustar00rootroot00000000000000 SVNClientAdapter =============== SVNClientAdapter is a high-level Java API for Subversion. It can use one of 3 low-level svn client implementations to provide access to the Subversion API: - JavaHL (JNI) subversion library (http://svn.collab.net/repos/svn/trunk/subversion/bindings/java/javahl/) - SVNKit (pure Java) (http://svnkit.com/) - svn(.exe) command line client (some functionality unavailable/unreliable with <1.3 command line clients) SVNClientAdapter is easier to use than SVNClient class and has more features. How to use it : ============= You will need to add svnClientAdapter.jar in your classpath. If you wish to use JNI client (recommended), you will need svnjavahl.jar in your classpath. If you wish to use pure java implementation of subversion low-level api, you will need svnkit.jar and ganymed.jar in your classpath. If you wish to use command line client, you will need that client be present on your system path. See the src/samples folder to see how to use it. cchabanois at no-log.org svnclientadapter-1.8.16/src/000077500000000000000000000000001203563747500157605ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/000077500000000000000000000000001203563747500202465ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/000077500000000000000000000000001203563747500210355ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/000077500000000000000000000000001203563747500223365ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/000077500000000000000000000000001203563747500245355ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/000077500000000000000000000000001203563747500301035ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/000077500000000000000000000000001203563747500323715ustar00rootroot00000000000000CmdLineAnnotations.java000066400000000000000000000132771203563747500367200ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Date; import javax.xml.parsers.DocumentBuilderFactory; import org.tigris.subversion.svnclientadapter.Annotations; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.utils.StringUtils; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; /** * Handles annotations (see svn ann) * * @author Cédric Chabanois */ public class CmdLineAnnotations extends Annotations { private CmdLineAnnotations() { //Use factory methods } public static CmdLineAnnotations createFromXml(byte[] annotations, InputStream contents) throws CmdLineException { CmdLineAnnotations result = new CmdLineAnnotations(); try { // Create a builder factory DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); // Create the builder and parse the file InputSource source = new InputSource(new ByteArrayInputStream(annotations)); Document doc = factory.newDocumentBuilder().parse(source); // // // // // // // // // // // NodeList nodes = doc.getElementsByTagName("entry"); Annotation[] lines = new Annotation[nodes.getLength()]; for(int i = 0; i < nodes.getLength(); i++) { Node entry = nodes.item(i); SVNRevision.Number revision = SVNRevision.Number.INVALID_REVISION; String author = null; Date date = null; int lineNr = Integer.parseInt(entry.getAttributes().getNamedItem("line-number").getNodeValue()); Element commitNode = CmdLineXmlCommand.getFirstNamedElement(entry, "commit"); if (commitNode != null) { Node revisionAttribute = commitNode.getAttributes().getNamedItem("revision"); revision = Helper.toRevNum(revisionAttribute.getNodeValue()); Element authorNode = CmdLineXmlCommand.getFirstNamedElement(commitNode, "author"); author = authorNode.getFirstChild().getNodeValue(); Element dateNode = CmdLineXmlCommand.getNextNamedElement(authorNode, "date"); date = Helper.convertXMLDate(dateNode.getFirstChild().getNodeValue()); } lines[lineNr - 1] = (new Annotation(revision.getNumber(), author, date, null)); } BufferedReader bReader = new BufferedReader(new InputStreamReader(contents)); String line = bReader.readLine(); int i = 0; while (line != null) { lines[i].setLine(line); result.addAnnotation(lines[i]); line = bReader.readLine(); i++; } bReader.close(); } catch (Exception e) { throw new CmdLineException(e); } return result; } public static CmdLineAnnotations createFromStdOut(String annotations, String lineSeparator) { CmdLineAnnotations result = new CmdLineAnnotations(); String[] lines = StringUtils.split(annotations, lineSeparator); for (int i = 0; i < lines.length; i++) { Annotation ann = new Annotation(getRevisionFrom(lines[i]), getAuthorFrom(lines[i]), getChangedFrom(lines[i]), getLineFrom(lines[i])); result.addAnnotation(ann); } return result; } private static long getRevisionFrom(String line) { String version = line.substring(0,6).trim(); if (version.equals("-")) { // if we annotate from revision 2 to HEAD, the author and revision // will be "-" if some lines have revision 1 return -1; } else { return Integer.parseInt(version); } } private static Date getChangedFrom(String line) { //Client adapter does not support verbose output with dates return null; } private static String getAuthorFrom(String line) { String author = StringUtils.stripStart(line.substring(7,17),null); if (author.equals("-")) { // if we annotate from revision 2 to HEAD, the author and revision // will be "-" if some lines have revision 1 return null; } else { return author; } } private static String getLineFrom(String line) { return line.substring(18); } } CmdLineClientAdapter.java000066400000000000000000002150571203563747500371420ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Properties; import java.util.StringTokenizer; import java.util.Vector; import org.tigris.subversion.svnclientadapter.AbstractClientAdapter; import org.tigris.subversion.svnclientadapter.ISVNAnnotations; import org.tigris.subversion.svnclientadapter.ISVNConflictResolver; import org.tigris.subversion.svnclientadapter.ISVNDirEntry; import org.tigris.subversion.svnclientadapter.ISVNDirEntryWithLock; import org.tigris.subversion.svnclientadapter.ISVNInfo; import org.tigris.subversion.svnclientadapter.ISVNLogMessage; import org.tigris.subversion.svnclientadapter.ISVNLogMessageCallback; import org.tigris.subversion.svnclientadapter.ISVNMergeInfo; import org.tigris.subversion.svnclientadapter.ISVNNotifyListener; import org.tigris.subversion.svnclientadapter.ISVNProgressListener; import org.tigris.subversion.svnclientadapter.ISVNProperty; import org.tigris.subversion.svnclientadapter.ISVNStatus; import org.tigris.subversion.svnclientadapter.ISVNStatusCallback; import org.tigris.subversion.svnclientadapter.SVNBaseDir; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNDiffSummary; import org.tigris.subversion.svnclientadapter.SVNNotificationHandler; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNRevision.Number; import org.tigris.subversion.svnclientadapter.SVNRevisionRange; import org.tigris.subversion.svnclientadapter.SVNScheduleKind; import org.tigris.subversion.svnclientadapter.SVNStatusUnversioned; import org.tigris.subversion.svnclientadapter.SVNUrl; /** *

* Implements a ISVNClientAdapter using the * Command line client. This expects the svn * executible to be in the path.

* * @author Philip Schatz (schatz at tigris) * @author C~dric Chabanois (cchabanois at no-log.org) */ public class CmdLineClientAdapter extends AbstractClientAdapter { //Fields final protected CmdLineNotificationHandler notificationHandler; final protected SvnCommandLine _cmd; final protected SvnMultiArgCommandLine _cmdMulti; final protected SvnAdminCommandLine svnAdminCmd; protected String version = null; private static boolean availabilityCached = false; private static boolean available; private static String dirName; public CmdLineClientAdapter(CmdLineNotificationHandler notificationHandler) { this(notificationHandler, new SvnCommandLine("svn", notificationHandler), new SvnMultiArgCommandLine("svn", notificationHandler), new SvnAdminCommandLine("svnadmin", notificationHandler)); } protected CmdLineClientAdapter(CmdLineNotificationHandler notificationHandler, SvnCommandLine cmd, SvnMultiArgCommandLine multiCmd, SvnAdminCommandLine adminCmd) { super(); this.notificationHandler = notificationHandler; this._cmd = cmd; this._cmdMulti = multiCmd; this.svnAdminCmd = adminCmd; } public boolean isThreadsafe() { return false; } //Methods public static boolean isAvailable() { // availabilityCached flag must be reset if location of client changes if (!availabilityCached) { // this will need to be fixed when path to svn will be customizable SvnCommandLine cmd = new SvnCommandLine("svn", new CmdLineNotificationHandler()); try { String version = cmd.version(); int i = version.indexOf(System.getProperty("line.separator")); // NOI18N version = version.substring(0,i); available = true; available &= version.indexOf("version 0.") == -1; available &= version.indexOf("version 1.0") == -1; available &= version.indexOf("version 1.1") == -1; available &= version.indexOf("version 1.2") == -1; } catch (Exception e) { e.printStackTrace(); available = false; } availabilityCached = true; } return available; } /** * @return something like "svn, version 0.35.1 (r8050)" * @throws SVNClientException */ public String getVersion() throws SVNClientException { if (version != null) return version; try { // we don't want to log this ... notificationHandler.disableLog(); version = _cmd.version(); int i = version.indexOf(System.getProperty("line.separator")); // NOI18N version = version.substring(0,i); return version; } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } finally { notificationHandler.enableLog(); } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#addNotifyListener(org.tigris.subversion.subclipse.client.ISVNClientNotifyListener) */ public void addNotifyListener(ISVNNotifyListener listener) { notificationHandler.add(listener); } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#removeNotifyListener(org.tigris.subversion.subclipse.client.ISVNClientNotifyListener) */ public void removeNotifyListener(ISVNNotifyListener listener) { notificationHandler.remove(listener); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getNotificationHandler() */ public SVNNotificationHandler getNotificationHandler() { return notificationHandler; } private boolean isManaged(File file) { if (file.isDirectory()) { return isManagedDir(file.getParentFile()) || isManagedDir(file); } else { return isManagedDir(file.getParentFile()); } } private boolean isManagedDir(File dir) { // all directories that do not have a .svn dir are not versioned File entries = new File(dir, getAdminDirectoryName() + "/entries"); return entries.exists(); } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#getStatus(java.io.File[]) */ public ISVNStatus[] getStatus(File[] files) throws SVNClientException { ISVNStatus[] statuses = new ISVNStatus[files.length]; // all files (and dirs) that are in nonmanaged dirs are unversioned ArrayList pathsList = new ArrayList(); for (int i = 0; i < files.length;i++) { File file = files[i]; if (isManaged(file)) { pathsList.add(toString(file)); } else { statuses[i] = new SVNStatusUnversioned(file,false); } } String[] paths = (String[])pathsList.toArray(new String[pathsList.size()]); // we must do a svn status and svn info only on resources that are in versioned dirs // because otherwise svn will stop after the first "svn: 'resource' is not a working copy" CmdLineStatuses cmdLineStatuses; try { CmdLineStatusPart[] cmdLineStatusParts = getCmdStatuses(paths, false, true, false, false); List targetsInfo = new ArrayList(cmdLineStatusParts.length); for (int i = 0; i < cmdLineStatusParts.length;i++) { if (cmdLineStatusParts[i].isManaged()) { targetsInfo.add(cmdLineStatusParts[i].getFile().toString()); } } String cmdLineInfoStrings = _cmd.info((String[]) targetsInfo.toArray(new String[targetsInfo.size()] ), null, null); cmdLineStatuses = new CmdLineStatuses(cmdLineInfoStrings, cmdLineStatusParts); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } for (int i = 0; i < cmdLineStatuses.size();i++) { ISVNStatus status = cmdLineStatuses.get(i); for (int j=0; j < files.length;j++) { if (files[j].getAbsoluteFile().equals(status.getFile())) { statuses[j] = status; } } } for (int i = 0; i < statuses.length; i++) { if (statuses[i] == null) { statuses[i] = new SVNStatusUnversioned(files[i],false); } } return statuses; } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getSingleStatus(java.io.File) */ public ISVNStatus getSingleStatus(File path) throws SVNClientException { return getStatus(new File[] {path})[0]; } private ISVNDirEntry[] getList(String target, SVNRevision rev, boolean recursive) throws SVNClientException { byte[] listXml; try { listXml = _cmd.list(target, toString(rev), recursive); return CmdLineRemoteDirEntry.createDirEntries(listXml); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#getList(java.net.URL, org.tigris.subversion.subclipse.client.ISVNRevision, boolean) */ public ISVNDirEntry[] getList(SVNUrl svnUrl, SVNRevision revision, boolean recurse) throws SVNClientException { return getList(toString(svnUrl), revision, recurse); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getList(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public ISVNDirEntry[] getList(File path, SVNRevision revision, boolean recurse) throws SVNClientException { return getList(toString(path), revision, recurse); } public ISVNDirEntryWithLock[] getListWithLocks(SVNUrl url, SVNRevision revision, SVNRevision pegRevision, boolean recurse) throws SVNClientException { ISVNDirEntry[] entries = getList(url, revision, pegRevision, recurse); ISVNDirEntryWithLock[] entriesWithLocks = new ISVNDirEntryWithLock[entries.length]; for (int i = 0; i < entries.length; i++) { entriesWithLocks[i] = new CmdLineRemoteDirEntryWithLock(entries[i], null); } return entriesWithLocks; } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getDirEntry(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision) */ public ISVNDirEntry getDirEntry(SVNUrl url, SVNRevision revision) throws SVNClientException { // list give the DirEntrys of the elements of a directory or the DirEntry // of a file ISVNDirEntry[] entries = getList(url.getParent(),revision,false); String expectedPath = url.getLastPathSegment(); for (int i = 0; i < entries.length;i++) { if (entries[i].getPath().equals(expectedPath)) { return entries[i]; } } return null; // not found } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getDirEntry(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision) */ public ISVNDirEntry getDirEntry(File path, SVNRevision revision) throws SVNClientException { // list give the DirEntrys of the elements of a directory or the DirEntry // of a file ISVNDirEntry[] entries = getList(path.getParentFile(),revision,false); String expectedPath = path.getName(); for (int i = 0; i < entries.length;i++) { if (entries[i].getPath().equals(expectedPath)) { return entries[i]; } } return null; // not found } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#remove(java.io.File[], boolean) */ public void remove(File[] files, boolean force) throws SVNClientException { String[] paths = new String[files.length]; try { for (int i = 0; i < files.length; i++) { paths[i] = files[i].toString(); } _cmd.delete(paths, null,force); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#revert(java.io.File, boolean) */ public void revert(File file, boolean recursive) throws SVNClientException { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(file)); _cmd.revert(new String[] { toString(file) }, recursive); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#getContent(java.net.SVNUrl, org.tigris.subversion.subclipse.client.ISVNRevision) */ public InputStream getContent(SVNUrl arg0, SVNRevision arg1) throws SVNClientException { try { InputStream content = _cmd.cat(toString(arg0), toString(arg1)); //read byte-by-byte and put it in a vector. //then take the vector and fill a byteArray. byte[] byteArray; byteArray = streamToByteArray(content); content.close(); return new ByteArrayInputStream(byteArray); } catch (IOException e) { throw SVNClientException.wrapException(e); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getContent(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision) */ public InputStream getContent(File path, SVNRevision revision) throws SVNClientException { try { InputStream content = _cmd.cat(toString(path), toString(revision)); //read byte-by-byte and put it in a vector. //then take the vector and fill a byteArray. byte[] byteArray; byteArray = streamToByteArray(content); content.close(); return new ByteArrayInputStream(byteArray); } catch (IOException e) { throw SVNClientException.wrapException(e); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#mkdir(java.net.URL, java.lang.String) */ public void mkdir(SVNUrl arg0, String arg1) throws SVNClientException { try { _cmd.mkdir(toString(arg0), arg1); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#remove(java.net.URL[], java.lang.String) */ public void remove(SVNUrl[] urls, String message) throws SVNClientException { String[] urlsStrings = new String[urls.length]; for (int i = 0; i < urls.length; i++) { urlsStrings[i] = urls[i].toString(); } try { _cmd.delete(urlsStrings, message,false); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#copy(java.net.URL, java.net.URL, java.lang.String, org.tigris.subversion.subclipse.client.ISVNRevision) */ public void copy(SVNUrl src, SVNUrl dest, String message, SVNRevision rev) throws SVNClientException { try { if (message == null) message = ""; _cmd.copy(toString(src), toString(dest), message, toString(rev), false); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#copy(java.io.File, java.io.File) */ public void copy(File srcPath, File destPath) throws SVNClientException { try { _cmd.copy(toString(srcPath), toString(destPath)); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } //sometimes the dir has not yet been created. //wait up to 5 sec for the dir to be created. for (int i = 0; i < 50 && !destPath.exists(); i++) { try { Thread.sleep(100); } catch (InterruptedException e2) { //do nothing if interrupted } } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#move(java.net.URL, java.net.URL, java.lang.String, org.tigris.subversion.subclipse.client.ISVNRevision) */ public void move(SVNUrl url, SVNUrl destUrl, String message, SVNRevision revision) throws SVNClientException { try { notificationHandler.setBaseDir(new File(".")); _cmd.move(toString(url), toString(destUrl), message, toString(revision), false); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#move(java.io.File, java.io.File, boolean) */ public void move(File file, File file2, boolean force) throws SVNClientException { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(new File[] {file,file2})); _cmd.move(toString(file), toString(file2), null, null, force); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#setUsername(java.lang.String) */ public void setUsername(String string) { if (string == null || string.length() == 0) return; _cmd.setUsername(string); } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#setPassword(java.lang.String) */ public void setPassword(String password) { if (password == null) return; _cmd.setPassword(password); } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#addDirectory(java.io.File, boolean) */ public void addDirectory(File file, boolean recurse) throws SVNClientException { addDirectory(file, recurse, false); } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#addDirectory(java.io.File, boolean, boolean) */ public void addDirectory(File file, boolean recurse, boolean force) throws SVNClientException { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(file)); _cmd.add(toString(file), recurse, force); } catch (CmdLineException e) { //if something is already in svn and we //try to add it, we get a warning. //ignore it.\ if (e.getMessage().startsWith("svn: warning: ")) return; throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#addFile(java.io.File) */ public void addFile(File file) throws SVNClientException { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(file)); _cmd.add(toString(file), false, false); } catch (CmdLineException e) { //if something is already in svn and we //try to add it, we get a warning. //ignore it.\ if (e.getMessage().startsWith("svn: warning: ")) return; throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#commit(java.io.File[], java.lang.String, boolean) */ public long commit(File[] parents, String comment, boolean recurse) throws SVNClientException { return commit(parents, comment, recurse , false); } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#commit(java.io.File[], java.lang.String, boolean, boolean) */ public long commit(File[] parents, String comment, boolean recurse, boolean keepLocks) throws SVNClientException { String[] paths = new String[parents.length]; for (int i = 0; i < parents.length; i++) { paths[i] = toString(parents[i]); } try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(parents)); _cmd.checkin(paths, comment, keepLocks); return _cmd.getRevision(); } catch (CmdLineException e) { if ("".equals(e.getMessage())) return SVNRevision.SVN_INVALID_REVNUM; if (e.getMessage().startsWith("svn: Attempted to lock an already-locked dir")) { //PHIL is this the best way to handle pending locks? (ie caused by "svn cp") //loop through up to 5 sec, waiting for locks //to be removed. for (int i = 0; i < 50; i++) { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(parents)); _cmd.checkin(paths, comment, keepLocks); return _cmd.getRevision(); } catch (CmdLineException e1) { try { Thread.sleep(100); } catch (InterruptedException e2) { //do nothing if interrupted } } } } throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#update(java.io.File, org.tigris.subversion.subclipse.client.ISVNRevision, boolean) */ public long update(File file, SVNRevision revision, boolean b) throws SVNClientException { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(file)); _cmd.update(toString(file), toString(revision)); return _cmd.getRevision(); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#update(java.io.File[], org.tigris.subversion.svnclientadapter.SVNRevision, boolean, boolean) */ public long[] update(File[] files, SVNRevision revision, boolean recurse, boolean ignoreExternals) throws SVNClientException { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(files[0])); _cmdMulti.update(toString(files), toString(revision)); return _cmdMulti.getRevisions(); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#checkout(java.net.URL, java.io.File, org.tigris.subversion.subclipse.client.ISVNRevision, boolean) */ public void checkout(SVNUrl url, File destPath, SVNRevision revision, boolean b) throws SVNClientException { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(destPath)); _cmd.checkout(toString(url), toString(destPath), toString(revision), b); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getStatus(java.io.File, boolean, boolean) */ public ISVNStatus[] getStatus(File path, boolean descend, boolean getAll) throws SVNClientException { return getStatus(path, descend, getAll, false); } protected CmdLineStatusPart[] getCmdStatuses(File[] paths, boolean descend, boolean getAll, boolean contactServer, boolean ignoreExternals) throws CmdLineException { String[] pathNames = new String[paths.length]; for (int i = 0; i < pathNames.length; i++) { pathNames[i] = toString(paths[i]); } return getCmdStatuses(pathNames, descend, getAll, contactServer, ignoreExternals); } protected CmdLineStatusPart[] getCmdStatuses(String[] paths, boolean descend, boolean getAll, boolean contactServer, boolean ignoreExternals) throws CmdLineException { if (paths.length == 0) { return new CmdLineStatusPart[0]; } byte[] listXml; listXml = _cmd.status(paths, descend, getAll, contactServer, ignoreExternals); return CmdLineStatusPart.CmdLineStatusPartFromXml.createStatusParts(listXml); } private void diff( String oldPath, SVNRevision oldPathRevision, String newPath, SVNRevision newPathRevision, File outFile, boolean recurse, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws SVNClientException { if (newPath == null) newPath = oldPath; if (oldPathRevision == null) oldPathRevision = SVNRevision.BASE; if (newPathRevision == null) newPathRevision = SVNRevision.WORKING; try { InputStream is = _cmd.diff( oldPath, toString(oldPathRevision), newPath, toString(newPathRevision), recurse, ignoreAncestry, noDiffDeleted, force); streamToFile(is, outFile); is.close(); } catch (IOException e) { //this should never happen } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean) */ public void diff( File oldPath, SVNRevision oldPathRevision, File newPath, SVNRevision newPathRevision, File outFile, boolean recurse) throws SVNClientException { if (oldPath == null) oldPath = new File("."); diff(oldPath, oldPathRevision, newPath, newPathRevision, outFile, recurse, true, false, false); } public void diff( File oldPath, SVNRevision oldPathRevision, File newPath, SVNRevision newPathRevision, File outFile, boolean recurse, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws SVNClientException { if (oldPath == null) oldPath = new File("."); diff( toString(oldPath), oldPathRevision, toString(newPath), newPathRevision, outFile, recurse, ignoreAncestry, noDiffDeleted, force); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(java.io.File, java.io.File, boolean) */ public void diff(File path, File outFile, boolean recurse) throws SVNClientException { diff(path, null, null, null, outFile, recurse); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean) */ public void diff( SVNUrl oldUrl, SVNRevision oldUrlRevision, SVNUrl newUrl, SVNRevision newUrlRevision, File outFile, boolean recurse) throws SVNClientException { diff(oldUrl, oldUrlRevision, newUrl, newUrlRevision, outFile, recurse, true, false, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean, boolean, boolean, boolean) */ public void diff( SVNUrl oldUrl, SVNRevision oldUrlRevision, SVNUrl newUrl, SVNRevision newUrlRevision, File outFile, boolean recurse, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws SVNClientException { diff(toString(oldUrl), oldUrlRevision, toString(newUrl), newUrlRevision, outFile, recurse, ignoreAncestry, noDiffDeleted, force); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean) */ public void diff( SVNUrl url, SVNRevision oldUrlRevision, SVNRevision newUrlRevision, File outFile, boolean recurse) throws SVNClientException { diff(url, oldUrlRevision, url, newUrlRevision, outFile, recurse); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#propertyGet(java.io.File, java.lang.String) */ public ISVNProperty propertyGet(File path, String propertyName) throws SVNClientException { try { InputStream valueAndData = _cmd.propget(toString(path), propertyName); byte[] bytes = streamToByteArray(valueAndData); valueAndData.close(); if (bytes.length == 0) { return null; // the property does not exist } return new CmdLineProperty(propertyName, new String(bytes), path, bytes); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } catch (IOException e) { throw SVNClientException.wrapException(e); } } public ISVNProperty propertyGet(SVNUrl url, String propertyName) throws SVNClientException { try { InputStream valueAndData = _cmd.propget(url.toString(), propertyName); byte[] bytes = streamToByteArray(valueAndData); valueAndData.close(); if (bytes.length == 0) { return null; // the property does not exist } return new CmdLineProperty(propertyName, new String(bytes), url, bytes); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } catch (IOException e) { throw SVNClientException.wrapException(e); } } public ISVNProperty propertyGet(SVNUrl url, SVNRevision revision, SVNRevision peg, String propertyName) throws SVNClientException { try { InputStream valueAndData = _cmd.propget(url.toString(), propertyName, toString(revision), toString(peg)); byte[] bytes = streamToByteArray(valueAndData); if (bytes.length == 0) { return null; // the property does not exist } return new CmdLineProperty(propertyName, new String(bytes), url, bytes); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } catch (IOException e) { throw SVNClientException.wrapException(e); } } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#propertySet(java.io.File, java.lang.String, java.io.File, boolean) */ public void propertySet(File path, String propertyName, File propertyFile, boolean recurse) throws SVNClientException, IOException { try { _cmd.propsetFile(propertyName, toString(propertyFile), toString(path), recurse); // there is no notification (Notify.notify is not called) when we set a property // so we will do notification ourselves ISVNStatus[] statuses = getStatus(path,recurse,false); for (int i = 0; i < statuses.length;i++) { notificationHandler.notifyListenersOfChange(statuses[i].getFile().getAbsolutePath()); } } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#propertyDel(java.io.File, java.lang.String, boolean) */ public void propertyDel(File path, String propertyName, boolean recurse) throws SVNClientException { try { _cmd.propdel(propertyName, toString(path), recurse); // there is no notification (Notify.notify is not called) when we delete a property // so we will do notification ourselves ISVNStatus[] statuses = getStatus(path,recurse,false); for (int i = 0; i < statuses.length;i++) { notificationHandler.notifyListenersOfChange(statuses[i].getFile().getAbsolutePath()); } } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#setRevProperty(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision.Number, java.lang.String, java.lang.String, boolean) */ public void setRevProperty(SVNUrl path, SVNRevision.Number revisionNo, String propName, String propertyData, boolean force) throws SVNClientException { try { _cmd.revpropset(propName, propertyData, toString(path), Long.toString(revisionNo.getNumber()), force); // there is no notification to send } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#mkdir(java.io.File) */ public void mkdir(File file) throws SVNClientException { try { _cmd.mkdir(toString(file)); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } //sometimes the dir has not yet been created. //wait up to 5 sec for the dir to be created. for (int i = 0; i < 50 && !file.exists(); i++) { try { Thread.sleep(100); } catch (InterruptedException e2) { //do nothing if interrupted } } } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#doImport(java.io.File, org.tigris.subversion.svnclientadapter.SVNUrl, java.lang.String, boolean) */ public void doImport(File path, SVNUrl url, String message, boolean recurse) throws SVNClientException { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); _cmd.importFiles(toString(path), toString(url), message, recurse); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#doExport(org.tigris.subversion.svnclientadapter.SVNUrl, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public void doExport(SVNUrl srcUrl, File destPath, SVNRevision revision, boolean force) throws SVNClientException { try { _cmd.export(toString(srcUrl), toString(destPath), toString(revision), force); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#doExport(java.io.File, java.io.File, boolean) */ public void doExport(File srcPath, File destPath, boolean force) throws SVNClientException { try { _cmd.export(toString(srcPath), toString(destPath), null, force); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#copy(java.io.File, org.tigris.subversion.svnclientadapter.SVNUrl, java.lang.String) */ public void copy(File srcPath, SVNUrl destUrl, String message) throws SVNClientException { try { if (message == null) message = ""; _cmd.copy(toString(srcPath), toString(destUrl), message, null, false); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#copy(org.tigris.subversion.svnclientadapter.SVNUrl, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision) */ public void copy(SVNUrl srcUrl, File destPath, SVNRevision revision) throws SVNClientException { try { _cmd.copy(toString(srcUrl), toString(destPath), null, toString(revision), false); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#propertySet(java.io.File, java.lang.String, java.lang.String, boolean) */ public void propertySet(File path, String propertyName, String propertyValue, boolean recurse) throws SVNClientException { try { _cmd.propset(propertyName, propertyValue, toString(path), recurse); // there is no notification (Notify.notify is not called) when we set a property // so we will do notification ourselves ISVNStatus[] statuses = getStatus(path,recurse,false); for (int i = 0; i < statuses.length;i++) { notificationHandler.notifyListenersOfChange(statuses[i].getFile().getAbsolutePath()); } } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /** * A safe toString() implementation which implements * null checking on obj. */ protected static String toString(Object obj) { return (obj == null) ? null : obj.toString(); } /** * Implementation used by overloads of getLogMessages(). * * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ private ISVNLogMessage[] getLogMessages( String pathOrUrl, String [] paths, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit) throws SVNClientException { String revRange = toString(revisionStart) + ":" + toString(revisionEnd); try { byte[] messages; // To acquire the paths associated with each delta, we'd // have to include the --verbose argument. if (fetchChangePath) { messages = _cmd.logVerbose(pathOrUrl, paths, revRange, stopOnCopy, limit); } else { messages = _cmd.log(pathOrUrl, revRange, stopOnCopy, limit); } return CmdLineLogMessage.createLogMessages(messages); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } private static void streamToFile(InputStream stream, File outFile) throws IOException { int tempByte; try { FileOutputStream os = new FileOutputStream(outFile); while ((tempByte = stream.read()) != -1) { os.write(tempByte); } os.close(); stream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } } private static byte[] streamToByteArray(InputStream stream) throws IOException { //read byte-by-byte and put it in a vector. //then take the vector and fill a byteArray. Vector buffer = new Vector(1024); int tempByte; while ((tempByte = stream.read()) != -1) { buffer.add(new Byte((byte) tempByte)); } byte[] byteArray = new byte[buffer.size()]; for (int i = 0; i < byteArray.length; i++) { Byte b = (Byte) buffer.get(i); byteArray[i] = b.byteValue(); } return byteArray; } protected ISVNAnnotations annotate(String target, SVNRevision revisionStart, SVNRevision revisionEnd) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.ANNOTATE); if(revisionStart == null) revisionStart = new SVNRevision.Number(1); if(revisionEnd == null) revisionEnd = SVNRevision.HEAD; byte[] annotations = _cmd.annotate(target,toString(revisionStart),toString(revisionEnd)); InputStream contents = _cmd.cat(target, revisionEnd.toString()); CmdLineAnnotations result = CmdLineAnnotations.createFromXml(annotations, contents); try { contents.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return result; } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#blame(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision) */ public ISVNAnnotations annotate(SVNUrl url, SVNRevision revisionStart, SVNRevision revisionEnd) throws SVNClientException { return annotate(toString(url), revisionStart, revisionEnd); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#annotate(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision) */ public ISVNAnnotations annotate(File file, SVNRevision revisionStart, SVNRevision revisionEnd) throws SVNClientException { String target = toString(file); //If the file is an uncommitted rename/move, we have to refer to original/source, not the new copy. ISVNInfo info = getInfoFromWorkingCopy(file); if ((SVNScheduleKind.ADD == info.getSchedule()) && (info.getCopyUrl() != null)) { target = info.getCopyUrl().toString(); } return annotate(target, revisionStart, revisionEnd); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getProperties(java.io.File) */ public ISVNProperty[] getProperties(File path) throws SVNClientException { try { String propertiesString = _cmd.proplist(toString(path), false); String propertyName; List properties = new LinkedList(); StringTokenizer st = new StringTokenizer(propertiesString, Helper.NEWLINE); while (st.hasMoreTokens()) { String propertyLine = st.nextToken(); if (propertyLine.startsWith("Properties on '")) { } else { propertyName = propertyLine.substring(2); properties.add(propertyGet(path,propertyName)); } } return (ISVNProperty[]) properties.toArray(new ISVNProperty[0]); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } public ISVNProperty[] getProperties(SVNUrl url) throws SVNClientException { try { String propertiesString = _cmd.proplist(url.toString(), false); String propertyName; List properties = new LinkedList(); StringTokenizer st = new StringTokenizer(propertiesString, Helper.NEWLINE); while (st.hasMoreTokens()) { String propertyLine = st.nextToken(); if (propertyLine.startsWith("Properties on '")) { } else { propertyName = propertyLine.substring(2); properties.add(propertyGet(url,propertyName)); } } return (ISVNProperty[]) properties.toArray(new ISVNProperty[0]); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /** * Remove 'conflicted' state on working copy files or directories * @param path * @throws SVNClientException */ public void resolved(File path) throws SVNClientException { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); _cmd.resolved(new String[] { toString(path) }, false); // there is no notification when we do svn resolve, we will do notification ourselves notificationHandler.notifyListenersOfChange(path.getAbsolutePath()); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#createRepository(java.io.File) */ public void createRepository(File path, String repositoryType) throws SVNClientException { try { svnAdminCmd.create(toString(path), repositoryType); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getStatus(java.io.File, boolean, boolean, boolean) */ public ISVNStatus[] getStatus(File path, boolean descend, boolean getAll, boolean contactServer) throws SVNClientException { return getStatus(path, descend, getAll, contactServer, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getStatus(java.io.File, boolean, boolean, boolean, boolean) */ public ISVNStatus[] getStatus(File path, boolean descend, boolean getAll, boolean contactServer, boolean ignoreExternals) throws SVNClientException { try { // first we get the status of the files CmdLineStatusPart[] cmdLineStatusParts = getCmdStatuses(new File[] {path},descend, getAll, contactServer, ignoreExternals); List targetsInfo = new ArrayList(cmdLineStatusParts.length); List nonManagedParts = new ArrayList(); for (int i = 0; i < cmdLineStatusParts.length;i++) { if (cmdLineStatusParts[i].isManaged()) { targetsInfo.add(cmdLineStatusParts[i].getFile().toString()); } else { nonManagedParts.add(new Integer(i)); } } // this is not enough, so we get info from the files String infoLinesString = _cmd.info((String[]) targetsInfo.toArray(new String[targetsInfo.size()] ), null, null); String[] parts = CmdLineInfoPart.parseInfoParts(infoLinesString); CmdLineInfoPart[] cmdLineInfoParts = new CmdLineInfoPart[parts.length]; for (int i = 0; i < parts.length;i++) { cmdLineInfoParts[i] = new CmdLineInfoPart(parts[i]); } CmdLineInfoPart[] allInfoParts = new CmdLineInfoPart[cmdLineStatusParts.length]; //Put the unversioned at corrent indexes. for (Iterator iter = nonManagedParts.iterator(); iter.hasNext();) { Integer indexOfNonManaged = (Integer) iter.next(); allInfoParts[indexOfNonManaged.intValue()] = CmdLineInfoPart.createUnversioned(null); } //Fill the remaining indexes with versioned infos. for (int i = 0; i < cmdLineInfoParts.length; i++) { for (int j = i; j < allInfoParts.length; j++) { if (allInfoParts[j] == null) { allInfoParts[j] = cmdLineInfoParts[i]; break; } } } CmdLineStatuses cmdLineStatuses = new CmdLineStatuses(cmdLineInfoParts, cmdLineStatusParts); return cmdLineStatuses.toArray(); } catch (CmdLineException e) { if (e.getMessage().trim().matches("svn:.*is not a working copy.*")) { return new ISVNStatus[] {new SVNStatusUnversioned(path)}; } throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#cancelOperation() */ public void cancelOperation() throws SVNClientException { notificationHandler.logMessage("Warning: operation canceled."); _cmd.stopProcess(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getInfoFromWorkingCopy(java.io.File) */ public ISVNInfo getInfoFromWorkingCopy(File path) throws SVNClientException { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); // first we get the status of the files to find out whether it is versioned CmdLineStatusPart[] cmdLineStatusParts = getCmdStatuses(new File[] {path}, false, true, false, false); // if the file is managed, it is safe to call info if ((cmdLineStatusParts.length > 0) && (cmdLineStatusParts[0].isManaged())) { String cmdLineInfoStrings = _cmd.info(new String[] { toString(path) }, null, null); return new CmdLineInfoPart(cmdLineInfoStrings); } else { return CmdLineInfoPart.createUnversioned(path.getPath()); } } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getInfo(java.io.File) */ public ISVNInfo getInfo(File path) throws SVNClientException { return getInfoFromWorkingCopy(path); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getInfo(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision) */ public ISVNInfo getInfo(SVNUrl url, SVNRevision revision, SVNRevision peg) throws SVNClientException { return getInfo(new SVNUrl[] { url }, revision, peg); } private ISVNInfo getInfo(SVNUrl[] urls, SVNRevision revision, SVNRevision peg) throws SVNClientException { try { String[] urlStrings = new String[urls.length]; for (int i = 0; i < urls.length; i++) { urlStrings[i] = toString(urls[i]); } //notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(urls)); String cmdLineInfoStrings = _cmd.info(urlStrings, toString(revision), toString(peg)); return new CmdLineInfoPart(cmdLineInfoStrings); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getInfo(org.tigris.subversion.svnclientadapter.SVNUrl[]) */ public ISVNInfo getInfo(SVNUrl[] urls) throws SVNClientException { return getInfo(urls, null, null); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#switchUrl(org.tigris.subversion.svnclientadapter.SVNUrl, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public void switchToUrl(File path, SVNUrl url, SVNRevision revision, boolean recurse) throws SVNClientException { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); _cmd.switchUrl(toString(path), toString(url), toString(revision), recurse); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#setConfigDirectory(java.io.File) */ public void setConfigDirectory(File dir) throws SVNClientException { _cmd.setConfigDirectory(toString(dir)); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#cleanup(java.io.File) */ public void cleanup(File path) throws SVNClientException { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); _cmd.cleanup(toString(path)); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#merge(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean, boolean, boolean, boolean) */ public void merge(SVNUrl path1, SVNRevision revision1, SVNUrl path2, SVNRevision revision2, File localPath, boolean force, boolean recurse, boolean dryRun, boolean ignoreAncestry) throws SVNClientException { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(localPath)); _cmd.merge(toString(path1), toString(revision1), toString(path2), toString(revision2), toString(localPath), force, recurse, dryRun, ignoreAncestry); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#lock(SVNUrl[], java.lang.String, boolean) */ public void lock(SVNUrl[] uris, String comment, boolean force) throws SVNClientException { // notificationHandler isn't used because we're operating on // the repository (rather than the WC). try { _cmd.lock(uris, comment, force); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#unlock(SVNUrl[], boolean) */ public void unlock(SVNUrl[] uris, boolean force) throws SVNClientException { // notificationHandler isn't used because we're operating on // the repository (rather than the WC). try { _cmd.unlock(uris, force); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#lock(java.io.File[], java.lang.String, boolean) */ public void lock(File[] paths, String comment, boolean force) throws SVNClientException { String[] files = new String[paths.length]; for (int i = 0; i < paths.length; i++) { files[i] = toString(paths[i]); } try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(paths)); _cmd.lock(files, comment, force); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } finally { for (int i = 0; i < files.length; i++) { notificationHandler.notifyListenersOfChange(files[i]); } } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#unlock(java.lang.String[], boolean) */ public void unlock(File[] paths, boolean force) throws SVNClientException { String[] files = new String[paths.length]; for (int i = 0; i < paths.length; i++) { files[i] = toString(paths[i]); } try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(paths)); _cmd.unlock(files, force); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } finally { for (int i = 0; i < files.length; i++) { notificationHandler.notifyListenersOfChange(files[i]); } } } public String getAdminDirectoryName(){ if (dirName == null) { // svn only supports this feature on Windows if (isOsWindows()) dirName = getEnvironmentVariable("SVN_ASP_DOT_NET_HACK"); // If the environment variable was present, then use _svn // as the directory name, otherwise the default of .svn if (dirName != null) dirName = "_svn"; else dirName = ".svn"; } return dirName; } public boolean isAdminDirectory(String name) { return getAdminDirectoryName().equals(name); } public static String getEnvironmentVariable(String var) { try { // pre-Java 1.5 this throws an Error. On Java 1.5 it // returns the environment variable return System.getenv(var); } catch(Error e) { try { // This means we are on 1.4. Get all variables into // a Properties object and get the variable from that return getEnvVars().getProperty(var); } catch (Throwable e1) { return null; } } } public static Properties getEnvVars() throws Throwable { Process p = null; Properties envVars = new Properties(); Runtime r = Runtime.getRuntime(); if (isOsWindows()) { if (System.getProperty("os.name").toLowerCase().indexOf("windows 9") > -1) p = r.exec( "command.com /c set" ); else p = r.exec( "cmd.exe /c set" ); } else { p = r.exec( "env" ); } if (p != null) { BufferedReader br = new BufferedReader( new InputStreamReader(p.getInputStream())); String line; while( (line = br.readLine()) != null ) { int idx = line.indexOf( '=' ); String key = line.substring( 0, idx ); String value = line.substring( idx+1 ); envVars.setProperty( key, value ); } p.getInputStream().close(); p.getOutputStream().close(); p.getErrorStream().close(); } return envVars; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public ISVNLogMessage[] getLogMessages(File path, SVNRevision revStart, SVNRevision revEnd, boolean fetchChangePath) throws SVNClientException { return getLogMessages(path, revStart, revEnd, false, fetchChangePath); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean, boolean) */ public ISVNLogMessage[] getLogMessages(File path, SVNRevision revStart, SVNRevision revEnd, boolean stopOnCopy, boolean fetchChangePath) throws SVNClientException { return getLogMessages(path, revStart, revEnd, stopOnCopy, fetchChangePath, 0); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean, boolean, long) */ public ISVNLogMessage[] getLogMessages(File path, SVNRevision revStart, SVNRevision revEnd, boolean stopOnCopy, boolean fetchChangePath, long limit) throws SVNClientException { String target = toString(path); //If the file is an uncommitted rename/move, we have to refer to original/source, not the new copy. ISVNInfo info = getInfoFromWorkingCopy(path); if ((SVNScheduleKind.ADD == info.getSchedule()) && (info.getCopyUrl() != null)) { target = info.getCopyUrl().toString(); } return getLogMessages(target, null, revStart, revEnd, stopOnCopy, fetchChangePath, limit); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public ISVNLogMessage[] getLogMessages(SVNUrl url, SVNRevision revStart, SVNRevision revEnd, boolean fetchChangePath) throws SVNClientException { return getLogMessages(url, null, revStart, revEnd, false, fetchChangePath); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean, boolean, long) */ public ISVNLogMessage[] getLogMessages(SVNUrl url, SVNRevision pegRevision, SVNRevision revStart, SVNRevision revEnd, boolean stopOnCopy, boolean fetchChangePath, long limit) throws SVNClientException { //TODO pegRevision not supported ! return getLogMessages(toString(url), null, revStart, revEnd, stopOnCopy, fetchChangePath, limit); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages(org.tigris.subversion.svnclientadapter.SVNUrl, java.lang.String[], org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean, boolean) */ public ISVNLogMessage[] getLogMessages(SVNUrl url, String[] paths, SVNRevision revStart, SVNRevision revEnd, boolean stopOnCopy, boolean fetchChangePath) throws SVNClientException { return getLogMessages(toString(url), paths, revStart, revEnd, stopOnCopy, fetchChangePath, 0); } public void relocate(String from, String to, String path, boolean recurse) throws SVNClientException { try { notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(new File(path))); _cmd.relocate(from, to, path, recurse); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(java.io.File, org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean) */ public void diff(File path, SVNUrl url, SVNRevision urlRevision, File outFile, boolean recurse) throws SVNClientException { diff( toString(path), null, toString(url) + "@" + toString(urlRevision), null, outFile, recurse, true, false, false); } public void addConflictResolutionCallback(ISVNConflictResolver callback) { // TODO } public ISVNAnnotations annotate(File file, SVNRevision revisionStart, SVNRevision revisionEnd, boolean ignoreMimeType, boolean includeMergedRevisions) throws SVNClientException { notImplementedYet(); return null; } public ISVNAnnotations annotate(SVNUrl url, SVNRevision revisionStart, SVNRevision revisionEnd, boolean ignoreMimeType, boolean includeMergedRevisions) throws SVNClientException { notImplementedYet(); return null; } public ISVNLogMessage[] getLogMessages(File path, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions) throws SVNClientException { notImplementedYet(); return null; } public ISVNLogMessage[] getLogMessages(SVNUrl url, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions) throws SVNClientException { notImplementedYet(); return null; } public ISVNMergeInfo getMergeInfo(File path, SVNRevision revision) throws SVNClientException { notImplementedYet(); return null; } public ISVNMergeInfo getMergeInfo(SVNUrl url, SVNRevision revision) throws SVNClientException { notImplementedYet(); return null; } public void merge(SVNUrl url, SVNRevision pegRevision, SVNRevisionRange[] revisions, File localPath, boolean force, int depth, boolean ignoreAncestry, boolean dryRun) throws SVNClientException { notImplementedYet(); } public SVNDiffSummary[] diffSummarize(File target, SVNRevision pegRevision, SVNRevision startRevision, SVNRevision endRevision, int depth, boolean ignoreAncestry) throws SVNClientException { notImplementedYet(); return null; } public SVNDiffSummary[] diffSummarize(File target1, SVNRevision revision1, SVNUrl target2, SVNRevision revision2, int depth, boolean ignoreAncestry) throws SVNClientException { notImplementedYet(); return null; } public SVNDiffSummary[] diffSummarize(SVNUrl target, SVNRevision pegRevision, SVNRevision startRevision, SVNRevision endRevision, int depth, boolean ignoreAncestry) throws SVNClientException { notImplementedYet(); return null; } public SVNDiffSummary[] diffSummarize(SVNUrl target1, SVNRevision revision1, SVNUrl target2, SVNRevision revision2, int depth, boolean ignoreAncestry) throws SVNClientException { notImplementedYet(); return null; } public String[] suggestMergeSources(File path) throws SVNClientException { notImplementedYet(); return null; } public String[] suggestMergeSources(SVNUrl url, SVNRevision peg) throws SVNClientException { notImplementedYet(); return null; } public void checkout(SVNUrl moduleName, File destPath, SVNRevision revision, int depth, boolean ignoreExternals, boolean force) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); } public void copy(SVNUrl srcUrl, SVNUrl destUrl, String message, SVNRevision revision, boolean makeParents) throws SVNClientException { try { if (message == null) message = ""; _cmd.copy(toString(srcUrl), toString(destUrl), message, toString(revision), makeParents); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } public void diff(SVNUrl target, SVNRevision pegRevision, SVNRevision startRevision, SVNRevision endRevision, File outFile, int depth, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); } public void diff(SVNUrl target, SVNRevision pegRevision, SVNRevision startRevision, SVNRevision endRevision, File outFile, boolean recurse) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); } public void dispose() { // TODO Auto-generated method stub } public InputStream getContent(SVNUrl url, SVNRevision revision, SVNRevision pegRevision) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); return null; } public ISVNDirEntry[] getList(SVNUrl url, SVNRevision revision, SVNRevision pegRevision, boolean recurse) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); return null; } public ISVNDirEntry[] getList(File path, SVNRevision revision, SVNRevision pegRevision, boolean recurse) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); return null; } public void resolve(File path, int result) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); } public void setProgressListener(ISVNProgressListener progressListener) { // TODO Auto-generated method stub } public void merge(SVNUrl url, SVNRevision pegRevision, SVNRevisionRange[] revisions, File localPath, boolean force, int depth, boolean ignoreAncestry, boolean dryRun, boolean recordOnly) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); } public void merge(SVNUrl path1, SVNRevision revision1, SVNUrl path2, SVNRevision revision2, File localPath, boolean force, int depth, boolean dryRun, boolean ignoreAncestry, boolean recordOnly) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); } public void copy(File[] srcPaths, SVNUrl destUrl, String message, boolean copyAsChild, boolean makeParents) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); } public void copy(SVNUrl[] srcUrls, SVNUrl destUrl, String message, SVNRevision revision, boolean copyAsChild, boolean makeParents) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); } public void switchToUrl(File path, SVNUrl url, SVNRevision revision, int depth, boolean setDepth, boolean ignoreExternals, boolean force) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); } public void switchToUrl(File path, SVNUrl url, SVNRevision revision, SVNRevision pegRevision, int depth, boolean setDepth, boolean ignoreExternals, boolean force) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); } public long update(File path, SVNRevision revision, int depth, boolean setDepth, boolean ignoreExternals, boolean force) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); return 0; } public long[] update(File[] path, SVNRevision revision, int depth, boolean setDepth, boolean ignoreExternals, boolean force) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); return null; } public void mergeReintegrate(SVNUrl path, SVNRevision pegRevision, File localPath, boolean force, boolean dryRun) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); } public void copy(SVNUrl srcUrl, File destPath, SVNRevision revision, boolean copyAsChild, boolean makeParents) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); } public ISVNLogMessage[] getMergeinfoLog(int kind, File path, SVNRevision pegRevision, SVNUrl mergeSourceUrl, SVNRevision srcPegRevision, boolean discoverChangedPaths) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); return null; } public ISVNLogMessage[] getMergeinfoLog(int kind, SVNUrl url, SVNRevision pegRevision, SVNUrl mergeSourceUrl, SVNRevision srcPegRevision, boolean discoverChangedPaths) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); return null; } public void getLogMessages(File path, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions, String[] requestedProperties, ISVNLogMessageCallback callback) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); } public void getLogMessages(SVNUrl url, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions, String[] requestedProperties, ISVNLogMessageCallback callback) throws SVNClientException { // TODO Auto-generated method stub notImplementedYet(); } public void copy(SVNUrl srcUrl, File destPath, SVNRevision revision, SVNRevision pegRevision, boolean copyAsChild, boolean makeParents) throws SVNClientException { // TODO Auto-generated method stub } public ISVNInfo[] getInfo(File file, boolean descend) throws SVNClientException { // TODO Auto-generated method stub return null; } public String getRevProperty(SVNUrl path, Number revisionNo, String propName) throws SVNClientException { // TODO Auto-generated method stub return null; } public ISVNAnnotations annotate(SVNUrl url, SVNRevision revisionStart, SVNRevision revisionEnd, SVNRevision pegRevision, boolean ignoreMimeType, boolean includeMergedRevisions) throws SVNClientException { // TODO Auto-generated method stub return null; } public ISVNAnnotations annotate(File file, SVNRevision revisionStart, SVNRevision revisionEnd, SVNRevision pegRevision, boolean ignoreMimeType, boolean includeMergedRevisions) throws SVNClientException { // TODO Auto-generated method stub return null; } public ISVNProperty[] getProperties(SVNUrl url, SVNRevision revision, SVNRevision peg) throws SVNClientException { // TODO Auto-generated method stub return null; } public ISVNProperty[] getRevProperties(SVNUrl url, Number revision) throws SVNClientException { // TODO Auto-generated method stub return null; } public SVNDiffSummary[] diffSummarize(File path, SVNUrl toUrl, SVNRevision toRevision, boolean recurse) throws SVNClientException { // TODO Auto-generated method stub return null; } @Override public String getPostCommitError() { // TODO Auto-generated method stub return null; } @Override public ISVNStatus[] getStatus(File path, boolean descend, boolean getAll, boolean contactServer, boolean ignoreExternals, ISVNStatusCallback callback) throws SVNClientException { // TODO Auto-generated method stub return null; } @Override public void propertySet(SVNUrl url, Number baseRev, String propertyName, String propertyValue, String message) throws SVNClientException { // TODO Auto-generated method stub } @Override public ISVNProperty[] getProperties(File path, boolean descend) throws SVNClientException { // TODO Auto-generated method stub return null; } @Override public ISVNProperty[] getProperties(SVNUrl url, SVNRevision revision, SVNRevision peg, boolean recurse) throws SVNClientException { // TODO Auto-generated method stub return null; } @Override public void switchToUrl(File path, SVNUrl url, SVNRevision revision, SVNRevision pegRevision, int depth, boolean setDepth, boolean ignoreExternals, boolean force, boolean ignoreAncestry) throws SVNClientException { // TODO Auto-generated method stub } @Override public void upgrade(File dir) throws SVNClientException { // TODO Auto-generated method stub } } CmdLineClientAdapter12.java000066400000000000000000000110141203563747500372700ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.io.File; import org.tigris.subversion.svnclientadapter.ISVNAnnotations; import org.tigris.subversion.svnclientadapter.ISVNNotifyListener; import org.tigris.subversion.svnclientadapter.ISVNStatus; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.utils.StringUtils; /** * Implements functions compatible with svn client version 1.2 or earlier * */ public class CmdLineClientAdapter12 extends CmdLineClientAdapter { private static boolean availabilityCached = false; private static boolean available; /** * Constructor * @param notificationHandler */ public CmdLineClientAdapter12(CmdLineNotificationHandler notificationHandler) { super(notificationHandler, new SvnCommandLine12("svn", notificationHandler), new SvnMultiArgCommandLine("svn", notificationHandler), new SvnAdminCommandLine("svnadmin", notificationHandler)); } public static boolean isAvailable() { // availabilityCached flag must be reset if location of client changes if (!availabilityCached) { // this will need to be fixed when path to svn will be customizable SvnCommandLine cmd = new SvnCommandLine("svn", new CmdLineNotificationHandler()); try { cmd.version(); available = true; } catch (Exception e) { available = false; } availabilityCached = true; } return available; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getStatus(java.io.File, boolean, boolean, boolean) */ public ISVNStatus[] getStatus(File path, boolean descend, boolean getAll, boolean contactServer) throws SVNClientException { notImplementedYet(); return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.commandline.CmdLineClientAdapter#getStatus(java.io.File, boolean, boolean) */ public ISVNStatus[] getStatus(File path, boolean descend, boolean getAll) throws SVNClientException { return super.getStatus(path, descend, getAll, false); } protected CmdLineStatusPart[] getCmdStatuses(String[] paths, boolean descend, boolean getAll, boolean contactServer, boolean ignoreExternals) throws CmdLineException { //Beware! the contactServer parameter is ignored, always treated as false. if (paths.length == 0) { return new CmdLineStatusPart[0]; } String statusLinesString = ((SvnCommandLine12) _cmd).statusByStdout(paths, descend, getAll, false, ignoreExternals); String[] parts = StringUtils.split(statusLinesString,Helper.NEWLINE); CmdLineStatusPart[] cmdLineStatusParts = new CmdLineStatusPart[parts.length]; for (int i = 0; i < parts.length;i++) { cmdLineStatusParts[i] = new CmdLineStatusPart.CmdLineStatusPartFromStdout(parts[i]); } return cmdLineStatusParts; } protected ISVNAnnotations annotate(String target, SVNRevision revisionStart, SVNRevision revisionEnd) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.ANNOTATE); if(revisionStart == null) revisionStart = new SVNRevision.Number(1); if(revisionEnd == null) revisionEnd = SVNRevision.HEAD; String annotations = ((SvnCommandLine12) _cmd).annotateByStdout(target,toString(revisionStart),toString(revisionEnd)); return CmdLineAnnotations.createFromStdOut(annotations,Helper.NEWLINE); } catch (CmdLineException e) { throw SVNClientException.wrapException(e); } } } CmdLineClientAdapterFactory.java000066400000000000000000000055161203563747500404670ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import org.tigris.subversion.svnclientadapter.ISVNClientAdapter; import org.tigris.subversion.svnclientadapter.SVNClientAdapterFactory; import org.tigris.subversion.svnclientadapter.SVNClientException; /** * Concrete implementation of SVNClientAdapterFactory for command line interface. * To register this factory, just call {@link CmdLineClientAdapterFactory#setup()} */ public class CmdLineClientAdapterFactory extends SVNClientAdapterFactory { /** Client adapter implementation identifier */ public static final String COMMANDLINE_CLIENT = "commandline"; private static boolean is13ClientAvailable = false; /** * Private constructor. * Clients are expected the use {@link #createSVNClientImpl()}, res. * ask the {@link SVNClientAdapterFactory} */ private CmdLineClientAdapterFactory() { super(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.SVNClientAdapterFactory#createSVNClientImpl() */ protected ISVNClientAdapter createSVNClientImpl() { if (is13ClientAvailable) { return new CmdLineClientAdapter(new CmdLineNotificationHandler()); } else { return new CmdLineClientAdapter12(new CmdLineNotificationHandler()); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.SVNClientAdapterFactory#getClientType() */ protected String getClientType() { return COMMANDLINE_CLIENT; } /** * Setup the client adapter implementation and register it in the adapters factory * @throws SVNClientException */ public static void setup() throws SVNClientException { if (!CmdLineClientAdapter12.isAvailable()) { throw new SVNClientException("Command line client adapter is not available"); } is13ClientAvailable = CmdLineClientAdapter.isAvailable(); SVNClientAdapterFactory.registerAdapterFactory(new CmdLineClientAdapterFactory()); } } CmdLineException.java000066400000000000000000000033111203563747500363450ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.lang.reflect.InvocationTargetException; /** * An exception that wraps the "svn" error message. * * @author Philip Schatz (schatz at tigris) */ class CmdLineException extends Exception { private static final long serialVersionUID = 1L; //Constructors CmdLineException() { super(); } CmdLineException(String message) { super(message); } CmdLineException(Throwable cause) { super(cause); } /* * Static helper method for creating exceptions */ static CmdLineException wrapException(Exception e) { if (e instanceof InvocationTargetException) { Throwable target = ((InvocationTargetException) e).getTargetException(); if (target instanceof CmdLineException) { return (CmdLineException) target; } } return new CmdLineException(e); } } CmdLineInfoPart.java000066400000000000000000000273631203563747500361460ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.io.File; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.StringTokenizer; import org.tigris.subversion.svnclientadapter.ISVNInfo; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNScheduleKind; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.SVNRevision.Number; /** * Represents the infos for one resource in the result of a svn info command * * @author Philip Schatz (schatz at tigris) * @author Cédric Chabanois (cchabanois at no-log.org) */ class CmdLineInfoPart implements ISVNInfo { //"Constants" private static final String KEY_PATH = "Path"; private static final String KEY_URL = "URL"; private static final String KEY_REVISION = "Revision"; private static final String KEY_REPOSITORY = "Repository Root"; private static final String KEY_NODEKIND = "Node Kind"; private static final String KEY_LASTCHANGEDAUTHOR = "Last Changed Author"; private static final String KEY_LASTCHANGEDREV = "Last Changed Rev"; private static final String KEY_LASTCHANGEDDATE = "Last Changed Date"; private static final String KEY_TEXTLASTUPDATED = "Text Last Updated"; private static final String KEY_SCHEDULE = "Schedule"; private static final String KEY_COPIEDFROMURL = "Copied From URL"; private static final String KEY_COPIEDFROMREV = "Copied From Rev"; private static final String KEY_PROPSLASTUPDATED = "Properties Last Updated"; private static final String KEY_REPOSITORYUUID = "Repository UUID"; private static final String KEY_LOCKOWNER = "Lock Owner"; private static final String KEY_LOCKCREATIONDATE = "Lock Created"; private static final String KEY_LOCKCOMMENT = "Lock Comment"; private static final String KEY_CONFLICTING_PREV_BASE = "Conflict Previous Base File"; private static final String KEY_CONFLICTING_PREV_WORKING = "Conflict Previous Working File"; private static final String KEY_CONFLICTING_CURRENT_BASE = "Conflict Current Base File"; //Fields private Map infoMap = new HashMap(); protected boolean unversioned = false; //Constructors /** * Here is two samples for infostring parameter * sample 1 : * ========== * Path: added.txt * Name: added.txt * URL: file:///F:/Programmation/Projets/subversion/svnant/test/test_repos/statusT * st/added.txt * Revision: 0 * Node Kind: file * Schedule: add * Conflict Previous Base File: rho.r1 * Conflict Previous Working File: rho * Conflict Current Base File: rho.r2 * * sample 2 : * =========== * ignored.txt: (Not a versioned resource) */ CmdLineInfoPart(String infoString) { this(); load(infoString); } protected CmdLineInfoPart() { super(); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastChangedDate() */ public Date getLastChangedDate() { return (unversioned) ? null : Helper.toDate(get(KEY_LASTCHANGEDDATE)); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastChangedRevision() */ public SVNRevision.Number getLastChangedRevision() { return (unversioned) ? null : Helper.toRevNum(get(KEY_LASTCHANGEDREV)); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastCommitAuthor() */ public String getLastCommitAuthor() { return (unversioned) ? null : get(KEY_LASTCHANGEDAUTHOR); } public SVNNodeKind getNodeKind() { return (unversioned) ? null : SVNNodeKind.fromString(get(KEY_NODEKIND)); } /** * @return path to this item */ public String getPath() { return get(KEY_PATH); } /** * @return The absolute path to this item. * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getFile() */ public File getFile() { return new File(getPath()).getAbsoluteFile(); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getRevision() */ public SVNRevision.Number getRevision() { return (unversioned) ? SVNRevision.INVALID_REVISION : Helper.toRevNum(get(KEY_REVISION)); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getUrl() */ public SVNUrl getUrl() { return (unversioned) ? null : Helper.toSVNUrl(get(KEY_URL)); } public String getUrlString() { return (unversioned) ? null : get(KEY_URL); } private String get(String key) { Object value = infoMap.get(key); return (value == null) ? null : value.toString(); } private void load(String infoString) { StringTokenizer st = new StringTokenizer(infoString, Helper.NEWLINE); //this does not have to be a versioned resource. //if it is not, the first line will end with // ": (Not a versioned resource)" if (st.countTokens() == 1) { unversioned = true; String line = st.nextToken(); // ### As of Subversion 1.3, this warning message is // ### printed to stderr. Are we ever even going to see // ### this text? // - no we're not. For >=1.3 we have to avoid this. // We cannot execute info on non-versioned resources, we have to use status first to check it. infoMap.put(KEY_PATH,line.substring(0,line.indexOf(": (Not a versioned resource)"))); } else { //First, go through and take each line and throw // it into a map with the key being the text to // the left of the colon, and value being to the // right. StringBuffer lockComment = new StringBuffer(); boolean inComment = false; while (st.hasMoreTokens()) { String line = st.nextToken(); if (inComment) { lockComment.append(line).append("\n"); } else { int middle = line.indexOf(':'); String key = line.substring(0, middle); if (key.startsWith(KEY_LOCKCOMMENT)) inComment = true; else { String value = line.substring(middle + 2); infoMap.put(key, value); } } } if (inComment) infoMap.put(KEY_LOCKCOMMENT, lockComment.toString()); } } /** * @return true when the info is versioned. */ public boolean isVersioned() { return !unversioned; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastDateTextUpdate() */ public Date getLastDateTextUpdate() { return (unversioned) ? null : Helper.toDate(get(KEY_TEXTLASTUPDATED)); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getUuid() */ public String getUuid() { return (unversioned) ? null : get(KEY_REPOSITORYUUID); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getRepository() */ public SVNUrl getRepository() { return (unversioned) ? null : Helper.toSVNUrl(get(KEY_REPOSITORY)); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getSchedule() */ public SVNScheduleKind getSchedule() { return SVNScheduleKind.fromString(get(KEY_SCHEDULE)); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastDatePropsUpdate() */ public Date getLastDatePropsUpdate() { return (unversioned) ? null : Helper.toDate(get(KEY_PROPSLASTUPDATED)); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#isCopied() */ public boolean isCopied() { return (getCopyRev() != null) || (getCopyUrl() != null); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getCopyRev() */ public Number getCopyRev() { return (unversioned) ? null : Helper.toRevNum(get(KEY_COPIEDFROMREV)); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getCopyUrl() */ public SVNUrl getCopyUrl() { return (unversioned) ? null : Helper.toSVNUrl(get(KEY_COPIEDFROMURL)); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockCreationDate() */ public Date getLockCreationDate() { return (unversioned) ? null : Helper.toDate(get(KEY_LOCKCREATIONDATE)); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockOwner() */ public String getLockOwner() { return (unversioned) ? null : get(KEY_LOCKOWNER); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockComment() */ public String getLockComment() { return (unversioned) ? null : get(KEY_LOCKCOMMENT); } /** * @return Returns the conflictNew. */ public File getConflictNew() { if (unversioned) return null; String path = get(KEY_CONFLICTING_CURRENT_BASE); return (path != null)? new File(getFile().getParent(), path).getAbsoluteFile() : null; } /** * @return Returns the conflictOld. */ public File getConflictOld() { if (unversioned) return null; String path = get(KEY_CONFLICTING_PREV_BASE); return (path != null)? new File(getFile().getParent(), path).getAbsoluteFile() : null; } /** * @return Returns the conflictWorking. */ public File getConflictWorking() { if (unversioned) return null; String path = get(KEY_CONFLICTING_PREV_WORKING); return (path != null)? new File(getFile().getParent(), path).getAbsoluteFile() : null; } /** * @param infoLines The text output by svn info. * @return The lines contained by infoLines as an * array. */ public static String[] parseInfoParts(String infoLines) { StringTokenizer st = new StringTokenizer(infoLines, Helper.NEWLINE); String current = null; List infoParts = new ArrayList(st.countTokens()); while (st.hasMoreTokens()) { String temp = st.nextToken(); if (temp.startsWith("Path:") || temp.endsWith(": (Not a versioned resource)")) { if (current != null) infoParts.add(current); current = temp; } else { if (current == null) current = temp; else current += "\n" + temp; } } if (current != null) infoParts.add(current); String[] infoArray = new String[infoParts.size()]; infoParts.toArray(infoArray); return infoArray; } /** * Factory method. Constructs unersioned info part for the give path * @param path * @return a new instance of CmdLineInfoPartUnversioned. */ public static CmdLineInfoPart createUnversioned(String path) { return new CmdLineInfoPartUnversioned(path); } protected static class CmdLineInfoPartUnversioned extends CmdLineInfoPart { private String path; protected CmdLineInfoPartUnversioned(String path) { super(); this.path = path; this.unversioned = true; } public String getPath() { return path; } } public int getDepth() { // TODO Auto-generated method stub return 0; } } CmdLineLogMessage.java000066400000000000000000000227641203563747500364520ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.io.ByteArrayInputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; import java.util.StringTokenizer; import javax.xml.parsers.DocumentBuilderFactory; import org.tigris.subversion.svnclientadapter.ISVNLogMessage; import org.tigris.subversion.svnclientadapter.ISVNLogMessageChangePath; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNLogMessageChangePath; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; /** *

Implements a Log message using "svn log".

* * @author Philip Schatz (schatz at tigris) */ class CmdLineLogMessage extends CmdLineXmlCommand implements ISVNLogMessage { private SVNRevision.Number rev; private String author; private Date date; private String msg; private ISVNLogMessageChangePath[] logMessageChangePaths; CmdLineLogMessage( SVNRevision.Number rev, String author, Date date, String msg, ISVNLogMessageChangePath[] logMessageChangePaths){ this.rev = rev; this.author = author; this.date = date; this.msg = msg; this.logMessageChangePaths = logMessageChangePaths; } /** * creates a log message from the output of svn log * This constructor is not used anymore. * The factory method createLogMessages is used instead */ CmdLineLogMessage(StringTokenizer st) { //NOTE: the leading dashes are ommitted by ClientAdapter. //grab "rev 49: phil | 2003-06-30 00:14:58 -0500 (Mon, 30 Jun 2003) | 1 line" String headerLine = st.nextToken(); //split the line up into 3 parts, left, middle, and right. StringTokenizer ltr = new StringTokenizer(headerLine, "|"); String left = ltr.nextToken(); String middle = ltr.nextToken(); String right = ltr.nextToken(); //Now, we have the header, so set the internal variables //set info gotten from top-left. StringTokenizer leftToken = new StringTokenizer(left, ":"); String revStr = leftToken.nextToken().trim(); //discard first bit. rev = Helper.toRevNum(revStr.substring(4, revStr.length())); // author is optional if(leftToken.hasMoreTokens()) author = leftToken.nextToken(); else author = ""; //set info from top-mid (date) date = Helper.toDate(middle.trim()); //get the number of lines. StringTokenizer rightToken = new StringTokenizer(right, " "); int messageLineCount = Integer.parseInt(rightToken.nextToken()); //get the body of the log. StringBuffer sb = new StringBuffer(); //st.nextToken(); //next line is always blank. for(int i=0; i < messageLineCount; i++) { sb.append(st.nextToken()); //dont add a newline to the last line. if(i < messageLineCount - 1) sb.append('\n'); } msg = sb.toString(); //take off the last dashes "-----------------------------------------" st.nextToken(); } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNLogMessage#getRevision() */ public SVNRevision.Number getRevision() { return rev; } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNLogMessage#getAuthor() */ public String getAuthor() { return author; } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNLogMessage#getDate() */ public Date getDate() { return date; } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNLogMessage#getMessage() */ public String getMessage() { return msg; } /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { return getMessage(); } /** * creates CmdLineLogMessages from a xml string (see svn log --xml -v) * @param cmdLineResults * @return CmdLineLogMessage[] array created from the supplied xml * @throws SVNClientException */ public static CmdLineLogMessage[] createLogMessages(byte[] cmdLineResults) throws SVNClientException { Collection logMessages = new ArrayList(); try { // Create a builder factory DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); // Create the builder and parse the file InputSource source = new InputSource(new ByteArrayInputStream(cmdLineResults)); Document doc = factory.newDocumentBuilder().parse(source); // This is the XML we need to parse // --verbose mode: // // Jesper // 2005-06-18T10:42:52.338920Z // // /trunk/Subclipse-test/org // /trunk/Subclipse-test/org/tigris // // This one is really really cool, too! // // Not --verbose mode: // // Jesper // 2005-06-18T10:42:52.338920Z // This one is really really cool, too! // NodeList nodes = doc.getElementsByTagName("logentry"); for(int i = 0; i < nodes.getLength(); i++) { Node logEntry = nodes.item(i); Element authorNode = getFirstNamedElement(logEntry, "author"); Element dateNode; if (authorNode == null) { dateNode = getFirstNamedElement(logEntry, "date"); } else { dateNode = getNextNamedElement(authorNode, "date"); } if (dateNode == null) throw new Exception("'date' tag expected under 'logentry'"); Element pathsNode = getNextNamedElement(dateNode, "paths"); Element msgNode = getNextNamedElement(pathsNode != null ? pathsNode : dateNode, "msg"); Node revisionAttribute = logEntry.getAttributes().getNamedItem("revision"); SVNRevision.Number rev = (revisionAttribute != null) ? Helper.toRevNum(revisionAttribute.getNodeValue()) : null; String author = (authorNode != null) ? authorNode.getFirstChild().getNodeValue() : ""; Date date = Helper.convertXMLDate(dateNode.getFirstChild().getNodeValue()); Node msgTextNode = msgNode.getFirstChild(); String msg = (msgTextNode != null) ? msgTextNode.getNodeValue() : ""; List paths = new ArrayList(); Element pathNode = getFirstNamedElement(pathsNode, "path"); while (pathNode != null) { String path = pathNode.getFirstChild().getNodeValue(); NamedNodeMap attributes = pathNode.getAttributes(); char action = attributes.getNamedItem("action").getNodeValue().charAt(0); Node copyFromPathNode = attributes.getNamedItem("copyfrom-path"); Node copyFromRevNode = attributes.getNamedItem("copyfrom-rev"); String copyFromPath = null; if (copyFromPathNode != null) { copyFromPath = copyFromPathNode.getNodeValue(); } SVNRevision.Number copyFromRev = null; if (copyFromRevNode != null) { copyFromRev = Helper.toRevNum(copyFromRevNode.getNodeValue()); } paths.add(new SVNLogMessageChangePath( path, copyFromRev, copyFromPath, action)); pathNode = getNextNamedElement(pathNode, "path"); } ISVNLogMessageChangePath[] logMessageChangePath = (ISVNLogMessageChangePath[])paths.toArray(new ISVNLogMessageChangePath[paths.size()]); CmdLineLogMessage logMessage = new CmdLineLogMessage(rev, author, date, msg, logMessageChangePath); logMessages.add(logMessage); } } catch (Exception e) { throw new SVNClientException(e); } return (CmdLineLogMessage[]) logMessages.toArray(new CmdLineLogMessage[logMessages.size()]); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLogMessage#getChangedPaths() */ public ISVNLogMessageChangePath[] getChangedPaths() { return logMessageChangePaths; } public ISVNLogMessage[] getChildMessages() { // TODO Auto-generated method stub return null; } public long getNumberOfChildren() { // TODO Auto-generated method stub return 0; } public long getTimeMicros() { // TODO Auto-generated method stub return 0; } public long getTimeMillis() { // TODO Auto-generated method stub return 0; } public void addChild(ISVNLogMessage msg) { // TODO Auto-generated method stub } public boolean hasChildren() { // TODO Auto-generated method stub return false; } } CmdLineNotificationHandler.java000066400000000000000000000035331203563747500403410ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.util.Iterator; import java.util.StringTokenizer; import org.tigris.subversion.svnclientadapter.ISVNNotifyListener; import org.tigris.subversion.svnclientadapter.SVNNotificationHandler; /** * Command line specific extension to generic notification handler * * @author Cédric Chabanois (cchabanois@ifrance.com) */ public class CmdLineNotificationHandler extends SVNNotificationHandler { /** * Log the supplied command line exception as Error * @param e an exception to log */ public void logException(CmdLineException e) { StringTokenizer st = new StringTokenizer(e.getMessage(), Helper.NEWLINE); while (st.hasMoreTokens()) { String line = st.nextToken(); for (Iterator it = notifylisteners.iterator(); it.hasNext();) { ISVNNotifyListener listener = (ISVNNotifyListener) it.next(); listener.logError(line); } } } } CmdLineNotify.java000066400000000000000000000056531203563747500356720ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; /** * Subversion notification interface. * * Implement this interface and implement the onNotify method * to provide a custom notification handler to the Modify * class. * If you need to pass extra information to the notification * handler then just add these to you implementing class */ public interface CmdLineNotify { /** * Handler for Subversion notifications. * * Override this function to allow Subversion to * send notifications * @param path on which action happen * @param action subversion action, see svn_wc_notify_action_t * @param kind node kind of path after action occurred * @param mimeType mime type of path after action occurred * @param contentState state of content after action occurred * @param propState state of properties after action occurred * @param revision revision number after action occurred */ public void onNotify(String path, int action, int kind, String mimeType, int contentState, int propState, long revision); /** * The type of action occuring. * The values are defined in the interface NotifyAction for building reasons. */ public static final class Action implements CmdLineNotifyAction { /** * Returns the textual representation for the action kind * @param action kind of action * @return english text */ public static final String getActionName(int action) { return CmdLineNotifyAction.actionNames[action]; } } /** * The type of notification that is occuring. * The values are defined in the interface NotifyStatus for building reasons. */ public static final class Status implements CmdLineNotifyStatus { /** * Returns the textual representation for the notification type * @param status type of the notification * @return english text */ public static final String getStatusName(int status) { return CmdLineNotifyStatus.statusNames[status]; } } } CmdLineNotifyAction.java000066400000000000000000000102371203563747500370220ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; /** * The type of action triggering the notification */ public interface CmdLineNotifyAction { /** Adding a path to revision control. */ public static final int add = 0; /** Copying a versioned path. */ public static final int copy = 1; /** Deleting a versioned path. */ public static final int delete =2; /** Restoring a missing path from the pristine text-base. */ public static final int restore = 3; /** Reverting a modified path. */ public static final int revert = 4; /** A revert operation has failed. */ public static final int failed_revert = 5; /** Resolving a conflict. */ public static final int resolved = 6; /** Skipping a path. */ public static final int skip = 7; /* The update actions are also used for checkouts, switches, and merges. */ /** Got a delete in an update. */ public static final int update_delete = 8; /** Got an add in an update. */ public static final int update_add = 9; /** Got any other action in an update. */ public static final int update_update = 10; /** The last notification in an update */ public static final int update_completed = 11; /** About to update an external module, use for checkouts and switches too, * end with @c svn_wc_update_completed. */ public static final int update_external = 12; /** The last notification in a status (including status on externals). */ public static final int status_completed = 13; /** Running status on an external module. */ public static final int status_external = 14; /** Committing a modification. */ public static final int commit_modified = 15; /** Committing an addition. */ public static final int commit_added = 16; /** Committing a deletion. */ public static final int commit_deleted = 17; /** Committing a replacement. */ public static final int commit_replaced = 18; /** Transmitting post-fix text-delta data for a file. */ public static final int commit_postfix_txdelta = 19; /** Processed a single revision's blame. */ public static final int blame_revision = 20; /** * @since 1.2 * Locking a path */ public static final int locked = 21; /** * @since 1.2 * Unlocking a path */ public static final int unlocked = 22; /** * @since 1.2 * Failed to lock a path */ public static final int failed_lock = 23; /** * @since 1.2 * Failed to unlock a path */ public static final int failed_unlock = 24; /** * textual representation of the action types */ public static final String[] actionNames = { "add", "copy", "delete", "restore", "revert", "failed revert", "resolved", "skip", "update delete", "update add", "update modified", "update completed", "update external", "status completed", "status external", "sending modified", "sending added ", "sending deleted ", "sending replaced", "transfer", "blame revision processed", "locked", "unlocked", "locking failed", "unlocking failed", }; } CmdLineNotifyStatus.java000066400000000000000000000037761203563747500371020ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; /** * status of the text or the property of the item triggering the notification */ public interface CmdLineNotifyStatus { /** It not applicable*/ public static final int inapplicable = 0; /** Notifier doesn't know or isn't saying. */ public static final int unknown = 1; /** The state did not change. */ public static final int unchanged = 2; /** The item wasn't present. */ public static final int missing = 3; /** An unversioned item obstructed work. */ public static final int obstructed = 4; /** Pristine state was modified. */ public static final int changed = 5; /** Modified state had mods merged in. */ public static final int merged = 6; /** Modified state got conflicting mods. */ public static final int conflicted = 7; /** * the textual represention for the status types */ public static final String[] statusNames = { "inapplicable", "unknown", "unchanged", "missing", "obstructed", "changed", "merged", "conflicted", }; } CmdLineProperty.java000066400000000000000000000045301203563747500362370ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.io.File; import org.tigris.subversion.svnclientadapter.ISVNProperty; import org.tigris.subversion.svnclientadapter.SVNUrl; /** * * @author Philip Schatz (schatz at tigris) */ class CmdLineProperty implements ISVNProperty { private String propName; private String propValue; private File file; private SVNUrl url; private byte[] data; CmdLineProperty(String name, String value, File file, byte[] data) { this.propName = name; this.propValue = value; this.url = null; this.file = file.getAbsoluteFile(); this.data = data; } CmdLineProperty(String name, String value, SVNUrl url, byte[] data) { this.propName = name; this.propValue = value; this.url = url; this.file = null; this.data = data; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNProperty#getName() */ public String getName() { return propName; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNProperty#getValue() */ public String getValue() { return propValue; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNProperty#getFile() */ public File getFile() { return file; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNProperty#getUrl() */ public SVNUrl getUrl() { return url; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNProperty#getData() */ public byte[] getData() { return data; } } CmdLineRemoteDirEntry.java000066400000000000000000000146761203563747500373430ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.io.ByteArrayInputStream; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import javax.xml.parsers.DocumentBuilderFactory; import org.tigris.subversion.svnclientadapter.ISVNDirEntry; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNRevision.Number; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; /** *

* Implements a DirEntry on a remote location using the * "svn list" command.

* * @author Philip Schatz (schatz at tigris) */ class CmdLineRemoteDirEntry extends CmdLineXmlCommand implements ISVNDirEntry { private String path; private SVNRevision.Number revision; private SVNNodeKind nodeKind; private String lastCommitAuthor; private Date lastChangedDate; private long size; /** * @param path * @param revision * @param size * @param author * @param date * @param kind */ protected CmdLineRemoteDirEntry(String path, Number revision, long size, String author, Date date, SVNNodeKind kind ) { super(); lastCommitAuthor = author; lastChangedDate = date; nodeKind = kind; this.path = path; this.revision = revision; this.size = size; } /** * creates CmdLineRemoteDirEntries from a xml string (see svn list --xml) * @param cmdLineResults * @return CmdLineRemoteDirEntry[] array created from the supplied xml * @throws SVNClientException */ public static CmdLineRemoteDirEntry[] createDirEntries(byte[] cmdLineResults) throws SVNClientException { Collection logMessages = new ArrayList(); try { // Create a builder factory DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); // Create the builder and parse the file InputSource source = new InputSource(new ByteArrayInputStream(cmdLineResults)); Document doc = factory.newDocumentBuilder().parse(source); // This is the XML we need to parse // // // // // svnClientAdapter.jar // 8199 // // cchab // 2004-01-31T16:44:06.761532Z // // // // NodeList nodes = doc.getElementsByTagName("entry"); for(int i = 0; i < nodes.getLength(); i++) { Node logEntry = nodes.item(i); String kindName = logEntry.getAttributes().getNamedItem("kind").getNodeValue(); Element nameNode = getFirstNamedElement(logEntry, "name"); if (nameNode == null) throw new Exception("'name' tag expected under 'entry'"); String name = nameNode.getFirstChild().getNodeValue(); long size = 0; Element sizeNode = null; if ("file".equals(kindName)) { sizeNode = getNextNamedElement(nameNode, "size"); if (sizeNode == null) throw new Exception("'size' tag expected under 'entry'"); size = Long.parseLong(sizeNode.getFirstChild().getNodeValue()); } else { sizeNode = nameNode; } Element commitNode = getNextNamedElement(sizeNode, "commit"); if (commitNode == null) throw new Exception("'commit' tag expected under 'entry'"); Node revisionAttribute = commitNode.getAttributes().getNamedItem("revision"); SVNRevision.Number rev = Helper.toRevNum(revisionAttribute.getNodeValue()); Element authorNode = getFirstNamedElement(commitNode, "author"); String author = null; if (authorNode != null) { author = authorNode.getFirstChild().getNodeValue(); } Element dateNode = getNextNamedElement(authorNode, "date"); Date date = null; if (dateNode != null) { date = Helper.convertXMLDate(dateNode.getFirstChild().getNodeValue()); } SVNNodeKind kind = SVNNodeKind.UNKNOWN; if ("file".equals(kindName)) { kind = SVNNodeKind.FILE; } else if ("dir".equals(kindName)) { kind = SVNNodeKind.DIR; } CmdLineRemoteDirEntry entry = new CmdLineRemoteDirEntry(name, rev, size, author, date, kind); logMessages.add(entry); } } catch (Exception e) { throw new SVNClientException(e); } return (CmdLineRemoteDirEntry[]) logMessages.toArray(new CmdLineRemoteDirEntry[logMessages.size()]); } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNDirEntry#getHasProps() */ public boolean getHasProps() { //TODO unhardcode this return false; } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNDirEntry#getNodeKind() */ public SVNNodeKind getNodeKind() { return nodeKind; } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNDirEntry#getLastChangedRevision() */ public SVNRevision.Number getLastChangedRevision() { return revision; } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNDirEntry#getLastChangedDate() */ public Date getLastChangedDate() { return lastChangedDate; } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNDirEntry#getLastCommitAuthor() */ public String getLastCommitAuthor() { return lastCommitAuthor; } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNDirEntry#getPath() */ public String getPath() { return path; } public long getSize() { return size; } } CmdLineRemoteDirEntryWithLock.java000066400000000000000000000011721203563747500407730ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandlinepackage org.tigris.subversion.svnclientadapter.commandline; import org.tigris.subversion.svnclientadapter.ISVNDirEntry; import org.tigris.subversion.svnclientadapter.ISVNDirEntryWithLock; import org.tigris.subversion.svnclientadapter.ISVNLock; public class CmdLineRemoteDirEntryWithLock implements ISVNDirEntryWithLock { private ISVNDirEntry dirEntry; private ISVNLock lock; public CmdLineRemoteDirEntryWithLock(ISVNDirEntry dirEntry, ISVNLock lock) { super(); this.dirEntry = dirEntry; this.lock = lock; } public ISVNDirEntry getDirEntry() { return dirEntry; } public ISVNLock getLock() { return lock; } } CmdLineStatusComposite.java000066400000000000000000000153341203563747500375650ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.io.File; import java.util.Date; import org.tigris.subversion.svnclientadapter.ISVNStatus; import org.tigris.subversion.svnclientadapter.SVNConflictDescriptor; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.SVNRevision.Number; /** *

* Implements a ISVNStatus using "svn status" and "svn info".

* * @author Philip Schatz (schatz at tigris) * @author Cédric Chabanois (cchabanois at no-log.org) * @author Daniel Rall */ class CmdLineStatusComposite implements ISVNStatus { private CmdLineStatusPart statusPart; private CmdLineInfoPart infoPart; /** *

* Creates a new status *

* Don't use this constructor if statusPart is null : use CmdLineStatusUnversioned instead * @param statusLinePart Generated from "svn status" * @param infoLinePart Generated from "svn info" */ CmdLineStatusComposite(CmdLineStatusPart statusPart, CmdLineInfoPart infoPart) { this.statusPart = statusPart; this.infoPart = infoPart; } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientStatus#getTextStatus() */ public SVNStatusKind getTextStatus() { return statusPart.getTextStatus(); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getPropStatus() */ public SVNStatusKind getPropStatus() { return statusPart.getPropStatus(); } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientStatus#getUrlCopiedFrom() */ public SVNUrl getUrlCopiedFrom() { return infoPart.getCopyUrl(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLastChangedDate() */ public Date getLastChangedDate() { return infoPart.getLastChangedDate(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLastChangedRevision() */ public Number getLastChangedRevision() { return infoPart.getLastChangedRevision(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLastCommitAuthor() */ public String getLastCommitAuthor() { return infoPart.getLastCommitAuthor(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getNodeKind() */ public SVNNodeKind getNodeKind() { return infoPart.getNodeKind(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getPath() */ public String getPath() { return (infoPart != null) ? infoPart.getPath() : statusPart.getPath(); } /** * @return The absolute path to this item. */ public File getFile() { return statusPart.getFile(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getRevision() */ public Number getRevision() { return infoPart.getRevision(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getUrl() */ public SVNUrl getUrl() { return infoPart.getUrl(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getUrlString() */ public String getUrlString() { return infoPart.getUrlString(); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getRepositoryTextStatus() */ public SVNStatusKind getRepositoryTextStatus() { return statusPart.getRepositoryTextStatus(); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getRepositoryPropStatus() */ public SVNStatusKind getRepositoryPropStatus() { return statusPart.getRepositoryPropStatus(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getConflictNew() */ public File getConflictNew() { return infoPart.getConflictNew(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getConflictOld() */ public File getConflictOld() { return infoPart.getConflictOld(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getConflictWorking() */ public File getConflictWorking() { return infoPart.getConflictWorking(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#isCopied() */ public boolean isCopied() { return statusPart.isCopied(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#isWcLocked() */ public boolean isWcLocked() { return statusPart.isWcLocked(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#isSwitched() */ public boolean isSwitched() { return statusPart.isSwitched(); } /* * (non-Javadoc) * * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLockCreationDate() */ public Date getLockCreationDate() { return infoPart.getLockCreationDate(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLockOwner() */ public String getLockOwner() { return infoPart.getLockOwner(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLockComment() */ public String getLockComment() { return infoPart.getLockComment(); } /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { return statusPart.getPath() + " T: " + statusPart.getTextStatus() + " P: " + statusPart.getPropStatus(); } public SVNConflictDescriptor getConflictDescriptor() { // TODO Auto-generated method stub return null; } public boolean hasTreeConflict() { // TODO Auto-generated method stub return false; } public boolean isFileExternal() { // TODO Auto-generated method stub return false; } } CmdLineStatusFromXml.java000066400000000000000000000336241203563747500372110ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.io.ByteArrayInputStream; import java.io.File; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import javax.xml.parsers.DocumentBuilderFactory; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; public class CmdLineStatusFromXml extends CmdLineXmlCommand { private SVNRevision.Number lastChangedRevision; private Date lastChangedDate; private String lastCommitAuthor; private SVNStatusKind textStatus; private SVNStatusKind repositoryTextStatus; private SVNStatusKind propStatus; private SVNStatusKind repositoryPropStatus; private SVNRevision.Number revision; private String path; private boolean copied; private boolean wcLocked; private boolean switched; private File conflictNew; private File conflictOld; private File conflictWorking; private String lockOwner; private Date lockCreationDate; private String lockComment; protected CmdLineStatusFromXml(String path) { super(); this.path = path; } /** * @return Returns the conflictNew. */ public File getConflictNew() { return conflictNew; } /** * @return Returns the conflictOld. */ public File getConflictOld() { return conflictOld; } /** * @return Returns the conflictWorking. */ public File getConflictWorking() { return conflictWorking; } /** * @return Returns the copied. */ public boolean isCopied() { return copied; } /** * @return Returns the wcLocked. */ public boolean isWcLocked() { return wcLocked; } /** * @return Returns the switched. */ public boolean isSwitched() { return switched; } /** * @return Returns the file. */ public File getFile() { return new File(getPath()).getAbsoluteFile(); } /** * @return Returns the lastCommitAuthor. */ public String getLastCommitAuthor() { return lastCommitAuthor; } /** * @return Returns the lastChangedDate. */ public Date getLastChangedDate() { return lastChangedDate; } /** * @return Returns the lastChangedRevision. */ public SVNRevision.Number getLastChangedRevision() { return lastChangedRevision; } /** * @return Returns the lockComment. */ public String getLockComment() { return lockComment; } /** * @return Returns the lockCreationDate. */ public Date getLockCreationDate() { return lockCreationDate; } /** * @return Returns the lockOwner. */ public String getLockOwner() { return lockOwner; } /** * @return Returns the path. */ public String getPath() { return path; } /** * @return Returns the propStatus. */ public SVNStatusKind getPropStatus() { return propStatus; } /** * @return Returns the repositoryPropStatus. */ public SVNStatusKind getRepositoryPropStatus() { return repositoryPropStatus; } /** * @return Returns the repositoryTextStatus. */ public SVNStatusKind getRepositoryTextStatus() { return repositoryTextStatus; } /** * @return Returns the revision. */ public SVNRevision.Number getRevision() { return revision; } /** * @return Returns the textStatus. */ public SVNStatusKind getTextStatus() { return textStatus; } /** * @param conflictNew The conflictNew to set. */ protected void setConflictNew(File conflictNew) { this.conflictNew = conflictNew; } /** * @param conflictOld The conflictOld to set. */ protected void setConflictOld(File conflictOld) { this.conflictOld = conflictOld; } /** * @param conflictWorking The conflictWorking to set. */ protected void setConflictWorking(File conflictWorking) { this.conflictWorking = conflictWorking; } /** * @param copied The copied to set. */ protected void setCopied(boolean copied) { this.copied = copied; } /** * @param wcLocked The wcLocked to set. */ protected void setWcLocked(boolean wcLocked) { this.wcLocked = wcLocked; } /** * @param switched The switched to set. */ protected void setSwitched(boolean switched) { this.switched = switched; } /** * @param lastCommitAuthor The lastCommitAuthor to set. */ protected void setLastCommitAuthor(String lastCommitAuthor) { this.lastCommitAuthor = lastCommitAuthor; } /** * @param lastChangedDate The lastChangedDate to set. */ protected void setLastChangedDate(Date lastChangedDate) { this.lastChangedDate = lastChangedDate; } /** * @param lastChangedRevision The lastChangedRevision to set. */ protected void setLastChangedRevision(SVNRevision.Number lastChangedRevision) { this.lastChangedRevision = lastChangedRevision; } /** * @param lockComment The lockComment to set. */ protected void setLockComment(String lockComment) { this.lockComment = lockComment; } /** * @param lockCreationDate The lockCreationDate to set. */ protected void setLockCreationDate(Date lockCreationDate) { this.lockCreationDate = lockCreationDate; } /** * @param lockOwner The lockOwner to set. */ protected void setLockOwner(String lockOwner) { this.lockOwner = lockOwner; } /** * @param path The path to set. */ protected void setPath(String path) { this.path = path; } /** * @param propStatus The propStatus to set. */ protected void setPropStatus(SVNStatusKind propStatus) { this.propStatus = propStatus; } /** * @param repositoryPropStatus The repositoryPropStatus to set. */ protected void setRepositoryPropStatus(SVNStatusKind repositoryPropStatus) { this.repositoryPropStatus = repositoryPropStatus; } /** * @param repositoryTextStatus The repositoryTextStatus to set. */ protected void setRepositoryTextStatus(SVNStatusKind repositoryTextStatus) { this.repositoryTextStatus = repositoryTextStatus; } /** * @param revision The revision to set. */ protected void setRevision(SVNRevision.Number revision) { this.revision = revision; } /** * @param textStatus The textStatus to set. */ protected void setTextStatus(SVNStatusKind textStatus) { this.textStatus = textStatus; } /** * creates CmdLineStatus(es) from a xml string (see svn status --xml) * @param cmdLineResults * @return CmdLineStatusFromXml[] array created from the supplied xml * @throws CmdLineException */ public static CmdLineStatusFromXml[] createStatuses(byte[] cmdLineResults) throws CmdLineException { Collection statuses = new ArrayList(); try { // Create a builder factory DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); // Create the builder and parse the file InputSource source = new InputSource(new ByteArrayInputStream(cmdLineResults)); Document doc = factory.newDocumentBuilder().parse(source); // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // NodeList nodes = doc.getElementsByTagName("entry"); for(int i = 0; i < nodes.getLength(); i++) { Node statusEntry = nodes.item(i); String entryPath = statusEntry.getAttributes().getNamedItem("path").getNodeValue(); CmdLineStatusFromXml status = new CmdLineStatusFromXml(entryPath); Element wcStatusNode = getFirstNamedElement(statusEntry, "wc-status"); if (wcStatusNode == null) throw new Exception("'wc-status' tag expected under 'entry'"); Node wcItemStatusAttr = wcStatusNode.getAttributes().getNamedItem("item"); status.setTextStatus(SVNStatusKind.fromString(wcItemStatusAttr.getNodeValue())); Node wcPpropStatusAttr = wcStatusNode.getAttributes().getNamedItem("props"); status.setPropStatus(SVNStatusKind.fromString(wcPpropStatusAttr.getNodeValue())); Node wcRevisionAttribute = wcStatusNode.getAttributes().getNamedItem("revision"); if (wcRevisionAttribute != null) { status.setRevision(Helper.toRevNum(wcRevisionAttribute.getNodeValue())); } Node wcLockedAttr = wcStatusNode.getAttributes().getNamedItem("wc-locked"); status.setWcLocked((wcLockedAttr != null) && "true".equals(wcLockedAttr.getNodeValue())); Node copiedAttr = wcStatusNode.getAttributes().getNamedItem("copied"); status.setCopied((copiedAttr != null) && "true".equals(copiedAttr.getNodeValue())); Node switchedAttr = wcStatusNode.getAttributes().getNamedItem("switched"); status.setSwitched((switchedAttr != null) && "true".equals(switchedAttr.getNodeValue())); Element commitNode = getFirstNamedElement(wcStatusNode, "commit"); if (commitNode != null) { Node commitRevisionAttribute = commitNode.getAttributes().getNamedItem("revision"); status.setLastChangedRevision(Helper.toRevNum(commitRevisionAttribute.getNodeValue())); Element authorNode = getFirstNamedElement(commitNode, "author"); if (authorNode != null) { status.setLastCommitAuthor(authorNode.getFirstChild().getNodeValue()); } Element dateNode = getNextNamedElement(authorNode, "date"); if (dateNode != null) { status.setLastChangedDate(Helper.convertXMLDate(dateNode.getFirstChild().getNodeValue())); } } Element lockNode = getNextNamedElement(commitNode, "lock"); if (lockNode != null) { Element tokenNode = getFirstNamedElement(lockNode, "token"); if (tokenNode == null) throw new Exception("'token' tag expected under 'lock'"); // String token = authorNode.getFirstChild().getNodeValue(); Element ownerNode = getNextNamedElement(lockNode, "owner"); if (ownerNode == null) throw new Exception("'owner' tag expected under 'lock'"); status.setLockOwner(ownerNode.getFirstChild().getNodeValue()); Element lockCommentNode = getNextNamedElement(ownerNode, "comment"); status.setLockComment((lockCommentNode != null) ? lockCommentNode.getFirstChild().getNodeValue() : null); Element lockCreatedNode = getNextNamedElement(lockCommentNode, "created"); status.setLockCreationDate(Helper.convertXMLDate((lockCreatedNode != null) ? lockCreatedNode.getFirstChild().getNodeValue() : null)); // Element lockExpiresNode = getNextNamedElement(lockCreatedNode, "expires"); // String lockExpires = (lockExpiresNode != null) ? lockExpiresNode.getFirstChild().getNodeValue() : null; } Element reposStatusNode = getNextNamedElement(wcStatusNode, "repos-status"); if (reposStatusNode != null) { Node reposItemStatusAttr = reposStatusNode.getAttributes().getNamedItem("item"); status.setRepositoryTextStatus(SVNStatusKind.fromString(reposItemStatusAttr.getNodeValue())); Node reposPropStatusAttr = reposStatusNode.getAttributes().getNamedItem("props"); status.setRepositoryPropStatus(SVNStatusKind.fromString(reposPropStatusAttr.getNodeValue())); } statuses.add(status); } } catch (Exception e) { throw new CmdLineException(e); } return (CmdLineStatusFromXml[]) statuses.toArray(new CmdLineStatusFromXml[statuses.size()]); } } CmdLineStatusPart.java000066400000000000000000000160071203563747500365270ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.io.File; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.utils.SVNStatusUtils; abstract class CmdLineStatusPart { protected SVNStatusKind textStatus; protected SVNStatusKind propStatus; protected CmdLineStatusPart(SVNStatusKind textStatus, SVNStatusKind propStatus) { super(); this.textStatus = textStatus; this.propStatus = propStatus; } public boolean isManaged() { return SVNStatusUtils.isManaged(textStatus); } /** * @return Whether this item was copied from another location. */ public abstract boolean isCopied(); /** * @return Whether this item's wc directory is locked. */ public abstract boolean isWcLocked(); /** * @return Whether this item was switched. */ public abstract boolean isSwitched(); /** * @return true if the resource has a remote counter-part */ public boolean hasRemote() { return (isManaged() && getTextStatus() != SVNStatusKind.ADDED); } /** * @return The status of the item itself (e.g. directory or file). */ public SVNStatusKind getTextStatus() { return textStatus; } /* package */ void setTextStatus(SVNStatusKind textSt) { this.textStatus = textSt; } public SVNStatusKind getPropStatus() { return propStatus; } public abstract SVNStatusKind getRepositoryTextStatus(); public abstract SVNStatusKind getRepositoryPropStatus(); /** * @return The absolute path to this item. */ public abstract File getFile(); public abstract String getPath(); static class CmdLineStatusPartFromStdout extends CmdLineStatusPart { public static final int STATUS_FILE_WIDTH = 40; protected String path; protected File file; protected char history; protected boolean wcLocked; protected boolean switched; /** * here are some statusLine samples : * A 0 ? ? added.txt * I ignored.txt * Note that there is not output for files that do not exist and are not deleted */ CmdLineStatusPartFromStdout(String statusLine) { super(getTextStatus(statusLine.charAt(0)), getPropStatus(statusLine.charAt(1))); wcLocked = getWcLockStatus(statusLine.charAt(2)); history = statusLine.charAt(3); switched = getSwitchedStatus(statusLine.charAt(4)); path = statusLine.substring(STATUS_FILE_WIDTH).trim(); file = new File(path); } /** * @return Whether this item was copied from another location. */ public boolean isCopied() { return (history == '+'); } /** * @return Whether this item's wc directory is locked. */ public boolean isWcLocked() { return wcLocked; } /** * @return Whether this item was switched relative to its parent */ public boolean isSwitched() { return switched; } /** * @return The status of the item itself (e.g. directory or file). */ private static SVNStatusKind getTextStatus(char statusChar) { switch (statusChar) { case ' ' : // none or normal return SVNStatusKind.NORMAL; case 'A' : return SVNStatusKind.ADDED; case '!' : // missing or incomplete return SVNStatusKind.MISSING; case 'D' : return SVNStatusKind.DELETED; case 'R' : return SVNStatusKind.REPLACED; case 'M' : return SVNStatusKind.MODIFIED; case 'G' : return SVNStatusKind.MERGED; case 'C' : return SVNStatusKind.CONFLICTED; case '~' : return SVNStatusKind.OBSTRUCTED; case 'I' : return SVNStatusKind.IGNORED; case 'X' : return SVNStatusKind.EXTERNAL; case '?' : return SVNStatusKind.UNVERSIONED; default : return SVNStatusKind.NONE; } } private static SVNStatusKind getPropStatus(char statusChar) { switch (statusChar) { case ' ' : // no modifications return SVNStatusKind.NONE; case 'C' : return SVNStatusKind.CONFLICTED; case 'M' : return SVNStatusKind.MODIFIED; default : return SVNStatusKind.NORMAL; } } private static boolean getWcLockStatus(char statusChar) { switch (statusChar) { case ' ': // no lock return false; case 'L': return true; default: return false; } } private static boolean getSwitchedStatus(char statusChar) { switch (statusChar) { case ' ': // no switch return false; case 'S': return true; default: return false; } } /** * @return The absolute path to this item. */ public File getFile() { return file.getAbsoluteFile(); } public String getPath() { return path; } public SVNStatusKind getRepositoryTextStatus() { //Not available from cmdLine's stdout return null; } public SVNStatusKind getRepositoryPropStatus() { //Not available from cmdLine's stdout return null; } } static class CmdLineStatusPartFromXml extends CmdLineStatusPart { private CmdLineStatusFromXml status; private CmdLineStatusPartFromXml(CmdLineStatusFromXml status) { super(status.getTextStatus(), status.getPropStatus()); this.status = status; } public static CmdLineStatusPartFromXml[] createStatusParts(byte[] cmdLineResults) throws CmdLineException { CmdLineStatusFromXml[] statuses = CmdLineStatusFromXml.createStatuses(cmdLineResults); CmdLineStatusPartFromXml[] result = new CmdLineStatusPartFromXml[statuses.length]; for (int i = 0; i < statuses.length; i++) { result[i] = new CmdLineStatusPartFromXml(statuses[i]); } return result; } public File getFile() { return status.getFile(); } public boolean isCopied() { return status.isCopied(); } public boolean isWcLocked() { return status.isWcLocked(); } public boolean isSwitched() { return status.isSwitched(); } public SVNStatusKind getRepositoryTextStatus() { return status.getRepositoryTextStatus(); } public SVNStatusKind getRepositoryPropStatus() { return status.getRepositoryPropStatus(); } public String getPath() { return status.getPath(); } } } CmdLineStatuses.java000066400000000000000000000137631203563747500362360ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import org.tigris.subversion.svnclientadapter.ISVNStatus; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.SVNStatusUnversioned; /** * Digests status and info information from * the command-line. * * @author Cédric Chabanois (cchabanois at no-log.org) * @author Daniel Rall */ public class CmdLineStatuses { private CmdLineInfoPart[] cmdLineInfoParts; private CmdLineStatusPart[] cmdLineStatusParts; private ISVNStatus[] cmdLineStatuses; CmdLineStatuses(String infoLines, CmdLineStatusPart[] cmdLineStatusParts) { this.cmdLineStatusParts = cmdLineStatusParts; if (infoLines.length() == 0) { cmdLineInfoParts = new CmdLineInfoPart[0]; } else { String[] parts = CmdLineInfoPart.parseInfoParts(infoLines); cmdLineInfoParts = new CmdLineInfoPart[parts.length]; for (int i = 0; i < parts.length;i++) { cmdLineInfoParts[i] = new CmdLineInfoPart(parts[i]); } } this.cmdLineStatuses = buildStatuses(); } CmdLineStatuses(CmdLineInfoPart[] cmdLineInfoParts, CmdLineStatusPart[] cmdLineStatusParts) { this.cmdLineInfoParts = cmdLineInfoParts; this.cmdLineStatusParts = cmdLineStatusParts; this.cmdLineStatuses = buildStatuses(); } /** * Procures status objects for the {@link #cmdLineStatuses} * instance field. */ private ISVNStatus[] buildStatuses() { processExternalStatuses(cmdLineStatusParts); List statuses = new LinkedList(); for (int i = 0; i < cmdLineStatusParts.length; i++) { CmdLineStatusPart cmdLineStatusPart = cmdLineStatusParts[i]; File absPath = cmdLineStatusPart.getFile(); if (cmdLineStatusPart == null || !cmdLineStatusPart.isManaged()) { boolean isIgnored = false; if (cmdLineStatusPart != null) { isIgnored = SVNStatusKind.IGNORED.equals(cmdLineStatusPart.getTextStatus()); } statuses.add(new SVNStatusUnversioned(absPath, isIgnored)); } else { CmdLineInfoPart cmdLineInfoPart = getCorrespondingInfoPart(absPath); if (cmdLineInfoPart != null) { statuses.add(new CmdLineStatusComposite(cmdLineStatusPart, cmdLineInfoPart)); } } } return (ISVNStatus []) statuses.toArray(new ISVNStatus[statuses.size()]); } /** * @param absPath The absolute path to an item which we have a * status for. * @return The info corresponding to the specified path, or * null if not found. */ private CmdLineInfoPart getCorrespondingInfoPart(File absPath) { for (int i = 0; i < cmdLineInfoParts.length; i++) { if (absPath.equals(cmdLineInfoParts[i].getFile())) { return cmdLineInfoParts[i]; } } return null; } /** * Post-process svn:externals statuses. * commandline answer two sort of statuses on externals: * - when ignoreExternals is set to true during call to status(), * the returned status has textStatus set to EXTERNAL, but the url is null.
* - when ignoreExternals is set to false during call to status(), * besides the "external + null" status, the second status with url and all fields is returned too, * but this one has textStatus NORMAL. * * This methods unifies both statuses to be complete and has textStatus external. * In case the first sort (when ignoreExternals true), the url is retrieved by call the info() */ protected CmdLineStatusPart[] processExternalStatuses(CmdLineStatusPart[] statuses) { //Collect indexes of external statuses List externalStatusesIndexes = new ArrayList(); for (int i = 0; i < statuses.length; i++) { if (SVNStatusKind.EXTERNAL.equals(statuses[i].getTextStatus())) { externalStatusesIndexes.add(new Integer(i)); } } if (externalStatusesIndexes.isEmpty()) { return statuses; } //Check the "second" externals so their textStatus is actually external for (Iterator iter = externalStatusesIndexes.iterator(); iter.hasNext();) { int index = ((Integer) iter.next()).intValue(); CmdLineStatusPart aStatus = statuses[index]; for (int i = 0; i < statuses.length; i++) { if ((statuses[i].getPath() != null) && (statuses[i].getPath().equals(aStatus.getPath()))) { statuses[i].setTextStatus(SVNStatusKind.EXTERNAL); } } } return statuses; } public ISVNStatus get(int i) { return cmdLineStatuses[i]; } public int size() { return cmdLineStatuses.length; } public ISVNStatus[] toArray() { return cmdLineStatuses; } } CmdLineXmlCommand.java000066400000000000000000000035501203563747500364530ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import org.w3c.dom.Element; import org.w3c.dom.Node; public class CmdLineXmlCommand { /** * Not exactly XPath, but finds a named node * @param parent * @param elementName * @return a node with the given name */ protected static Element getFirstNamedElement(Node parent, String elementName) { if (parent == null) return null; return findNamedElementSibling(parent.getFirstChild(), elementName); } protected static Element getNextNamedElement(Node foundNode, String elementName) { if (foundNode == null) return null; return findNamedElementSibling(foundNode.getNextSibling(), elementName); } private static Element findNamedElementSibling(Node sibling, String elementName) { if (sibling == null) return null; while (sibling != null) { if (sibling.getNodeType() == Node.ELEMENT_NODE && sibling.getNodeName().equals(elementName)) return (Element)sibling; sibling = sibling.getNextSibling(); } return null; } } CommandLine.java000066400000000000000000000410201203563747500353400ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; /** * Common superclass for both SvnCommandLine and SvnAdminCommandLine * * @author Philip Schatz (schatz at tigris) * @author Cédric Chabanois (cchabanois at no-log.org) * @author Daniel Rall */ abstract class CommandLine { protected String commandName; protected CmdLineNotificationHandler notificationHandler; protected Process process; protected CommandLine(String commandName, CmdLineNotificationHandler notificationHandler) { this.commandName = commandName; this.notificationHandler = notificationHandler; } String version() throws CmdLineException { CmdArguments args = new CmdArguments(); args.add("--version"); return execString(args,false); } /** * Executes the given svn command and returns the corresponding * Process object. * * @param svnArguments The command-line arguments to execute. */ private Process execProcess(CmdArguments svnArguments) throws CmdLineException { // We add "svn" or "svnadmin" to the arguments (as // appropriate), and convert it to an array of strings. int svnArgsLen = svnArguments.size(); String[] cmdline = new String[svnArgsLen + 1]; cmdline[0] = commandName; StringBuffer svnCommand = new StringBuffer(); boolean nextIsPassword = false; for (int i = 0; i < svnArgsLen; i++) { if (i != 0) svnCommand.append(' '); Object arg = svnArguments.get(i); if (arg != null) arg = arg.toString(); if ("".equals(arg)) { arg = "\"\""; } if (nextIsPassword) { // Avoid showing the password on the console. svnCommand.append("*******"); nextIsPassword = false; } else { svnCommand.append(arg); } if ("--password".equals(arg)) { nextIsPassword = true; } // Regardless of the data type passed in via svnArguments, // at this point we expect to have a String object. cmdline[i + 1] = (String) arg; } notificationHandler.logCommandLine(svnCommand.toString()); // Run the command, and return the associated Process object. try { return process = Runtime.getRuntime().exec(cmdline, getEnvironmentVariables()); } catch (IOException e) { throw new CmdLineException(e); } } /** * Get environment variables to be set when invoking the command-line. * Includes LANG and LC_ALL so Subversion's output is not localized. * Systemroot is required on windows platform. * Without this variable present, the windows' DNS resolver does not work. * APR_ICONV_PATH is required on windows platform for UTF-8 translation. * The PATH is there, well, just to be sure ;-) */ protected String[] getEnvironmentVariables() { final String path = CmdLineClientAdapter.getEnvironmentVariable("PATH"); final String systemRoot = CmdLineClientAdapter.getEnvironmentVariable("SystemRoot"); final String aprIconv = CmdLineClientAdapter.getEnvironmentVariable("APR_ICONV_PATH"); int i = 3; if (path != null) i++; if (systemRoot != null) i++; if (aprIconv != null) i++; String[] lcVars = getLocaleVariables(); String[] env = new String[i + lcVars.length]; i = 0; //Clear the LC_ALL, we're going to override the LC_MESSAGES and LC_TIME env[i] = "LC_ALL="; i++; //Set the LC_MESSAGES to "C" to avoid translated svn output. (We're parsing the english one) env[i] = "LC_MESSAGES=C"; i++; env[i] = "LC_TIME=C"; i++; if (path != null) { env[i] = "PATH=" + path; i++; } if (systemRoot != null) { env[i] = "SystemRoot=" + systemRoot; i++; } if (aprIconv != null) { env[i] = "APR_ICONV_PATH=" + aprIconv; i++; } //Add the remaining LC vars for (int j = 0; j < lcVars.length; j++) { env[i] = lcVars[j]; i++; } return env; } private String[] getLocaleVariables() { String LC_ALL = CmdLineClientAdapter.getEnvironmentVariable("LC_ALL"); if ((LC_ALL == null) || (LC_ALL.length() == 0)) { LC_ALL = CmdLineClientAdapter.getEnvironmentVariable("LANG"); if (LC_ALL == null) { LC_ALL=""; } } final String[] lcVarNames = new String[] { "LC_CTYPE", "LC_NUMERIC", "LC_COLLATE", "LC_MONETARY", "LC_PAPER", "LC_NAME", "LC_ADDRESS", "LC_TELEPHONE", "LC_MEASUREMENT", "LC_IDENTIFICATION" }; List variables = new ArrayList(lcVarNames.length); for (int i = 0; i < lcVarNames.length; i++) { String varValue = CmdLineClientAdapter.getEnvironmentVariable(lcVarNames[i]); variables.add(lcVarNames[i] + "=" + ((varValue != null) ? varValue : LC_ALL)); } return (String[]) variables.toArray(new String[variables.size()]); } /** * Pumps the output from both provided streams, blocking until * complete. * * @param proc * @param outPumper The process output stream. * @param outPumper The process error stream. */ private void pumpProcessStreams(Process proc, StreamPumper outPumper, StreamPumper errPumper) { new Thread(outPumper).start(); new Thread(errPumper).start(); try { outPumper.waitFor(); errPumper.waitFor(); } catch (InterruptedException ignored) { notificationHandler.logError("Command output processing interrupted !"); } finally { try { proc.getInputStream().close(); proc.getOutputStream().close(); proc.getErrorStream().close(); } catch (IOException ioex) { //Just ignore. Exception when closing the stream. } } } /** * Runs the process and returns the results. * * @param svnArguments The command-line arguments to execute. * @param coalesceLines * @return Any output returned from execution of the command-line. */ protected String execString(CmdArguments svnArguments, boolean coalesceLines) throws CmdLineException { Process proc = execProcess(svnArguments); StreamPumper outPumper = new CharacterStreamPumper(proc.getInputStream(), coalesceLines); StreamPumper errPumper = new CharacterStreamPumper(proc.getErrorStream(), false); pumpProcessStreams(proc, outPumper, errPumper); try { String errMessage = errPumper.toString(); if (errMessage.length() > 0) { throw new CmdLineException(errMessage); } String outputString = outPumper.toString(); notifyFromSvnOutput(outputString); return outputString; } catch (CmdLineException e) { notificationHandler.logException(e); throw e; } } /** * Runs the process and returns the results. * @param svnArguments The arguments to pass to the command-line * binary. * @param assumeUTF8 Whether the output of the command should be * treated as UTF-8 (as opposed to the JVM's default encoding). * @return String */ protected byte[] execBytes(CmdArguments svnArguments, boolean assumeUTF8) throws CmdLineException { Process proc = execProcess(svnArguments); ByteStreamPumper outPumper = new ByteStreamPumper(proc.getInputStream()); StreamPumper errPumper = new CharacterStreamPumper(proc.getErrorStream(), false); pumpProcessStreams(proc, outPumper, errPumper); try { String errMessage = errPumper.toString(); if (errMessage.length() > 0) { throw new CmdLineException(errMessage); } byte[] bytes = outPumper.getBytes(); String notifyMessage = ""; if (assumeUTF8) { try { notifyMessage = new String(bytes, "UTF-8"); } catch (UnsupportedEncodingException e) { // It is guaranteed to be there! } } else { // This uses the default charset, which is likely // wrong if we are trying to get the bytes, anyway... notifyMessage = new String(bytes); } notifyFromSvnOutput(notifyMessage); return bytes; } catch (CmdLineException e) { notificationHandler.logException(e); throw e; } } /** * runs the command (returns nothing) * @param svnArguments * @throws CmdLineException */ protected void execVoid(CmdArguments svnArguments) throws CmdLineException { execString(svnArguments,false); } //TODO check the deprecation /** * Runs the process and returns the results. * @param svnArguments The arguments to pass to the command-line * binary. * @return the InputStream on commads result. Caller has to close it explicitelly(). * @deprecated this does not sound as a good idea. Check if we're able to live without it. */ protected InputStream execInputStream(CmdArguments svnArguments) throws CmdLineException { Process proc = execProcess(svnArguments); try { proc.getOutputStream().close(); proc.getErrorStream().close(); //InputStream has to be closed by caller ! } catch (IOException ioex) { //Just ignore. Exception when closing the stream. } return proc.getInputStream(); } /** * notify the listeners from the output. This is the default implementation * * @param svnOutput */ protected void notifyFromSvnOutput(String svnOutput) { StringTokenizer st = new StringTokenizer(svnOutput, Helper.NEWLINE); int size = st.countTokens(); //do everything but the last line for (int i = 1; i < size; i++) { notificationHandler.logMessage(st.nextToken()); } //log the last line as the completed message. if (size > 0) notificationHandler.logCompleted(st.nextToken()); } protected void stopProcess() { try { process.getInputStream().close(); process.getOutputStream().close(); process.getErrorStream().close(); } catch (IOException ioex) { //Just ignore. Closing streams. } process.destroy(); } /** * Pulls all the data out of a stream. Inspired by Ant's * StreamPumper (by Robert Field). */ private static abstract class StreamPumper implements Runnable { private boolean finished; /** * Constructor * */ protected StreamPumper() { super(); } /** * Copies data from the input stream to the internal buffer. * Terminates as soon as the input stream is closed, or an * error occurs. */ public void run() { synchronized (this) { // Just in case this object is reused in the future. this.finished = false; } try { pumpStream(); } finally { synchronized (this) { this.finished = true; notify(); } } } /** * Called by {@link #run()} to pull the data out of the * stream. */ protected abstract void pumpStream(); /** * Tells whether the end of the stream has been reached. * @return true is the stream has been exhausted. **/ public synchronized boolean isFinished() { return this.finished; } /** * This method blocks until the stream pumper finishes. * @see #isFinished() * @throws InterruptedException **/ public synchronized void waitFor() throws InterruptedException { while (!isFinished()) { wait(); } } } /** Extracts character data from streams. */ private static class CharacterStreamPumper extends StreamPumper { private BufferedReader reader; private StringBuffer sb = new StringBuffer(); private boolean coalesceLines = false; /** * @param is Input stream from which to read the data. * @param coalesceLines Whether to coalesce lines. */ public CharacterStreamPumper(InputStream is, boolean coalesceLines) { this.reader = new BufferedReader(new InputStreamReader(is)); this.coalesceLines = coalesceLines; } /** * Copies data from the input stream to the internal string * buffer. */ protected void pumpStream() { try { String line; while ((line = this.reader.readLine()) != null) { if (this.coalesceLines) { this.sb.append(line); } else { this.sb.append(line).append(Helper.NEWLINE); } } } catch (IOException ex) { System.err .println("Problem occured during fetching the command output: " + ex.getMessage()); } finally { try { reader.close(); } catch (IOException e) { // Exception during closing the stream. Just ignore. } } } public synchronized String toString() { return this.sb.toString(); } } /** Extracts byte data from streams. */ private static class ByteStreamPumper extends StreamPumper { private InputStream bis; private ByteArrayOutputStream bytes = new ByteArrayOutputStream(); private final static int BUFFER_LENGTH = 1024; private byte[] inputBuffer = new byte[BUFFER_LENGTH]; /** * Create a new stream pumper. * * @param is input stream to read data from */ public ByteStreamPumper(InputStream is) { this.bis = is; } /** * Copies data from the input stream to the string buffer * * Terminates as soon as the input stream is closed or an error occurs. */ protected void pumpStream() { try { int bytesRead; while ((bytesRead = this.bis.read(this.inputBuffer)) != -1) { this.bytes.write(this.inputBuffer, 0, bytesRead); } } catch (IOException ex) { System.err .println("Problem occured during fetching the command output: " + ex.getMessage()); } finally { try { this.bytes.flush(); this.bytes.close(); this.bis.close(); } catch (IOException e) { // Exception during closing the stream. Just ignore. } } } /** * @return A byte array contaning the raw bytes read from the input * stream. */ public synchronized byte[] getBytes() { return bytes.toByteArray(); } } protected static class CmdArguments { private List args = new ArrayList(); protected void add(Object arg) { this.args.add(arg); } protected void addAuthInfo(String user, String pass) { if (user != null && user.length() > 0) { add("--username"); add(user); } if (pass != null && pass.length() > 0) { add("--password"); add(pass); } add("--non-interactive"); } protected void addConfigInfo(String configDir) { if (configDir != null) { add("--config-dir"); add(configDir); } } protected void addLogMessage(String message) { add("--force-log"); add("-m"); add((message != null) ? message : ""); } private int size() { return this.args.size(); } private Object get(int index) { return this.args.get(index); } } } Helper.java000066400000000000000000000046761203563747500344110ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.net.MalformedURLException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNUrl; /** * @author Philip Schatz (schatz at tigris) * @author Daniel Rall */ class Helper { static final String NEWLINE = System.getProperty("line.separator"); private static DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss Z"); // 2003-10-13T12:54:42.957948Z private static DateFormat xmlFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); // Initialize timezone to GMT for xmlFormat static { xmlFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT")); } /** * A non-instantiable class */ private Helper() { //non-instantiable } static SVNUrl toSVNUrl(String url) { try { return new SVNUrl(url); } catch (MalformedURLException e) { return null; } } static SVNRevision.Number toRevNum(String rev) { if (rev == null) return null; try { return new SVNRevision.Number(Long.parseLong(rev)); } catch (NumberFormatException e) { return new SVNRevision.Number(-1); } } static Date toDate(String date) { if (date == null) return null; try { return df.parse(date); } catch (ParseException e1) { return null; } } static Date convertXMLDate(String date) { if (date == null) return null; try { return xmlFormat.parse(date); } catch (ParseException e1) { return null; } } } SvnAdminCommandLine.java000066400000000000000000000033271203563747500370100ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import org.tigris.subversion.svnclientadapter.ISVNNotifyListener; /** * Call svnadmin * * @author Cédric Chabanois (cchabanois at no-log.org) */ public class SvnAdminCommandLine extends CommandLine { //Constructors SvnAdminCommandLine(String svnPath,CmdLineNotificationHandler notificationHandler) { super(svnPath,notificationHandler); } /** * Create a new, empty repository at path * */ void create(String path, String repositoryType) throws CmdLineException { notificationHandler.setCommand(ISVNNotifyListener.Command.CREATE_REPOSITORY); CmdArguments args = new CmdArguments(); args.add("create"); if (repositoryType != null) { // repository type is for svnadmin >= 1.1 args.add("--fs-type"); args.add(repositoryType); } args.add(path); execVoid(args); } } SvnCommandLine.java000066400000000000000000001000311203563747500360250ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.io.InputStream; import org.tigris.subversion.svnclientadapter.ISVNNotifyListener; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.commandline.parser.SvnOutputParser; /** *

* Performs the gruntwork of calling "svn". * Is a bare-bones interface to using the Subversion commandline client.

* * @author Philip Schatz (schatz at tigris) * @author C�dric Chabanois (cchabanois at no-log.org) * @author John M Flinchbaugh (john at hjsoft.com) */ public class SvnCommandLine extends CommandLine { protected String user; protected String pass; protected SvnOutputParser svnOutputParser = new SvnOutputParser(); protected long rev = SVNRevision.SVN_INVALID_REVNUM; protected boolean parseSvnOutput = false; protected String configDir = null; //Constructors SvnCommandLine(String svnPath,CmdLineNotificationHandler notificationHandler) { super(svnPath,notificationHandler); } /** * * @param revision * @return "HEAD" if revision is a null or empty string, return revision otherwise */ protected static String validRev(String revision) { return (revision == null || "".equals(revision)) ? "HEAD" : revision; } /** *

* Sets the username used by this client.

* * @param username The username to use for authentication. */ void setUsername(String username) { user = username; } /** *

* Sets the password used by this client.

* * @param password The password to use for authentication. */ void setPassword(String password) { pass = password; } /** * set the directory from which user configuration files will be read */ void setConfigDirectory(String dir) { configDir = dir; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.commandline.CommandLine#version() */ String version() throws CmdLineException { setCommand(ISVNNotifyListener.Command.UNDEFINED, false); return super.version(); } /** *

* Adds an unversioned file into the repository.

* * @param resource Local path of resource to add. * @param recursive true if this is a directory * and its children should be traversed * recursively. * @param force true if this is a directory that * should be scanned even if it's already added * to the repository */ String add(String path, boolean recursive, boolean force) throws CmdLineException { setCommand(ISVNNotifyListener.Command.ADD, true); CmdArguments args = new CmdArguments(); args.add("add"); if (!recursive) args.add("-N"); if (force) args.add("--force"); args.add(path); return execString(args,false); } /** *

* Output the content of specified file or URL.

* * @param url Either the local path to a file, or URL * to print the contents of. * @return An stream containing the contents of the file. */ InputStream cat(String url, String revision) throws CmdLineException { setCommand(ISVNNotifyListener.Command.CAT, false); CmdArguments args = new CmdArguments(); args.add("cat"); args.add("-r"); args.add(validRev(revision)); args.add(url); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execInputStream(args); } /** *

* Send changes from your working copy to the * repository.

* * @param path The local path to the folder(s)/file(s) * to commit. * @param message The message associated with the * committed resources. * @throws CmdLineException */ String checkin(String[] path, String message, boolean keepLocks) throws CmdLineException { setCommand(ISVNNotifyListener.Command.COMMIT, true); CmdArguments args = new CmdArguments(); args.add("ci"); if (keepLocks) args.add("--no-unlock"); args.addLogMessage(message); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); for (int i = 0; i < path.length;i++) { args.add(path[i]); } return execString(args,false); } /** *

* Recursively clean up the working copy, * removing locks, resuming unfinished operations.

* * @param path The local path to clean up. */ void cleanup(String path) throws CmdLineException { setCommand(ISVNNotifyListener.Command.CLEANUP, true); CmdArguments args = new CmdArguments(); args.add("cleanup"); args.add(path); args.addConfigInfo(this.configDir); execVoid(args); } /** *

* Check out a working copy from a repository.

* * @param url The URL to check out from. * @param destination The local directory to check out to. * @param revision The revision to check out. * Defaults to "HEAD". * @param recursive true if subdirs should be checked out recursively. * @throws CmdLineException */ String checkout(String url, String destination, String revision, boolean recursive) throws CmdLineException { setCommand(ISVNNotifyListener.Command.CHECKOUT, true); CmdArguments args = new CmdArguments(); args.add("co"); args.add("-r"); args.add(validRev(revision)); args.add(url + "@" + validRev(revision)); args.add(destination); if (!recursive) args.add("-N"); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execString(args,false); } /** *

* Duplicate something in working copy or repos, * remembering history.

* *

* src and dest can each be either a working copy (WC) path or URL.

*
*
WC -> WC
*
copy and schedule for addition (with history)
* *
WC -> URL
*
immediately commit a copy of WC to URL
* *
URL -> WC
*
check out URL into WC, schedule for addition
* *
URL -> URL
*
complete server-side copy; used to branch and tag
*
* * @param src Local path or URL to copy from. * @param dest Local path or URL to copy to. * @param message Commit message. * @param revision Optional revision to copy from. * @param makeparents true <=> Create parents first when copying from source url to dest url. */ void copy(String src, String dest, String message, String revision, boolean makeparents) throws CmdLineException { setCommand(ISVNNotifyListener.Command.COPY, true); CmdArguments args = new CmdArguments(); args.add("cp"); if (revision != null) { args.add("-r"); args.add(validRev(revision)); } if (makeparents) { args.add("--parents"); } if (message != null) args.addLogMessage(message); args.add(src); args.add(dest); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); execVoid(args); } /** *

* Duplicate a resource in local file system.

* * @param src Local path to copy from. * @param dest Local destination path. * @throws CmdLineException */ void copy(String src, String dest) throws CmdLineException { setCommand(ISVNNotifyListener.Command.COPY, true); CmdArguments args = new CmdArguments(); args.add("cp"); args.add(src); args.add(dest); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); execVoid(args); } /** *

* Remove files and directories from version control.

* * @param target Local path or URL to remove. * @param message Associated message when deleting from * URL. */ String delete(String[] target, String message, boolean force) throws CmdLineException { setCommand(ISVNNotifyListener.Command.REMOVE, true); CmdArguments args = new CmdArguments(); args.add("rm"); if (message != null) { args.addLogMessage(message); } if (force) { args.add("--force"); } for (int i = 0;i < target.length;i++) { args.add(target[i]); } args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execString(args,false); } /** *

* Display the differences between two paths.

* */ InputStream diff(String oldPath, String oldRev, String newPath, String newRev, boolean recurse, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws CmdLineException { setCommand(ISVNNotifyListener.Command.DIFF, false); CmdArguments args = new CmdArguments(); args.add("diff"); if (newRev != null) { args.add("-r"); if (newRev.equals("WORKING")) { // "WORKING" is not a valid revision argument at least in 0,35,1 args.add(oldRev); } else { args.add(oldRev+":"+newRev); } } if (!recurse) { args.add("-N"); } if (!ignoreAncestry) { args.add("--notice-ancestry"); } if (noDiffDeleted) { args.add("--no-diff-deleted"); } if (force) { args.add("--force"); } args.add("--old"); args.add(oldPath); args.add("--new"); args.add(newPath); args.addConfigInfo(this.configDir); return execInputStream(args); } /** *

* export files and directories from remote URL.

* */ void export(String url, String path, String revision, boolean force) throws CmdLineException { setCommand(ISVNNotifyListener.Command.EXPORT, true); CmdArguments args = new CmdArguments(); args.add("export"); args.add("-r"); args.add(validRev(revision)); args.add(url); args.add(path); if (force) args.add("--force"); args.addConfigInfo(this.configDir); execVoid(args); } /** *

* Commit an unversioned file or directory into the repository.

* * @param path Local path to import from. * @param url Remote URL to import to. * @param message commit message */ String importFiles(String path, String url, String message, boolean recursive) throws CmdLineException { setCommand(ISVNNotifyListener.Command.IMPORT, true); CmdArguments args = new CmdArguments(); args.add("import"); args.add(path); args.add(url); if (!recursive) { args.add("-N"); } args.addLogMessage(message); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execString(args,false); } /** * info: Display info about a resource. * usage: info [PATH [PATH ... ]] * * Print information about PATHs. * * Valid options: * --targets arg : pass contents of file ARG as additional args * -R [--recursive] : descend recursively * * @param path * @return String with the info call result */ String info(String[] target, String revision, String peg) throws CmdLineException { if (target.length == 0) { // otherwise we would do a "svn info" without args return ""; } setCommand(ISVNNotifyListener.Command.INFO, false); CmdArguments args = new CmdArguments(); args.add("info"); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); if (revision != null) { args.add("-r"); args.add(revision); } for (int i = 0;i < target.length;i++) { if (peg == null) args.add(target[i]); else args.add(target[i] + "@" + peg); } return execString(args,false); } /** *

* List directory entries of a URL.

* * @param url Remote URL. * @param revision Revision to use. can be null * Defaults to HEAD. * @param recursive Should this operation recurse into sub-directories */ byte[] list(String url, String revision, boolean recursive) throws CmdLineException { setCommand(ISVNNotifyListener.Command.LS, false); CmdArguments args = new CmdArguments(); args.add("list"); if (recursive) { args.add("-R"); } args.add("--xml"); args.add("-r"); args.add(revision); args.add(url); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execBytes(args,false); } /** *

* Show the log messages for a set of revision(s) and/or file(s).

* * @param target Local path or URL. * @param revision Optional revision range to get log * messages from. */ byte[] log(String target, String revision, boolean stopOnCopy, long limit ) throws CmdLineException { setCommand(ISVNNotifyListener.Command.LOG, false); CmdArguments args = new CmdArguments(); args.add("log"); args.add("-r"); args.add(validRev(revision)); args.add(target); args.add("--xml"); if (stopOnCopy) args.add("--stop-on-copy"); if (limit > 0) { args.add("--limit"); args.add(Long.toString(limit)); } args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execBytes(args, true); } /** *

* Show the log messages for a set of revision(s) and/or file(s).

*

The difference to the methode log is the parameter -v * * @param target Local path or URL. * @param paths list of paths relative to target, may be null * @param revision Optional revision range to get log * messages from. */ byte[] logVerbose(String target, String [] paths, String revision, boolean stopOnCopy, long limit ) throws CmdLineException { setCommand(ISVNNotifyListener.Command.LOG, false); CmdArguments args = new CmdArguments(); args.add("log"); args.add("-r"); args.add(validRev(revision)); args.add(target); if (paths != null) { for (int i = 0; i < paths.length; i++) { args.add(paths[i]); } } args.add("--xml"); args.add("-v"); if (stopOnCopy) args.add("--stop-on-copy"); if (limit > 0) { args.add("--limit"); args.add(Long.toString(limit)); } args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execBytes(args, true); } /** *

* Create a new directory under revision control.

* * @param url URL to create. (contains existing url, * followed by "/newDirectoryName"). * @param message Commit message to send. */ void mkdir(String url, String message) throws CmdLineException { setCommand(ISVNNotifyListener.Command.MKDIR, true); CmdArguments args = new CmdArguments(); args.add("mkdir"); args.addLogMessage(message); args.add(url); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); execVoid(args); } void mkdir(String localPath) throws CmdLineException { setCommand(ISVNNotifyListener.Command.MKDIR, true); CmdArguments args = new CmdArguments(); args.add("mkdir"); args.add(localPath); args.addConfigInfo(this.configDir); execVoid(args); } /** *

* Move/rename something in working copy or repository.

* *

* source and dest can both be working copy (WC) paths or URLs.

*
*
WC -> WC
*
move and schedule for addition (with history)
*
URL -> URL
*
complete server-side rename.
* * @param source Local path or URL to move from. * @param dest Local path or URL to move to. * @param message Optional message to send with URL. * @param force Perform move even if there are modifications to working copy */ String move(String source, String dest, String message, String revision, boolean force) throws CmdLineException { setCommand(ISVNNotifyListener.Command.MOVE, true); CmdArguments args = new CmdArguments(); args.add("mv"); args.add("-r"); args.add(validRev(revision)); args.add(source); args.add(dest); if (message != null) { args.addLogMessage(message); } if (force) { args.add("--force"); } args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execString(args,false); } /** *

* Print value of propName on files, dirs, or revisions.

* * @param Local path of resource. * @param propName Property name whose value we wish to find. */ InputStream propget(String path, String propName) throws CmdLineException { setCommand(ISVNNotifyListener.Command.PROPGET, false); CmdArguments args = new CmdArguments(); args.add("propget"); args.add("--strict"); args.add(propName); args.add(path); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execInputStream(args); } /** *

* Print value of propName on files, dirs, or revisions.

* * @param Local path of resource. * @param propName Property name whose value we wish to find. */ InputStream propget(String path, String propName, String revision, String peg) throws CmdLineException { setCommand(ISVNNotifyListener.Command.PROPGET, false); CmdArguments args = new CmdArguments(); args.add("propget"); args.add("--strict"); args.add("-r"); args.add(revision); args.add(propName); args.add(path + "@" + peg); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execInputStream(args); } /** *

* Set propName to propVal on files or dirs.

* * @param propName name of the property. * @param propValue New value to set propName to. * @param target Local path to resource. */ void propset(String propName, String propValue, String target, boolean recurse) throws CmdLineException { setCommand(ISVNNotifyListener.Command.PROPSET, false); CmdArguments args = new CmdArguments(); args.add("propset"); if (recurse) args.add("-R"); args.add(propName); args.add(propValue); args.add(target); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); execVoid(args); } /** * List the properties for the given file or dir * * @param target * @return String with the resource properties * @throws CmdLineException */ String proplist(String target, boolean recurse) throws CmdLineException { setCommand(ISVNNotifyListener.Command.PROPLIST, false); CmdArguments args = new CmdArguments(); args.add("proplist"); if (recurse) args.add("-R"); args.add(target); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execString(args,false); } /** * Remove propName from files, dirs. * * @param propName * @param target * @param recurse * @throws CmdLineException */ void propdel(String propName, String target, boolean recurse) throws CmdLineException { setCommand(ISVNNotifyListener.Command.PROPDEL, true); CmdArguments args = new CmdArguments(); args.add("propdel"); if (recurse) args.add("-R"); args.add(propName); args.add(target); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); execVoid(args); } /** *

* Sets a binary file as the value of a property.

* * @param propName name of the property. * @param propFile Local path to binary file. * @param target Local path to resource. */ void propsetFile(String propName, String propFile, String target, boolean recurse) throws CmdLineException { setCommand(ISVNNotifyListener.Command.PROPSET, false); CmdArguments args = new CmdArguments(); args.add("propset"); if (recurse) args.add("-R"); args.add(propName); args.add("-F"); args.add(propFile); args.add(target); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); execVoid(args); } /** *

* Restore pristine working copy file (undo all local edits)

* * @param paths Local paths to revert. * @param recursive true if reverting subdirectories. */ String revert(String[] paths, boolean recursive) throws CmdLineException { setCommand(ISVNNotifyListener.Command.REVERT, true); CmdArguments args = new CmdArguments(); args.add("revert"); if (recursive) args.add("-R"); for (int i = 0; i < paths.length;i++) { args.add(paths[i]); } args.addConfigInfo(this.configDir); return execString(args,false); } /** * Remove 'conflicted' state on working copy files or directories. * * @param paths * @param recursive * @throws CmdLineException */ void resolved(String[] paths, boolean recursive) throws CmdLineException { setCommand(ISVNNotifyListener.Command.RESOLVED, true); CmdArguments args = new CmdArguments(); args.add("resolved"); if (recursive) args.add("-R"); for (int i = 0; i < paths.length;i++) { args.add(paths[i]); } args.addConfigInfo(this.configDir); execVoid(args); } /** *

* Print the status of working copy files and directories.

* * @param path Local path of resource to get status of. * @param allEntries if false, only interesting entries will be get (local mods and/or out-of-date). * @param checkUpdates Check for updates on server. */ byte[] status(String path[], boolean descend, boolean allEntries, boolean checkUpdates, boolean ignoreExternals) throws CmdLineException { if (path.length == 0) { // otherwise we would do a "svn status" without args return new byte[0]; } setCommand(ISVNNotifyListener.Command.STATUS, false); CmdArguments args = new CmdArguments(); args.add("status"); args.add("--xml"); if (allEntries) { args.add("-v"); } if (!descend) args.add("-N"); if (checkUpdates) { args.add("-u"); } if (allEntries) { args.add("--no-ignore"); // disregard default and svn:ignore property ignores } if (ignoreExternals) { args.add("--ignore-externals"); } for (int i = 0; i < path.length;i++) { args.add(path[i]); } args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execBytes(args, false); } /** *

* Bring changes from the repository into the working copy.

* * @param path Local path to possibly update. * @param revision Optional revision to update to. */ String update(String path, String revision) throws CmdLineException { setCommand(ISVNNotifyListener.Command.UPDATE, true); CmdArguments args = new CmdArguments(); args.add("up"); args.add("-r"); args.add(validRev(revision)); args.add(path); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execString(args,false); } /** *

* Bring changes from the repository into the working copy.

* * @param paths Local paths to possibly update. * @param revision Optional revision to update to. */ String update(String[] paths, String revision) throws CmdLineException { StringBuffer pathsArg = new StringBuffer(); for (int i = 0; i < paths.length; i++) { pathsArg.append(paths[i]); pathsArg.append(" "); } setCommand(ISVNNotifyListener.Command.UPDATE, true); CmdArguments args = new CmdArguments(); args.add("up"); args.add("-r"); args.add(validRev(revision)); args.add(pathsArg.toString()); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execString(args,false); } /** * Output the content of specified files or URLs with revision and * author information in-line. * @param path * @param revisionStart * @param revisionEnd * @return byte[] array containing the XML representation of annotate data * @throws CmdLineException */ byte[] annotate(String path,String revisionStart, String revisionEnd) throws CmdLineException { setCommand(ISVNNotifyListener.Command.ANNOTATE, false); CmdArguments args = new CmdArguments(); args.add("annotate"); args.add("--xml"); args.add("-r"); if ((revisionStart != null) && (revisionStart.length() > 0)) { args.add(validRev(revisionStart) + ":" + validRev(revisionEnd)); } else { args.add(validRev(revisionEnd)); } args.add(path); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execBytes(args,false); } /** * Update the working copy to mirror a new URL within the repository. */ String switchUrl(String path, String url, String revision, boolean recurse) throws CmdLineException { setCommand(ISVNNotifyListener.Command.SWITCH, true); CmdArguments args = new CmdArguments(); args.add("sw"); args.add(url); args.add(path); if (!recurse) args.add("-N"); args.add("-r"); args.add(validRev(revision)); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execString(args,false); } /** * Update the working copy to point to a new repository URL. */ String relocate(String from, String to, String path, boolean recurse) throws CmdLineException { setCommand(ISVNNotifyListener.Command.RELOCATE, false); CmdArguments args = new CmdArguments(); args.add("sw"); args.add("--relocate"); if (!recurse) args.add("-N"); args.add(from); args.add(to); args.add(path); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execString(args,false); } /** * Update the working copy to mirror a new URL within the repository. */ String merge(String path1, String revision1, String path2, String revision2, String localPath, boolean force, boolean recurse, boolean dryRun, boolean ignoreAncestry) throws CmdLineException { setCommand(ISVNNotifyListener.Command.MERGE, true); CmdArguments args = new CmdArguments(); args.add("merge"); if (!recurse) args.add("-N"); if (force) args.add("--force"); if (ignoreAncestry) args.add("--ignore-ancestry"); if (dryRun) args.add("--dry-run"); if (path1.equals(path2)) { args.add("-r"); args.add(validRev(revision1) + ":" + validRev(revision2)); args.add(path1); } else { args.add(path1 + "@" + validRev(revision1)); args.add(path2 + "@" + validRev(revision2)); } args.add(localPath); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execString(args,false); } /** *

* Set propName to propVal on revision revision.

* * @param propName name of the property. * @param propValue New value to set propName to. * @param target Local path or URL to resource. * @param force If the propset should be forced. */ void revpropset(String propName, String propValue, String target, String revision, boolean force) throws CmdLineException { setCommand(ISVNNotifyListener.Command.PROPSET, false); CmdArguments args = new CmdArguments(); args.add("propset"); args.add(propName); args.add("--revprop"); args.add(propValue); args.add(target); args.add("-r"); args.add(revision); if (force) args.add("--force"); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); execVoid(args); } /** * @param paths Represents either WC paths, or repository URIs. * @param comment The comment to use for the lock operation. * @param force Whether to include --force in the * command-line. */ String lock(Object[] paths, String comment, boolean force) throws CmdLineException { setCommand(ISVNNotifyListener.Command.LOCK, true); CmdArguments args = new CmdArguments(); args.add("lock"); if (force) args.add("--force"); if (comment != null && !comment.equals("")) { args.add("-m"); args.add(comment); } args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); for (int i = 0; i < paths.length; i++) { args.add(paths[i]); } return execString(args, false); } /** * @param paths Represents either WC paths, or repository URIs. * @param comment The comment to use for the lock operation. * @param force Whether to include --force in the * command-line. */ String unlock(Object[] paths, boolean force) throws CmdLineException { setCommand(ISVNNotifyListener.Command.UNLOCK, true); CmdArguments args = new CmdArguments(); args.add("unlock"); if (force) args.add("--force"); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); for (int i = 0; i < paths.length;i++) { args.add(paths[i]); } return execString(args,false); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.commandline.CommandLine#notifyFromSvnOutput(java.lang.String) */ protected void notifyFromSvnOutput(String svnOutput) { this.rev = SVNRevision.SVN_INVALID_REVNUM; // we call the super implementation : handles logMessage and logCompleted super.notifyFromSvnOutput(svnOutput); if (parseSvnOutput) { // we parse the svn output CmdLineNotify notify = new CmdLineNotify() { public void onNotify( String path, int action, int kind, String mimeType, int contentState, int propState, long revision) { // we only call notifyListenersOfChange and logRevision // logMessage and logCompleted have already been called if (path != null) { notificationHandler.notifyListenersOfChange(path); } if (revision != SVNRevision.SVN_INVALID_REVNUM) { SvnCommandLine.this.rev = revision; notificationHandler.logRevision(revision, path); } } }; try { svnOutputParser.addListener(notify); svnOutputParser.parse(svnOutput); } finally { svnOutputParser.removeListener(notify); } } } /** * We call the super implementation : handles logMessage and logCompleted. * This method main reason is to provide subclasses way to call super.super.notifyFromSvnOutput() * @param svnOutput */ protected void notifyMessagesFromSvnOutput(String svnOutput) { this.rev = SVNRevision.SVN_INVALID_REVNUM; // we call the super implementation : handles logMessage and logCompleted super.notifyFromSvnOutput(svnOutput); } /** * set the command used and tell if the svn ouput is notification * that must be parsed using SvnOutputParser
* The result of commands like list, cat must not be parsed here because * in these cases, the output is not notification * @param command * @param ouputIsNotification */ protected void setCommand(int command, boolean ouputIsNotification) { this.parseSvnOutput = ouputIsNotification; notificationHandler.setCommand(command); } /** * get the revision notified for latest command. If an error occured, the value * of revision must be ignored * @return Returns the revision. */ public long getRevision() { return rev; } } SvnCommandLine12.java000066400000000000000000000103271203563747500362000ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import org.tigris.subversion.svnclientadapter.ISVNNotifyListener; /** * SvnCommandLine subclass providing features compatible with version 1.2 of svn client. * * @author Martin Letenay */ public class SvnCommandLine12 extends SvnCommandLine { //Constructors SvnCommandLine12(String svnPath,CmdLineNotificationHandler notificationHandler) { super(svnPath,notificationHandler); } /** * info: Display info about a resource. * usage: info [PATH [PATH ... ]] * * Print information about PATHs. * * Valid options: * --targets arg : pass contents of file ARG as additional args * -R [--recursive] : descend recursively * * @param path * @return String with the info call result */ String info(String[] target) throws CmdLineException { if (target.length == 0) { // otherwise we would do a "svn info" without args return ""; } setCommand(ISVNNotifyListener.Command.INFO, false); CmdArguments args = new CmdArguments(); args.add("info"); args.addConfigInfo(this.configDir); for (int i = 0;i < target.length;i++) { args.add(target[i]); } return execString(args,false); } /** *

* Print the status of working copy files and directories.

* * @param path Local path of resource to get status of. * @param allEntries if false, only interesting entries will be get (local mods and/or out-of-date). * @param checkUpdates Check for updates on server. */ String statusByStdout(String path[], boolean descend, boolean allEntries, boolean checkUpdates, boolean ignoreExternals) throws CmdLineException { if (path.length == 0) { // otherwise we would do a "svn status" without args return ""; } setCommand(ISVNNotifyListener.Command.STATUS, false); CmdArguments args = new CmdArguments(); args.add("status"); args.add("-v"); if (!allEntries) { args.add("-q"); } if (!descend) args.add("-N"); if (checkUpdates) args.add("-u"); if (allEntries) { args.add("--no-ignore"); // disregard default and svn:ignore property ignores } if (ignoreExternals) { args.add("--ignore-externals"); } for (int i = 0; i < path.length;i++) { args.add(path[i]); } args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execString(args,false); } /** * Output the content of specified files or URLs with revision and * author information in-line. * @param path * @param revisionStart * @param revisionEnd * @return String with the annotate data * @throws CmdLineException */ String annotateByStdout(String path,String revisionStart, String revisionEnd) throws CmdLineException { setCommand(ISVNNotifyListener.Command.ANNOTATE, false); CmdArguments args = new CmdArguments(); args.add("annotate"); args.add("-r"); if ((revisionStart != null) && (revisionStart.length() > 0)) { args.add(validRev(revisionStart) + ":" + validRev(revisionEnd)); } else { args.add(validRev(revisionEnd)); } args.add(path); args.addAuthInfo(this.user, this.pass); args.addConfigInfo(this.configDir); return execString(args,false); } } SvnMultiArgCommandLine.java000066400000000000000000000060351203563747500375030ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.tigris.subversion.svnclientadapter.SVNRevision; /** * SvnCommandLine subclass for handling command with multiple arguments (thus multiple answers) * @see org.tigris.subversion.svnclientadapter.commandline.SvnCommandLine */ public class SvnMultiArgCommandLine extends SvnCommandLine { protected List revs = new ArrayList(); SvnMultiArgCommandLine(String svnPath,CmdLineNotificationHandler notificationHandler) { super(svnPath,notificationHandler); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.commandline.CommandLine#notifyFromSvnOutput(java.lang.String) */ protected void notifyFromSvnOutput(String svnOutput) { // we call the super implementation : handles logMessage and logCompleted super.notifyMessagesFromSvnOutput(svnOutput); if (parseSvnOutput) { // we parse the svn output CmdLineNotify notify = new CmdLineNotify() { public void onNotify( String path, int action, int kind, String mimeType, int contentState, int propState, long revision) { // we only call notifyListenersOfChange and logRevision // logMessage and logCompleted have already been called if (path != null) { notificationHandler.notifyListenersOfChange(path); } SvnMultiArgCommandLine.this.revs.add(new Long(revision)); if (revision != SVNRevision.SVN_INVALID_REVNUM) { notificationHandler.logRevision(revision, path); } } }; try { svnOutputParser.addListener(notify); svnOutputParser.parse(svnOutput); } finally { svnOutputParser.removeListener(notify); } } } /** * get the revisions notified for latest command. If an error occured, the value * of revisions must be ignored * @return Returns the revisions. */ public long[] getRevisions() { long[] result = new long[revs.size()]; int i = 0; for (Iterator iter = revs.iterator(); iter.hasNext();) { result[i] = ((Long )iter.next()).longValue(); i++; } return result; } } svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/parser/000077500000000000000000000000001203563747500336655ustar00rootroot00000000000000SvnActionRE.java000066400000000000000000000124311203563747500366050ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/parser/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline.parser; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.commandline.CmdLineNotifyStatus; /** * regular expression to parse an svn notification line * * @author C�dric Chabanois (cchabanois at no-log.org) */ class SvnActionRE { public static final String PATH = "path"; public static final String CONTENTSTATE = "contentState"; public static final String PROPSTATE = "propState"; public static final String REVISION = "revision"; private Pattern pattern; private Matcher matcher; private int action; private int contentStatus = CmdLineNotifyStatus.unknown; private int propStatus = CmdLineNotifyStatus.unknown; private String[] notificationProperties; /** * each parenthesized subexpression in the regular expression can be associated to a notificationProperty * which is either PATH, CONTENTSTATE, PROPSTATE or REVISION * @see SvnOutputParser * @param re the regular expression to parse the svn line * @param action the action corresponding to this line * @param notificationProperties an array containing some of the following constants * PATH, CONTENTSTATE, PROPSTATE, REVISION */ public SvnActionRE(String re, int action, String[] notificationProperties) { this.pattern = Pattern.compile('^'+re+'$'); this.action = action; this.notificationProperties = notificationProperties; } public SvnActionRE(String re, int action, String notificationProperty) { this.pattern = Pattern.compile('^'+re+'$'); this.action = action; this.notificationProperties = new String[] { notificationProperty }; } public SvnActionRE(String re, int action) { this.pattern = Pattern.compile('^'+re+'$'); this.action = action; this.notificationProperties = new String[] { }; } public SvnActionRE(String re, int action, int contentStatus, int propStatus) { this(re,action); this.contentStatus = contentStatus; this.propStatus = propStatus; } public SvnActionRE(String re, int action, int contentStatus, String[] notificationProperties) { this(re,action,notificationProperties); this.contentStatus = contentStatus; } public SvnActionRE(String re, int action, int contentStatus, int propStatus,String[] notificationProperties) { this(re,action,notificationProperties); this.contentStatus = contentStatus; this.propStatus = propStatus; } /** * @return the action */ public int getAction() { return action; } private int getIndex(String notificationProperty) { for (int i = 0; i < notificationProperties.length;i++) { if (notificationProperties[i].equals(notificationProperty)) { return i; } } return -1; } public boolean match(String line) { this.matcher = pattern.matcher(line); return this.matcher.matches(); } /** * @return the path on which action happen or null */ public String getPath() { int index = getIndex(PATH); if (index == -1) { return null; } else { return matcher.group(index+1); } } private int getStatus(char statusChar) { if (statusChar == ' ') return CmdLineNotifyStatus.unchanged; else if (statusChar == 'C') return CmdLineNotifyStatus.conflicted; else if (statusChar == 'G') return CmdLineNotifyStatus.merged; else if (statusChar == 'U') return CmdLineNotifyStatus.changed; else return CmdLineNotifyStatus.unknown; } /** * @return the content state */ public int getContentState() { if (contentStatus != CmdLineNotifyStatus.unknown) { return contentStatus; } int index = getIndex(CONTENTSTATE); if (index == -1) { return CmdLineNotifyStatus.unknown; } else { String stateChar = matcher.group(index+1); return getStatus(stateChar.charAt(0)); } } /** * @return the prop status */ public int getPropStatus() { if (propStatus != CmdLineNotifyStatus.unknown) { return propStatus; } int index = getIndex(PROPSTATE); if (index == -1) { return CmdLineNotifyStatus.unknown; } else { String stateChar = matcher.group(index+1); return getStatus(stateChar.charAt(0)); } } /** * @return the revision or null */ public long getRevision() { int index = getIndex(REVISION); if (index == -1) { return SVNRevision.SVN_INVALID_REVNUM; } else { String revisionString = matcher.group(index+1); return Long.parseLong(revisionString); } } }SvnOutputParser.java000066400000000000000000000176041203563747500376250ustar00rootroot00000000000000svnclientadapter-1.8.16/src/commandline/org/tigris/subversion/svnclientadapter/commandline/parser/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline.parser; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.StringTokenizer; import java.util.logging.Logger; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.commandline.CmdLineNotify; import org.tigris.subversion.svnclientadapter.commandline.CmdLineNotifyAction; import org.tigris.subversion.svnclientadapter.commandline.CmdLineNotifyStatus; /** * parser for the output of svn * * @author Cédric Chabanois (cchabanois at no-log.org) */ public class SvnOutputParser { private static final Logger log = Logger.getLogger(SvnOutputParser.class.getName()); private static final String NEWLINE = "\n\r"; // See see subversion/clients/cmdline/notify.c for possible outputs // we depend on javahl because it would be a waste to duplicate the notification actions private SvnActionRE[] svnActionsRE = new SvnActionRE[] { new SvnActionRE("Skipped missing target: '(.+)'",CmdLineNotifyAction.skip, CmdLineNotifyStatus.missing,new String[] { SvnActionRE.PATH } ), new SvnActionRE("Skipped '(.+)'",CmdLineNotifyAction.skip,SvnActionRE.PATH), new SvnActionRE("D ([^ ].+)",CmdLineNotifyAction.update_delete,SvnActionRE.PATH), new SvnActionRE("A ([^ ].+)",CmdLineNotifyAction.update_add,SvnActionRE.PATH), new SvnActionRE("Restored '(.+)'",CmdLineNotifyAction.restore,SvnActionRE.PATH), new SvnActionRE("Reverted '(.+)'",CmdLineNotifyAction.revert,SvnActionRE.PATH), new SvnActionRE("Failed to revert '(.+)' -- try updating instead\\.",CmdLineNotifyAction.failed_revert,SvnActionRE.PATH), new SvnActionRE("Resolved conflicted state of '(.+)'",CmdLineNotifyAction.resolved,SvnActionRE.PATH), new SvnActionRE("A (bin) ([^ ].+)",CmdLineNotifyAction.add,SvnActionRE.PATH), new SvnActionRE("A ([^ ].+)",CmdLineNotifyAction.add,SvnActionRE.PATH), new SvnActionRE("D ([^ ].+)",CmdLineNotifyAction.delete,SvnActionRE.PATH), new SvnActionRE("([CGU ])([CGU ]) (.+)",CmdLineNotifyAction.update_update,new String[] {SvnActionRE.CONTENTSTATE, SvnActionRE.PROPSTATE,SvnActionRE.PATH}), new SvnActionRE("Fetching external item into '(.+)'",CmdLineNotifyAction.update_external,SvnActionRE.PATH), new SvnActionRE("Exported external at revision (\\d+)\\.",CmdLineNotifyAction.update_completed,SvnActionRE.REVISION), new SvnActionRE("Exported revision (\\d+)\\.",CmdLineNotifyAction.update_completed,SvnActionRE.REVISION), new SvnActionRE("Checked out external at revision (\\d+)\\.",CmdLineNotifyAction.update_completed,SvnActionRE.REVISION), new SvnActionRE("Checked out revision (\\d+)\\.",CmdLineNotifyAction.update_completed,SvnActionRE.REVISION), new SvnActionRE("Updated external to revision (\\d+)\\.",CmdLineNotifyAction.update_completed,SvnActionRE.REVISION), new SvnActionRE("Updated to revision (\\d+)\\.",CmdLineNotifyAction.update_completed,SvnActionRE.REVISION), new SvnActionRE("External at revision (\\d+)\\.",CmdLineNotifyAction.update_completed,SvnActionRE.REVISION), new SvnActionRE("At revision (\\d+)\\.",CmdLineNotifyAction.update_completed,SvnActionRE.REVISION), new SvnActionRE("External export complete\\.",CmdLineNotifyAction.update_completed, CmdLineNotifyStatus.inapplicable, CmdLineNotifyStatus.inapplicable), new SvnActionRE("Export complete\\.",CmdLineNotifyAction.update_completed, CmdLineNotifyStatus.inapplicable, CmdLineNotifyStatus.inapplicable), new SvnActionRE("External checkout complete\\.",CmdLineNotifyAction.update_completed, CmdLineNotifyStatus.inapplicable, CmdLineNotifyStatus.inapplicable), new SvnActionRE("Checkout complete\\.",CmdLineNotifyAction.update_completed, CmdLineNotifyStatus.inapplicable, CmdLineNotifyStatus.inapplicable), new SvnActionRE("External update complete\\.",CmdLineNotifyAction.update_completed, CmdLineNotifyStatus.inapplicable, CmdLineNotifyStatus.inapplicable), new SvnActionRE("Update complete\\.",CmdLineNotifyAction.update_completed, CmdLineNotifyStatus.inapplicable, CmdLineNotifyStatus.inapplicable), new SvnActionRE("Performing status on external item at '(.+)'",CmdLineNotifyAction.status_external,SvnActionRE.PATH), new SvnActionRE("Status against revision: *(\\d+)",CmdLineNotifyAction.status_completed,SvnActionRE.REVISION), new SvnActionRE("Sending (.+)",CmdLineNotifyAction.commit_modified,SvnActionRE.PATH), new SvnActionRE("Adding (bin) (.+)",CmdLineNotifyAction.commit_added,SvnActionRE.PATH), new SvnActionRE("Adding (.+)",CmdLineNotifyAction.commit_added,SvnActionRE.PATH), new SvnActionRE("Deleting (.+)",CmdLineNotifyAction.commit_deleted,SvnActionRE.PATH), new SvnActionRE("Replacing (.+)",CmdLineNotifyAction.commit_replaced,SvnActionRE.PATH), new SvnActionRE("Transmitting file data \\.*",CmdLineNotifyAction.commit_postfix_txdelta), new SvnActionRE("'(.+)' locked by user.*",CmdLineNotifyAction.locked), new SvnActionRE("'(.+)' unlocked.*",CmdLineNotifyAction.unlocked), // this one is not a notification new SvnActionRE("Committed revision (\\d+)\\.",-1,SvnActionRE.REVISION) }; private List listeners = new LinkedList(); /** * add a listener * @param listener */ public void addListener(CmdLineNotify listener) { listeners.add(listener); } /** * remove a listener * @param listener */ public void removeListener(CmdLineNotify listener) { listeners.remove(listener); } /** * parse the given svn output (this can be more than one line) * and notifies listeners * @param svnOutput */ public void parse(String svnOutput) { StringTokenizer st = new StringTokenizer(svnOutput, NEWLINE); while (st.hasMoreTokens()) { String line = st.nextToken(); synchronized(this) { // only one client must access a given SvnActionRE at a time SvnActionRE svnActionRE = getMatchingSvnActionRE(line); if (svnActionRE != null) { notifyListeners(svnActionRE); } else { // if we don't find a matching svnActionRE, we just log it log.warning("Can't find a svn action for svn output line : "+line); } } } } /** * return the matching svn action or null if none matches * @param line * @return the matching svn action or null if none matches */ private SvnActionRE getMatchingSvnActionRE(String line) { SvnActionRE result = null; for (int i = 0; i < svnActionsRE.length;i++) { if (svnActionsRE[i].match(line)) { if (result != null) { log.severe("Multiple regular expressions match : "+line); } else { result = svnActionsRE[i]; } } } return result; } private void notifyListeners(SvnActionRE svnActionRE) { for (Iterator it = listeners.iterator();it.hasNext();) { CmdLineNotify listener = (CmdLineNotify)it.next(); listener.onNotify( svnActionRE.getPath(), svnActionRE.getAction(), SVNNodeKind.UNKNOWN.toInt(), // we don't know the kind (String)null, // we don't know the mimeType svnActionRE.getContentState(), svnActionRE.getPropStatus(), svnActionRE.getRevision()); } } } svnclientadapter-1.8.16/src/javahl/000077500000000000000000000000001203563747500172255ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/000077500000000000000000000000001203563747500200145ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/000077500000000000000000000000001203563747500213155ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/000077500000000000000000000000001203563747500235145ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/000077500000000000000000000000001203563747500270625ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/000077500000000000000000000000001203563747500303275ustar00rootroot00000000000000AbstractJhlClientAdapter.java000066400000000000000000003756701203563747500357760ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.StringTokenizer; import org.apache.subversion.javahl.ClientException; import org.apache.subversion.javahl.ConflictResult; import org.apache.subversion.javahl.ISVNClient; import org.apache.subversion.javahl.SubversionException; import org.apache.subversion.javahl.callback.ListCallback; import org.apache.subversion.javahl.callback.StatusCallback; import org.apache.subversion.javahl.callback.UserPasswordCallback; import org.apache.subversion.javahl.types.CopySource; import org.apache.subversion.javahl.types.Depth; import org.apache.subversion.javahl.types.DirEntry; import org.apache.subversion.javahl.types.Lock; import org.apache.subversion.javahl.types.Mergeinfo; import org.apache.subversion.javahl.types.Revision; import org.apache.subversion.javahl.types.RevisionRange; import org.apache.subversion.javahl.types.Status; import org.tigris.subversion.svnclientadapter.AbstractClientAdapter; import org.tigris.subversion.svnclientadapter.ISVNAnnotations; import org.tigris.subversion.svnclientadapter.ISVNConflictResolver; import org.tigris.subversion.svnclientadapter.ISVNDirEntry; import org.tigris.subversion.svnclientadapter.ISVNDirEntryWithLock; import org.tigris.subversion.svnclientadapter.ISVNInfo; import org.tigris.subversion.svnclientadapter.ISVNLogMessage; import org.tigris.subversion.svnclientadapter.ISVNLogMessageCallback; import org.tigris.subversion.svnclientadapter.ISVNMergeInfo; import org.tigris.subversion.svnclientadapter.ISVNMergeinfoLogKind; import org.tigris.subversion.svnclientadapter.ISVNNotifyListener; import org.tigris.subversion.svnclientadapter.ISVNProgressListener; import org.tigris.subversion.svnclientadapter.ISVNPromptUserPassword; import org.tigris.subversion.svnclientadapter.ISVNProperty; import org.tigris.subversion.svnclientadapter.ISVNStatus; import org.tigris.subversion.svnclientadapter.ISVNStatusCallback; import org.tigris.subversion.svnclientadapter.SVNBaseDir; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNDiffSummary; import org.tigris.subversion.svnclientadapter.SVNDiffSummary.SVNDiffKind; import org.tigris.subversion.svnclientadapter.SVNInfoUnversioned; import org.tigris.subversion.svnclientadapter.SVNLogMessageCallback; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNNotificationHandler; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNRevisionRange; import org.tigris.subversion.svnclientadapter.SVNScheduleKind; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.SVNStatusUnversioned; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.utils.Messages; /** * This is a base class for the JavaHL Adapter. It allows the JavaHL * Adapter and the SVNKit Adapter to share most of their implementation. * * The SVNKit Adapter works by providing an implementation of the JavaHL * SVNClientInterface. * */ public abstract class AbstractJhlClientAdapter extends AbstractClientAdapter { protected ISVNClient svnClient; protected JhlNotificationHandler notificationHandler; protected JhlConflictResolver conflictResolver; protected JhlProgressListener progressListener; private String postCommitError; public AbstractJhlClientAdapter() { } /** * for users who want to directly use underlying javahl SVNClientInterface * @return the SVNClientInterface instance */ public ISVNClient getSVNClient() { return svnClient; } /** * the default prompter : never prompts the user */ public static class DefaultPromptUserPassword implements UserPasswordCallback { public int askTrustSSLServer(String info, boolean allowPermanently) { return UserPasswordCallback.AcceptTemporary; } public String askQuestion(String realm, String question, boolean showAnswer) { return ""; } public boolean askYesNo(String realm, String question, boolean yesIsDefault) { return yesIsDefault; } public String getPassword() { return ""; } public String getUsername() { return ""; } public boolean prompt(String realm, String username) { return false; } public boolean prompt(String realm, String username, boolean maySave) { return false; } public String askQuestion(String realm, String question, boolean showAnswer, boolean maySave) { return null; } public boolean userAllowedSave() { return false; } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#addNotifyListener(org.tigris.subversion.svnclientadapter.ISVNNotifyListener) */ public void addNotifyListener(ISVNNotifyListener listener) { notificationHandler.add(listener); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#removeNotifyListener(org.tigris.subversion.svnclientadapter.ISVNNotifyListener) */ public void removeNotifyListener(ISVNNotifyListener listener) { notificationHandler.remove(listener); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getNotificationHandler() */ public SVNNotificationHandler getNotificationHandler() { return notificationHandler; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#setUsername(java.lang.String) */ public void setUsername(String username) { svnClient.username(username); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#setPassword(java.lang.String) */ public void setPassword(String password) { notificationHandler.setCommand(ISVNNotifyListener.Command.UNDEFINED); svnClient.password(password); } /** * Register callback interface to supply username and password on demand * @param prompt */ public void setPromptUserPassword(UserPasswordCallback prompt) { svnClient.setPrompt(prompt); } protected static String fileToSVNPath(File file, boolean canonical) { if (file == null) return null; // SVN need paths with '/' separators if (canonical) { try { return file.getCanonicalPath().replace('\\', '/'); } catch (IOException e) { return null; } } else return file.getPath().replace('\\', '/'); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#addFile(java.io.File) */ public void addFile(File file) throws SVNClientException { try{ notificationHandler.setCommand(ISVNNotifyListener.Command.ADD); notificationHandler.logCommandLine("add -N "+file.toString()); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(file)); svnClient.add(fileToSVNPath(file, false), Depth.infinity, false, true, true); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#addDirectory(java.io.File, boolean) */ public void addDirectory(File file, boolean recurse) throws SVNClientException { addDirectory(file, recurse, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#addDirectory(java.io.File, boolean, boolean) */ public void addDirectory(File dir, boolean recurse, boolean force) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.ADD); notificationHandler.logCommandLine( "add"+ (recurse?"":" -N")+ (force?" --force":"")+ " "+dir.toString()); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(dir)); boolean noIgnores = false; boolean addParents = true; svnClient.add(fileToSVNPath(dir, false), Depth.infinityOrEmpty(recurse), force, noIgnores, addParents); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#checkout(org.tigris.subversion.svnclientadapter.SVNUrl, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public void checkout( SVNUrl moduleName, File destPath, SVNRevision revision, boolean recurse) throws SVNClientException { checkout(moduleName, destPath, revision, Depth.infinityOrImmediates(recurse).ordinal(), false, true); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#checkout(org.tigris.subversion.svnclientadapter.SVNUrl, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, int, boolean, boolean) */ public void checkout( SVNUrl moduleName, File destPath, SVNRevision revision, int depth, boolean ignoreExternals, boolean force) throws SVNClientException { try { String url = moduleName.toString(); Depth d = JhlConverter.depth(depth); notificationHandler.setCommand(ISVNNotifyListener.Command.CHECKOUT); StringBuffer commandLine = new StringBuffer("checkout " + url + " -r " + revision.toString() + depthCommandLine(d)); if (ignoreExternals) commandLine.append(" --ignore-externals"); if (force) commandLine.append(" --force"); notificationHandler.logCommandLine(commandLine.toString()); notificationHandler.setBaseDir(new File(".")); svnClient.checkout( url, fileToSVNPath(destPath, false), JhlConverter.convert(revision), JhlConverter.convert(revision), d, ignoreExternals, force); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#commit(java.io.File[], java.lang.String, boolean) */ public long commit(File[] paths, String message, boolean recurse) throws SVNClientException { return commit(paths, message, recurse, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#commit(java.io.File[], java.lang.String, boolean, boolean) */ public long commit(File[] paths, String message, boolean recurse, boolean keepLocks) throws SVNClientException { try { postCommitError = null; String fixedMessage = fixSVNString(message); if (fixedMessage == null) fixedMessage = ""; notificationHandler.setCommand(ISVNNotifyListener.Command.COMMIT); Set files = new HashSet(paths.length); String commandLine = "commit -m \""+getFirstMessageLine(fixedMessage)+"\""; if (!recurse) commandLine+=" -N"; if (keepLocks) commandLine+=" --no-unlock"; for (int i = 0; i < paths.length; i++) { files.add(fileToSVNPath(paths[i], false)); } commandLine = appendPaths(commandLine, files); notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(paths)); boolean keepChangeLists = false; JhlCommitCallback callback = new JhlCommitCallback(); svnClient.commit(files, Depth.infinityOrEmpty(recurse), keepLocks, keepChangeLists, null, null, new JhlCommitMessage(fixedMessage), callback); postCommitError = callback.getPostCommitError(); long newRev = callback.getRevision(); if (newRev > 0) notificationHandler.logCompleted("Committed revision " + newRev + "."); return newRev; } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } public String getPostCommitError() { return postCommitError; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getList(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public ISVNDirEntry[] getList(SVNUrl url, SVNRevision revision, boolean recurse) throws SVNClientException { String target = url.toString(); return list(target, revision, SVNRevision.HEAD, recurse); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getList(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public ISVNDirEntry[] getList(SVNUrl url, SVNRevision revision, SVNRevision pegRevision, boolean recurse) throws SVNClientException { String target = url.toString(); return list(target, revision, pegRevision, recurse); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getList(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public ISVNDirEntry[] getList(File path, SVNRevision revision, boolean recurse) throws SVNClientException { String target = fileToSVNPath(path, false); return list(target, revision, SVNRevision.HEAD, recurse); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getList(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public ISVNDirEntry[] getList(File path, SVNRevision revision, SVNRevision pegRevision, boolean recurse) throws SVNClientException { String target = fileToSVNPath(path, false); return list(target, revision, pegRevision, recurse); } private ISVNDirEntry[] list(String path, SVNRevision revision, SVNRevision pegRevision, boolean recurse) throws SVNClientException { final List dirEntryList = new ArrayList(); ListCallback callback = new ListCallback() { public void doEntry(DirEntry dirent, Lock lock) { if (dirent.getPath().length() == 0) { if (dirent.getNodeKind() == org.apache.subversion.javahl.types.NodeKind.file) { String absPath = dirent.getAbsPath(); int lastSeparator = absPath.lastIndexOf('/'); String path = absPath.substring(lastSeparator, absPath.length()); dirent.setPath(path); } else { // Don't add requested directory. return; } } dirEntryList.add(new JhlDirEntry(dirent)); } }; try { notificationHandler.setCommand(ISVNNotifyListener.Command.LS); String commandLine = "list -r "+revision.toString()+(recurse?"-R":"")+" "+path; notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(new File(".")); svnClient.list(path, JhlConverter.convert(revision), JhlConverter.convert(pegRevision), Depth.infinityOrImmediates(recurse), DirEntry.Fields.all, false, callback); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } ISVNDirEntry[] dirEntries = new ISVNDirEntry[dirEntryList.size()]; dirEntryList.toArray(dirEntries); return dirEntries; } public ISVNDirEntryWithLock[] getListWithLocks(SVNUrl url, SVNRevision revision, SVNRevision pegRevision, boolean recurse) throws SVNClientException { final List dirEntryList = new ArrayList(); ListCallback callback = new ListCallback() { public void doEntry(DirEntry dirent, Lock lock) { if (dirent.getPath().length() == 0) { if (dirent.getNodeKind() == org.apache.subversion.javahl.types.NodeKind.file) { String absPath = dirent.getAbsPath(); int lastSeparator = absPath.lastIndexOf('/'); String path = absPath.substring(lastSeparator, absPath.length()); dirent.setPath(path); } else { // Don't add requested directory. return; } } dirEntryList.add(new JhlDirEntryWithLock(dirent, lock)); } }; try { notificationHandler.setCommand(ISVNNotifyListener.Command.LS); String commandLine = "list -r "+revision.toString()+(recurse?"-R":"")+" "+url.toString(); notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(new File(".")); svnClient.list(url.toString(), JhlConverter.convert(revision), JhlConverter.convert(pegRevision), Depth.infinityOrImmediates(recurse), DirEntry.Fields.all, true, callback); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } ISVNDirEntryWithLock[] dirEntries = new ISVNDirEntryWithLock[dirEntryList.size()]; dirEntryList.toArray(dirEntries); return dirEntries; } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getDirEntry(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision) */ public ISVNDirEntry getDirEntry(SVNUrl url, SVNRevision revision) throws SVNClientException { // list give the DirEntrys of the elements of a directory or the DirEntry // of a file ISVNDirEntry[] entries = getList(url.getParent(), revision,false); String expectedPath = url.getLastPathSegment(); for (int i = 0; i < entries.length;i++) { if (entries[i].getPath().equals(expectedPath)) { return entries[i]; } } return null; // not found } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getDirEntry(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision) */ public ISVNDirEntry getDirEntry(File path, SVNRevision revision) throws SVNClientException { // list give the DirEntrys of the elements of a directory or the DirEntry // of a file ISVNDirEntry[] entries = getList(path.getParentFile(), revision,false); String expectedPath = path.getName(); for (int i = 0; i < entries.length;i++) { if (entries[i].getPath().equals(expectedPath)) { return entries[i]; } } return null; // not found } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getSingleStatus(java.io.File) */ public ISVNStatus getSingleStatus(File path) throws SVNClientException { return getStatus(new File[] {path})[0]; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getStatus(java.io.File[]) */ public ISVNStatus[] getStatus(File[] path) throws SVNClientException { ISVNStatus[] statuses = new ISVNStatus[path.length]; for (int i = 0; i < path.length; i++) { ISVNStatus[] s = getStatus(path[i], false, true, false, false); if (s == null || s.length == 0) { statuses[i] = new SVNStatusUnversioned(path[i]); } else { statuses[i] = s[0]; } } return statuses; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getStatus(java.io.File, boolean, boolean) */ public ISVNStatus[] getStatus(File path, boolean descend, boolean getAll) throws SVNClientException { return getStatus(path, descend,getAll,false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getStatus(java.io.File, boolean, boolean, boolean) */ public ISVNStatus[] getStatus(File path, boolean descend, boolean getAll, boolean contactServer) throws SVNClientException { return getStatus(path, descend, getAll, contactServer, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getStatus(java.io.File, boolean, boolean, boolean, boolean) */ public ISVNStatus[] getStatus(File path, boolean descend, boolean getAll, boolean contactServer, boolean ignoreExternals) throws SVNClientException { return getStatus(path, descend, getAll, contactServer, ignoreExternals, null); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getStatus(java.io.File, boolean, boolean, boolean, boolean, ISVNStatusCallback) */ public ISVNStatus[] getStatus(File path, boolean descend, boolean getAll, boolean contactServer, boolean ignoreExternals, ISVNStatusCallback callback) throws SVNClientException { notificationHandler.setCommand(ISVNNotifyListener.Command.STATUS); String filePathSVN = fileToSVNPath(path, false); Depth depth = Depth.unknownOrImmediates(descend); // If descend is true, recurse fully, else do only immediate children. notificationHandler.logCommandLine("status" + (contactServer?" -u":"")+ depthCommandLine(depth) + " " + filePathSVN); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); try { StatusCallback statusCallback; if (callback == null) { statusCallback = new MyStatusCallback(); } else { statusCallback = new JhlStatusCallback(callback); } svnClient.status( filePathSVN, depth, contactServer, // If update is set, contact the repository and augment the status structures with information about out-of-dateness getAll,getAll, // retrieve all entries; otherwise, retrieve only "interesting" entries (local mods and/or out-of-date). ignoreExternals, null, statusCallback); List statusList = null; if (statusCallback instanceof MyStatusCallback) { statusList = ((MyStatusCallback)statusCallback).getStatusList(); } else { statusList = ((JhlStatusCallback)statusCallback).getStatusList(); } return processFolderStatuses(processExternalStatuses(JhlConverter.convertStatus( statusList, svnClient)), getAll, contactServer); // if yes the svn:externals will be ignored } catch (ClientException e) { if (e.getAprError() == ErrorCodes.wcNotDirectory) { // when there is no .svn dir, an exception is thrown ... return new ISVNStatus[] {new SVNStatusUnversioned(path)}; } else { notificationHandler.logException(e); throw new SVNClientException(e); } } } /** * A private status callback implementation used by thin wrappers. * Instances of this class are not thread-safe. */ private class MyStatusCallback implements StatusCallback { public void doStatus(String path, Status status) { // Status can be null, in which case you are supposed to use the // String to construct an otherwise null status object. I am not sure // of the use-case for this right now, so I am just going to discard them if (status != null) statuses.add(status); } private List statuses = new ArrayList(); public List getStatusList() { return statuses; } } /** * Post-process svn:externals statuses. * JavaHL answer two sort of statuses on externals: * - when ignoreExternals is set to true during call to status(), * the returned status has textStatus set to EXTERNAL, but the url is null.
* - when ignoreExternals is set to false during call to status(), * besides the "external + null" status, the second status with url and all fields is returned too, * but this one has textStatus NORMAL. * * This methods unifies both statuses to be complete and has textStatus external. * In case the first sort (when ignoreExternals true), the url is retrieved by call the info() */ protected JhlStatus[] processExternalStatuses(JhlStatus[] statuses) throws SVNClientException { //Collect indexes of external statuses List externalStatusesIndexes = new ArrayList(); for (int i = 0; i < statuses.length; i++) { if (SVNStatusKind.EXTERNAL.equals(statuses[i].getTextStatus())) { externalStatusesIndexes.add(new Integer(i)); } } if (externalStatusesIndexes.isEmpty()) { return statuses; } //Wrap the "second" externals so their textStatus is actually external for (Integer integer : externalStatusesIndexes) { int index = integer.intValue(); JhlStatus jhlStatus = statuses[index]; for (int i = 0; i < statuses.length; i++) { if ((statuses[i].getPath() != null) && (statuses[i].getPath().equals(jhlStatus.getPath()))) { statuses[i] = new JhlStatus.JhlStatusExternal(statuses[i], svnClient); statuses[index] = statuses[i]; } } } return statuses; } /** * Post-process statuses. * Folders do not return proper lastChangedRevision information. * this allows it to be populated via the svn info command */ protected ISVNStatus[] processFolderStatuses(JhlStatus[] statuses, boolean getAll, boolean contactServer) throws SVNClientException { if (!getAll || !contactServer) return statuses; //Fill the missing last changed info on folders from the file info in the array List folders = new ArrayList(); for (int i = 0; i < statuses.length; i++) { JhlStatus jhlStatus = statuses[i]; if (SVNNodeKind.DIR == jhlStatus.getNodeKind() && jhlStatus.getReposLastChangedRevision() == null) { folders.add(jhlStatus); } } for (int i = 0; i < statuses.length; i++) { JhlStatus jhlStatus = statuses[i]; if (jhlStatus.getLastChangedRevision() != null) { for (JhlStatus folder : folders) { if (jhlStatus.getUrlString() != null && jhlStatus.getUrlString().startsWith(folder.getUrlString() + "/")) { if (folder.getLastChangedRevision() == null || folder.getLastChangedRevision().getNumber() < jhlStatus.getLastChangedRevision().getNumber()) { folder.updateFromStatus(jhlStatus); } } } } } return statuses; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#copy(java.io.File, java.io.File) */ public void copy(File srcPath, File destPath) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.COPY); String src = fileToSVNPath(srcPath, false); String dest = fileToSVNPath(destPath, false); notificationHandler.logCommandLine("copy " + src + " " + dest); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(new File[] {srcPath,destPath })); List copySources = new ArrayList(); copySources.add(new CopySource(src, Revision.WORKING, Revision.WORKING)); svnClient.copy(copySources, dest, true, true, false, null, null, null); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#copy(java.io.File, org.tigris.subversion.svnclientadapter.SVNUrl, java.lang.String) */ public void copy(File srcPath, SVNUrl destUrl, String message) throws SVNClientException { try { String fixedMessage = fixSVNString(message); if (fixedMessage == null) fixedMessage = ""; notificationHandler.setCommand(ISVNNotifyListener.Command.COPY); String src = fileToSVNPath(srcPath, false); String dest = destUrl.toString(); notificationHandler.logCommandLine("copy " + src + " " + dest); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(srcPath)); List copySources = new ArrayList(); copySources.add(new CopySource(src, Revision.WORKING, Revision.WORKING)); svnClient.copy(copySources, dest, true, true, true, null, new JhlCommitMessage(fixedMessage), null); // last parameter is not used } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#copy(java.io.File[], org.tigris.subversion.svnclientadapter.SVNUrl, java.lang.String, boolean, boolean) */ public void copy(File[] srcPaths, SVNUrl destUrl, String message, boolean copyAsChild, boolean makeParents) throws SVNClientException { String fixedMessage = fixSVNString(message); // This is a hack for now since copy of multiple isolated WC's is currently not working. if (srcPaths.length > 1) { mkdir(destUrl, makeParents, fixedMessage); for (int i = 0; i < srcPaths.length; i++) { File[] file = { srcPaths[i] }; copy(file, destUrl, fixedMessage, copyAsChild, makeParents); } return; } try { if (fixedMessage == null) fixedMessage = ""; notificationHandler.setCommand(ISVNNotifyListener.Command.COPY); List copySources = new ArrayList(srcPaths.length); for (int i = 0; i < srcPaths.length; i++) copySources.add(new CopySource(fileToSVNPath(srcPaths[i], false), Revision.WORKING, Revision.WORKING)); String dest = destUrl.toString(); String commandLine = "copy"; Set paths = new HashSet(srcPaths.length); for (int i = 0; i < srcPaths.length; i++) { paths.add(fileToSVNPath(srcPaths[i], false)); } commandLine = appendPaths(commandLine, paths) + " " + dest; notificationHandler.logCommandLine(commandLine.toString()); notificationHandler.setBaseDir(); svnClient.copy(copySources, dest, copyAsChild, makeParents, true, null, new JhlCommitMessage(fixedMessage), null); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#copy(org.tigris.subversion.svnclientadapter.SVNUrl, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision) */ public void copy(SVNUrl srcUrl, File destPath, SVNRevision revision) throws SVNClientException { copy(srcUrl, destPath, revision, true, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#copy(org.tigris.subversion.svnclientadapter.SVNUrl, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, boolean, boolean) */ public void copy(SVNUrl srcUrl, File destPath, SVNRevision revision, boolean copyAsChild, boolean makeParents) throws SVNClientException { copy(srcUrl, destPath, revision, SVNRevision.HEAD, copyAsChild, makeParents); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#copy(org.tigris.subversion.svnclientadapter.SVNUrl, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean, boolean) */ public void copy(SVNUrl srcUrl, File destPath, SVNRevision revision, SVNRevision pegRevision, boolean copyAsChild, boolean makeParents) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.COPY); String dest = fileToSVNPath(destPath, false); List copySources = new ArrayList(); copySources.add(new CopySource(srcUrl.toString(), JhlConverter.convert(revision), JhlConverter.convert(pegRevision))); notificationHandler.logCommandLine("copy " + srcUrl + " " + dest); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(destPath)); svnClient.copy(copySources, dest, copyAsChild, makeParents, true, null, null, null); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#copy(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNUrl, java.lang.String, org.tigris.subversion.svnclientadapter.SVNRevision) */ public void copy( SVNUrl srcUrl, SVNUrl destUrl, String message, SVNRevision revision) throws SVNClientException { copy (srcUrl, destUrl, message, revision, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#copy(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNUrl, java.lang.String, org.tigris.subversion.svnclientadapter.SVNRevision) */ public void copy( SVNUrl srcUrl, SVNUrl destUrl, String message, SVNRevision revision, boolean makeParents) throws SVNClientException { copy(new SVNUrl[] { srcUrl }, destUrl, message, revision, true, makeParents); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#copy(org.tigris.subversion.svnclientadapter.SVNUrl[], org.tigris.subversion.svnclientadapter.SVNUrl, java.lang.String, org.tigris.subversion.svnclientadapter.SVNRevision, boolean, boolean) */ public void copy( SVNUrl[] srcUrls, SVNUrl destUrl, String message, SVNRevision revision, boolean copyAsChild, boolean makeParents) throws SVNClientException { try { String fixedMessage = fixSVNString(message); if (fixedMessage == null) fixedMessage = ""; notificationHandler.setCommand(ISVNNotifyListener.Command.COPY); List copySources = new ArrayList(srcUrls.length); for (int i = 0; i < srcUrls.length; i++) copySources.add(new CopySource(srcUrls[i].toString(), JhlConverter.convert(revision), JhlConverter.convert(SVNRevision.HEAD))); String dest = destUrl.toString(); String commandLine = "copy -r" + revision.toString(); Set paths = new HashSet(srcUrls.length); for (int i = 0; i < srcUrls.length; i++) { paths.add(srcUrls[i].toString()); } commandLine = appendPaths(commandLine, paths) + " " + dest; notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(); svnClient.copy(copySources, dest, copyAsChild, makeParents, true, null, new JhlCommitMessage(fixedMessage), null); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#remove(org.tigris.subversion.svnclientadapter.SVNUrl[], java.lang.String) */ public void remove(SVNUrl url[], String message) throws SVNClientException { try { String fixedMessage = fixSVNString(message); if (fixedMessage == null) fixedMessage = ""; notificationHandler.setCommand(ISVNNotifyListener.Command.REMOVE); String commandLine = "delete -m \""+getFirstMessageLine(fixedMessage)+"\""; Set targets = new HashSet(url.length); for (int i = 0; i < url.length;i++) { targets.add(url[i].toString()); } commandLine = appendPaths(commandLine, targets); notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(); svnClient.remove(targets,false, false, null, new JhlCommitMessage(fixedMessage), null); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#remove(java.io.File[], boolean) */ public void remove(File file[], boolean force) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.REMOVE); String commandLine = "delete"+(force?" --force":""); Set targets = new HashSet(file.length); for (int i = 0; i < file.length;i++) { targets.add(fileToSVNPath(file[i], false)); } commandLine = appendPaths(commandLine, targets); notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(file)); svnClient.remove(targets, force, false, null, null, null); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#doExport(org.tigris.subversion.svnclientadapter.SVNUrl, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public void doExport( SVNUrl srcUrl, File destPath, SVNRevision revision, boolean force) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.EXPORT); String src = srcUrl.toString(); String dest = fileToSVNPath(destPath, false); notificationHandler.logCommandLine( "export -r " + revision.toString() + ' ' + src + ' ' + dest); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(destPath)); svnClient.doExport(src, dest, JhlConverter.convert(revision), Revision.HEAD, force, false, Depth.infinity, null); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#doExport(java.io.File, java.io.File, boolean) */ public void doExport(File srcPath, File destPath, boolean force) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.EXPORT); String src = fileToSVNPath(srcPath, false); String dest = fileToSVNPath(destPath, false); notificationHandler.logCommandLine("export " + src + ' ' + dest); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(new File[]{srcPath,destPath })); // in this case, revision is not used but must be valid svnClient.doExport(src, dest, Revision.WORKING, Revision.BASE, force, false, Depth.infinity, null); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#doImport(java.io.File, org.tigris.subversion.svnclientadapter.SVNUrl, java.lang.String, boolean) */ public void doImport( File path, SVNUrl url, String message, boolean recurse) throws SVNClientException { try { String fixedMessage = fixSVNString(message); if (fixedMessage == null) fixedMessage = ""; notificationHandler.setCommand(ISVNNotifyListener.Command.IMPORT); String src = fileToSVNPath(path, false); String dest = url.toString(); notificationHandler.logCommandLine( "import -m \"" + getFirstMessageLine(fixedMessage) + "\" " + (recurse ? "" : "-N ") + src + ' ' + dest); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); svnClient.doImport(src, dest, Depth.infinityOrEmpty(recurse), false, true, null, new JhlCommitMessage(fixedMessage), null); notificationHandler.logCompleted(Messages.bind("notify.import.complete")); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#mkdir(org.tigris.subversion.svnclientadapter.SVNUrl, java.lang.String) */ public void mkdir(SVNUrl url, String message) throws SVNClientException { this.mkdir(url, false, message); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#mkdir(java.io.File) */ public void mkdir(File file) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.MKDIR); Set target = new HashSet(); target.add(fileToSVNPath(file, false)); notificationHandler.logCommandLine( "mkdir "+target); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(file)); svnClient.mkdir(target, false, null, null, null); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#move(java.io.File, java.io.File, boolean) */ public void move(File srcPath, File destPath, boolean force) throws SVNClientException { // use force when you want to move file even if there are local modifications try { notificationHandler.setCommand(ISVNNotifyListener.Command.MOVE); Set src = new HashSet(); src.add(fileToSVNPath(srcPath, false)); String dest = fileToSVNPath(destPath, false); notificationHandler.logCommandLine( "move "+fileToSVNPath(srcPath, false)+' '+dest); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(new File[] {srcPath, destPath})); svnClient.move(src,dest,force, false, false,null,null,null); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#move(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNUrl, java.lang.String, org.tigris.subversion.svnclientadapter.SVNRevision) */ public void move( SVNUrl srcUrl, SVNUrl destUrl, String message, SVNRevision revision) throws SVNClientException { try { String fixedMessage = fixSVNString(message); // NOTE: The revision arg is ignored as you cannot move // a specific revision, only HEAD. if (fixedMessage == null) fixedMessage = ""; notificationHandler.setCommand(ISVNNotifyListener.Command.MOVE); Set src = new HashSet(); src.add(srcUrl.toString()); String dest = destUrl.toString(); notificationHandler.logCommandLine( "move -m \"" + getFirstMessageLine(fixedMessage) + ' ' + srcUrl.toString() + ' ' + dest); notificationHandler.setBaseDir(); svnClient.move(src, dest, false, false, false, null, new JhlCommitMessage(fixedMessage), null); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#update(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public long update(File path, SVNRevision revision, boolean recurse) throws SVNClientException { return update(path, revision, Depth.unknownOrFiles(recurse).ordinal(), false, false, true); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#update(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, int, boolean, boolean, boolean) */ public long update(File path, SVNRevision revision, int depth, boolean setDepth, boolean ignoreExternals, boolean force) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.UPDATE); Set target = new HashSet(); String t = fileToSVNPath(path, false); target.add(t); Depth d = JhlConverter.depth(depth); StringBuffer commandLine; if (d == Depth.exclude) commandLine = new StringBuffer("update " + t + " --set-depth=exclude"); else { commandLine = new StringBuffer("update " + t + " -r " + revision.toString() + depthCommandLine(d)); if (ignoreExternals) commandLine.append(" --ignore-externals"); if (force) commandLine.append(" --force"); } notificationHandler.logCommandLine(commandLine.toString()); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); boolean makeParents = false; long rev[] = svnClient.update(target, JhlConverter.convert(revision), d, setDepth, makeParents, ignoreExternals, force); return rev[0]; } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#update(java.io.File[], org.tigris.subversion.svnclientadapter.SVNRevision, boolean, boolean) */ public long[] update(File[] path, SVNRevision revision, boolean recurse, boolean ignoreExternals) throws SVNClientException { return update(path, revision, Depth.unknownOrFiles(recurse).ordinal(), false, ignoreExternals, true); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#update(java.io.File[], org.tigris.subversion.svnclientadapter.SVNRevision, int, boolean, boolean) */ public long[] update(File[] path, SVNRevision revision, int depth, boolean setDepth, boolean ignoreExternals, boolean force) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.UPDATE); Set targets = new HashSet(path.length); for (int i = 0; i < path.length; i++) { targets.add(fileToSVNPath(path[i], false)); } Depth d = JhlConverter.depth(depth); StringBuffer commandLine = new StringBuffer(appendPaths("update ", targets) + " -r " + revision.toString() + depthCommandLine(d)); if (ignoreExternals) commandLine.append(" --ignore-externals"); if (force) commandLine.append(" --force"); notificationHandler.logCommandLine(commandLine.toString()); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); notificationHandler.holdStats(); boolean makeParents = false; long[] rtnCode = svnClient.update(targets, JhlConverter.convert(revision), d, setDepth, makeParents, ignoreExternals, force); notificationHandler.releaseStats(); return rtnCode; } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#revert(java.io.File, boolean) */ public void revert(File path, boolean recurse) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.REVERT); String target = fileToSVNPath(path, false); notificationHandler.logCommandLine( "revert "+ (recurse?"":"-N ")+ target); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); svnClient.revert(target,Depth.infinityOrEmpty(recurse), null); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getContent(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision) */ public InputStream getContent(SVNUrl url, SVNRevision revision, SVNRevision pegRevision) throws SVNClientException { try { notificationHandler.setCommand( ISVNNotifyListener.Command.CAT); String commandLine = "cat -r " + revision + " " + url; if (pegRevision != null) { commandLine = commandLine + "@" + pegRevision; } notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(); byte[] contents = svnClient.fileContent(url.toString(), JhlConverter.convert(revision), JhlConverter.convert(pegRevision)); InputStream input = new ByteArrayInputStream(contents); return input; } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getContent(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision) */ public InputStream getContent(SVNUrl url, SVNRevision revision) throws SVNClientException { return getContent(url, revision, SVNRevision.HEAD); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getContent(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision) */ public InputStream getContent(File path, SVNRevision revision) throws SVNClientException { try { String target = fileToSVNPath(path, false); notificationHandler.setCommand( ISVNNotifyListener.Command.CAT); notificationHandler.logCommandLine( "cat -r " + revision.toString() + " " + target); notificationHandler.setBaseDir(); if (revision.equals(SVNRevision.BASE)) { // This is to work-around a JavaHL problem when trying to // retrieve the base revision of a newly added file. ISVNStatus status = getSingleStatus(path); if (status.getTextStatus().equals(SVNStatusKind.ADDED)) return new ByteArrayInputStream(new byte[0]); } byte[] contents = svnClient.fileContent(target, JhlConverter.convert(revision), Revision.BASE); InputStream input = new ByteArrayInputStream(contents); return input; } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getProperties(java.io.File) */ public ISVNProperty[] getProperties(File path) throws SVNClientException { return getProperties(path, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getProperties(java.io.File) */ public ISVNProperty[] getProperties(File path, boolean descend) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.PROPLIST); String target = fileToSVNPath(path, false); StringBuffer commandLine = new StringBuffer("propList "); if (descend) { commandLine.append(" -R "); } commandLine.append(target); notificationHandler.logCommandLine(commandLine.toString()); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); JhlProplistCallback callback = new JhlProplistCallback(true); if (descend) { svnClient.properties(target, null, null, Depth.infinity, null, callback); } else { svnClient.properties(target, null, null, Depth.empty, null, callback); } return callback.getPropertyData(); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getProperties(org.tigris.subversion.svnclientadapter.SVNUrl) */ public ISVNProperty[] getProperties(SVNUrl url) throws SVNClientException { return getProperties(url, SVNRevision.HEAD, SVNRevision.HEAD); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getProperties(org.tigris.subversion.svnclientadapter.SVNUrl) */ public ISVNProperty[] getProperties(SVNUrl url, SVNRevision revision, SVNRevision pegRevision) throws SVNClientException { return getProperties(url, revision, pegRevision, true); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getProperties(org.tigris.subversion.svnclientadapter.SVNUrl) */ public ISVNProperty[] getProperties(SVNUrl url, SVNRevision revision, SVNRevision pegRevision, boolean recurse) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.PROPLIST); String target = url.toString(); notificationHandler.logCommandLine( "proplist "+ target); notificationHandler.setBaseDir(); JhlProplistCallback callback = new JhlProplistCallback(false); Depth depth; if (recurse) { depth = Depth.infinity; } else { depth = Depth.empty; } svnClient.properties(target, JhlConverter.convert(revision), JhlConverter.convert(pegRevision), depth, null, callback); return callback.getPropertyData(); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#propertySet(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision.Number,java.lang.String, java.lang.String, java.lang.String) */ public void propertySet( SVNUrl url, SVNRevision.Number baseRev, String propertyName, String propertyValue, String message) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.PROPSET); if (propertyName.startsWith("svn:")) { // Normalize line endings in property value svnClient.propertySetRemote(url.toString(), baseRev.getNumber(), propertyName, fixSVNString(propertyValue).getBytes(), new JhlCommitMessage(message), false, null, new JhlCommitCallback()); } else { svnClient.propertySetRemote(url.toString(), baseRev.getNumber(), propertyName, propertyValue.getBytes(), new JhlCommitMessage(message), false, null, new JhlCommitCallback()); } } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#propertySet(java.io.File, java.lang.String, java.lang.String, boolean) */ public void propertySet( File path, String propertyName, String propertyValue, boolean recurse) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.PROPSET); String target = fileToSVNPath(path, false); notificationHandler.logCommandLine( "propset " + (recurse?"-R ":"") + propertyName + " \"" + propertyValue + "\" " + target); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); Set statusBefore = null; if (recurse) { statusBefore = new HashSet(); ISVNStatus[] statuses = getStatus(path,recurse,false); for (int i = 0; i < statuses.length;i++) { statusBefore.add(statuses[i].getFile().getAbsolutePath()); } } Set paths = new HashSet(1); paths.add(target); if (propertyName.startsWith("svn:")) { // Normalize line endings in property value svnClient.propertySetLocal(paths, propertyName, fixSVNString(propertyValue).getBytes(), Depth.infinityOrEmpty(recurse), null, false); } else { svnClient.propertySetLocal(paths, propertyName, propertyValue.getBytes(), Depth.infinityOrEmpty(recurse), null, false); } // there is no notification (Notify.notify is not called) when we set a property // so we will do notification ourselves if (recurse) { ISVNStatus[] statuses = getStatus(path,recurse,false); for (int i = 0; i < statuses.length;i++) { String statusPath = statuses[i].getFile().getAbsolutePath(); notificationHandler.notifyListenersOfChange(statusPath); statusBefore.remove(statusPath); } for (String status : statusBefore) notificationHandler.notifyListenersOfChange(status); } else { notificationHandler.notifyListenersOfChange(path.getAbsolutePath()); } } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#propertySet(java.io.File, java.lang.String, java.io.File, boolean) */ public void propertySet( File path, String propertyName, File propertyFile, boolean recurse) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.PROPSET); String target = fileToSVNPath(path, false); notificationHandler.logCommandLine( "propset " + (recurse?"-R ":"") + propertyName + "-F \"" + propertyFile.toString() + "\" " + target); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); byte[] propertyBytes = new byte[(int) propertyFile.length()]; FileInputStream is = null; try { is = new FileInputStream(propertyFile); is.read(propertyBytes); } catch (IOException ioe) { throw new SVNClientException(ioe); } finally { if (is != null) { try { is.close(); } catch (IOException e) { // ignore } } } Set statusBefore = null; if (recurse) { statusBefore = new HashSet(); ISVNStatus[] statuses = getStatus(path,recurse,false); for (int i = 0; i < statuses.length;i++) { statusBefore.add(statuses[i].getFile().getAbsolutePath()); } } Set paths = new HashSet(1); paths.add(target); svnClient.propertySetLocal(paths, propertyName, propertyBytes, Depth.infinityOrEmpty(recurse), null, false); // there is no notification (Notify.notify is not called) when we set a property // so we will do notification ourselves if (recurse) { ISVNStatus[] statuses = getStatus(path,recurse,false); for (int i = 0; i < statuses.length;i++) { String statusPath = statuses[i].getFile().getAbsolutePath(); notificationHandler.notifyListenersOfChange(statusPath); statusBefore.remove(statusPath); } for (String status : statusBefore) notificationHandler.notifyListenersOfChange(status); } else { notificationHandler.notifyListenersOfChange(path.getAbsolutePath()); } } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#propertyGet(java.io.File, java.lang.String) */ public ISVNProperty propertyGet(File path, String propertyName) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.PROPGET); String target = fileToSVNPath(path, false); notificationHandler.logCommandLine( "propget " + propertyName + " " + target); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); byte[] bytes = svnClient.propertyGet(target, propertyName, null, null); if (bytes == null) return null; else return JhlPropertyData.newForFile(target, propertyName, bytes); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#propertyGet(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, java.lang.String) */ public ISVNProperty propertyGet(SVNUrl url, SVNRevision revision, SVNRevision peg, String propertyName) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.PROPGET); String target = url.toString(); String commandLine = "propget -r " + revision.toString() + " " + propertyName + " " + target; if (!peg.equals(SVNRevision.HEAD)) commandLine += "@" + peg.toString(); notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(); byte[] bytes = svnClient.propertyGet(target, propertyName, JhlConverter.convert(revision), JhlConverter.convert(peg)); if (bytes == null) return null; else return JhlPropertyData.newForUrl(target, propertyName, bytes); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#propertyDel(java.io.File, java.lang.String, boolean) */ public void propertyDel(File path, String propertyName,boolean recurse) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.PROPDEL); String target = fileToSVNPath(path, false); notificationHandler.logCommandLine("propdel "+propertyName+" "+target); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); Set statusBefore = null; if (recurse) { statusBefore = new HashSet(); ISVNStatus[] statuses = getStatus(path,recurse,false); for (int i = 0; i < statuses.length;i++) { statusBefore.add(statuses[i].getFile().getAbsolutePath()); } } Set paths = new HashSet(1); paths.add(target); svnClient.propertySetLocal(paths, propertyName, null, Depth.infinityOrEmpty(recurse), null, true); // there is no notification (Notify.notify is not called) when we set a property // so we will do notification ourselves if (recurse) { ISVNStatus[] statuses = getStatus(path,recurse,false); for (int i = 0; i < statuses.length;i++) { String statusPath = statuses[i].getFile().getAbsolutePath(); notificationHandler.notifyListenersOfChange(statusPath); statusBefore.remove(statusPath); } for (String status : statusBefore) notificationHandler.notifyListenersOfChange(status); } else { notificationHandler.notifyListenersOfChange(path.getAbsolutePath()); } } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean) */ public void diff(File oldPath, SVNRevision oldPathRevision, File newPath, SVNRevision newPathRevision, File outFile, boolean recurse) throws SVNClientException { diff(oldPath, oldPathRevision, newPath, newPathRevision, outFile, recurse, true, false, false); } private void diffRelative(File oldPath, SVNRevision oldPathRevision, File newPath, SVNRevision newPathRevision, File outFile, boolean recurse, boolean ignoreAncestry, boolean noDiffDeleted, boolean force, File relativeTo) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF); if (oldPath == null) oldPath = new File("."); if (newPath == null) newPath = oldPath; if (oldPathRevision == null) oldPathRevision = SVNRevision.BASE; if (newPathRevision == null) newPathRevision = SVNRevision.WORKING; // we don't want canonical file path (otherwise the complete file name // would be in the patch). This way the user can choose to use a relative // path String oldTarget = fileToSVNPath(oldPath, false); String newTarget = fileToSVNPath(newPath, false); String svnOutFile = fileToSVNPath(outFile, false); String relativeToDir = fileToSVNPath(relativeTo, false); String commandLine = "diff "; if ( (oldPathRevision.getKind() != Revision.Kind.base.ordinal()) || (newPathRevision.getKind() != Revision.Kind.working.ordinal()) ) { commandLine += "-r "+oldPathRevision.toString(); if (newPathRevision.getKind() != Revision.Kind.working.ordinal()) commandLine+= ":"+newPathRevision.toString(); commandLine += " "; } if (!oldPath.equals(new File("."))) commandLine += "--old "+oldTarget+" "; if (!newPath.equals(oldPath)) commandLine += "--new "+newTarget+" "; int depth = Depth.empty.ordinal(); if (recurse) depth = Depth.infinity.ordinal(); else { if (oldPath.isFile()) depth = Depth.files.ordinal(); } notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(new File[]{oldPath,newPath})); svnClient.diff(oldTarget,JhlConverter.convert(oldPathRevision),newTarget,JhlConverter.convert(newPathRevision), relativeToDir, svnOutFile, JhlConverter.depth(depth), null, ignoreAncestry, noDiffDeleted, force, true); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean, boolean, boolean, boolean) */ public void diff(File oldPath, SVNRevision oldPathRevision, File newPath, SVNRevision newPathRevision, File outFile, boolean recurse, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF); if (oldPath == null) oldPath = new File("."); if (newPath == null) newPath = oldPath; if (oldPathRevision == null) oldPathRevision = SVNRevision.BASE; if (newPathRevision == null) newPathRevision = SVNRevision.WORKING; // we don't want canonical file path (otherwise the complete file name // would be in the patch). This way the user can choose to use a relative // path String oldTarget = fileToSVNPath(oldPath, false); String newTarget = fileToSVNPath(newPath, false); String svnOutFile = fileToSVNPath(outFile, false); String commandLine = "diff "; if ( (oldPathRevision.getKind() != Revision.Kind.base.ordinal()) || (newPathRevision.getKind() != Revision.Kind.working.ordinal()) ) { commandLine += "-r "+oldPathRevision.toString(); if (newPathRevision.getKind() != Revision.Kind.working.ordinal()) commandLine+= ":"+newPathRevision.toString(); commandLine += " "; } if (!oldPath.equals(new File("."))) commandLine += "--old "+oldTarget+" "; if (!newPath.equals(oldPath)) commandLine += "--new "+newTarget+" "; notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(new File[]{oldPath,newPath})); svnClient.diff(oldTarget,JhlConverter.convert(oldPathRevision),newTarget,JhlConverter.convert(newPathRevision), null, svnOutFile, Depth.infinityOrEmpty(recurse), null, ignoreAncestry, noDiffDeleted, force, true); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(java.io.File, java.io.File, boolean) */ public void diff(File path, File outFile, boolean recurse) throws SVNClientException { diff(path, null,null,null,outFile,recurse); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean) */ public void diff(SVNUrl oldUrl, SVNRevision oldUrlRevision, SVNUrl newUrl, SVNRevision newUrlRevision, File outFile, boolean recurse) throws SVNClientException { diff(oldUrl, oldUrlRevision, newUrl, newUrlRevision, outFile, recurse, true, false, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, int, boolean, boolean, boolean) */ public void diff(SVNUrl target, SVNRevision pegRevision, SVNRevision startRevision, SVNRevision endRevision, File outFile, int depth, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF); if (pegRevision == null) pegRevision = SVNRevision.HEAD; if (startRevision == null) startRevision = SVNRevision.HEAD; if (endRevision == null) endRevision = SVNRevision.HEAD; String commandLine = "diff "; Depth d = JhlConverter.depth(depth); commandLine += depthCommandLine(d); if (ignoreAncestry) commandLine += " --ignoreAncestry"; commandLine += " -r " + startRevision + ":" + endRevision + " " + target; notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(); svnClient.diff(target.toString(), JhlConverter.convert(pegRevision), JhlConverter.convert(startRevision), JhlConverter.convert(endRevision), null, outFile.getAbsolutePath(), d, null, ignoreAncestry, noDiffDeleted, force, false); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean) */ public void diff(SVNUrl target, SVNRevision pegRevision, SVNRevision startRevision, SVNRevision endRevision, File outFile, boolean recurse) throws SVNClientException { diff(target, pegRevision, startRevision, endRevision, outFile, Depth.infinityOrImmediates(recurse).ordinal(), true, false, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean, boolean, boolean, boolean) */ public void diff(SVNUrl oldUrl, SVNRevision oldUrlRevision, SVNUrl newUrl, SVNRevision newUrlRevision, File outFile, boolean recurse, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF); if (newUrl == null) newUrl = oldUrl; if (oldUrlRevision == null) oldUrlRevision = SVNRevision.HEAD; if (newUrlRevision == null) newUrlRevision = SVNRevision.HEAD; String svnOutFile = fileToSVNPath(outFile, false); String commandLine = "diff "; if ( (oldUrlRevision.getKind() != Revision.Kind.head.ordinal()) || (newUrlRevision.getKind() != Revision.Kind.head.ordinal()) ) { commandLine += "-r "+oldUrlRevision.toString(); if (newUrlRevision.getKind() != Revision.Kind.head.ordinal()) commandLine+= ":"+newUrlRevision.toString(); commandLine += " "; } commandLine += oldUrl+" "; if (!newUrl.equals(oldUrl)) commandLine += newUrl+" "; notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(); svnClient.diff(oldUrl.toString(),JhlConverter.convert(oldUrlRevision),newUrl.toString(),JhlConverter.convert(newUrlRevision), null, svnOutFile, Depth.infinityOrEmpty(recurse), null, ignoreAncestry, noDiffDeleted, force, false); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean) */ public void diff(SVNUrl url, SVNRevision oldUrlRevision, SVNRevision newUrlRevision, File outFile, boolean recurse) throws SVNClientException { diff(url,oldUrlRevision,url,newUrlRevision,outFile,recurse); } public ISVNAnnotations annotate(File file, SVNRevision revisionStart, SVNRevision revisionEnd, boolean ignoreMimeType, boolean includeMergedRevisions) throws SVNClientException { return annotate(file, revisionStart, revisionEnd, null, ignoreMimeType, includeMergedRevisions); } public ISVNAnnotations annotate(File file, SVNRevision revisionStart, SVNRevision revisionEnd, SVNRevision pegRevision, boolean ignoreMimeType, boolean includeMergedRevisions) throws SVNClientException { String target = fileToSVNPath(file, false); //If the file is an uncommitted rename/move, we have to refer to original/source, not the new copy. ISVNInfo info = getInfoFromWorkingCopy(file); if ((SVNScheduleKind.ADD == info.getSchedule()) && (info.getCopyUrl() != null)) { target = info.getCopyUrl().toString(); } return annotate(target, revisionStart, revisionEnd, pegRevision, ignoreMimeType, includeMergedRevisions); } public ISVNAnnotations annotate(SVNUrl url, SVNRevision revisionStart, SVNRevision revisionEnd, SVNRevision pegRevision, boolean ignoreMimeType, boolean includeMergedRevisions) throws SVNClientException { return annotate(url.toString(), revisionStart, revisionEnd, pegRevision, ignoreMimeType, includeMergedRevisions); } private ISVNAnnotations annotate(String target, SVNRevision revisionStart, SVNRevision revisionEnd, SVNRevision pegRevision, boolean ignoreMimeType, boolean includeMergedRevisions) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.ANNOTATE); if(revisionStart == null) revisionStart = new SVNRevision.Number(1); if(revisionEnd == null) revisionEnd = SVNRevision.HEAD; if (pegRevision == null) pegRevision = SVNRevision.HEAD; String commandLine = "blame "; if (includeMergedRevisions) commandLine += "-g "; commandLine = commandLine + "-r " + revisionStart.toString() + ":" + revisionEnd.toString() + " "; commandLine = commandLine + target + "@" + pegRevision; notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(); JhlAnnotations annotations = new JhlAnnotations(); svnClient.blame(target, JhlConverter.convert(pegRevision), JhlConverter.convert(revisionStart), JhlConverter.convert(revisionEnd), ignoreMimeType, includeMergedRevisions, annotations); return annotations; } catch (ClientException e) { if (includeMergedRevisions && ((ClientException)e).getAprError() == SVNClientException.UNSUPPORTED_FEATURE) { return annotate(target, revisionStart, revisionEnd, pegRevision, ignoreMimeType, false); } if (e.getAprError() == ErrorCodes.fsNotFound && pegRevision != null && !pegRevision.equals(revisionEnd)) { return annotate(target, revisionStart, pegRevision, pegRevision, ignoreMimeType, includeMergedRevisions); } else { notificationHandler.logException(e); throw new SVNClientException(e); } } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#annotate(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision) */ public ISVNAnnotations annotate(SVNUrl url, SVNRevision revisionStart, SVNRevision revisionEnd) throws SVNClientException { return annotate(url.toString(), revisionStart, revisionEnd, null, false, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#annotate(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision) */ public ISVNAnnotations annotate(File file, SVNRevision revisionStart, SVNRevision revisionEnd) throws SVNClientException { String target = fileToSVNPath(file, false); //If the file is an uncommitted rename/move, we have to refer to original/source, not the new copy. ISVNInfo info = getInfoFromWorkingCopy(file); if ((SVNScheduleKind.ADD == info.getSchedule()) && (info.getCopyUrl() != null)) { target = info.getCopyUrl().toString(); } return annotate(target, revisionStart, revisionEnd, null, false, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#resolved(java.io.File) */ public void resolved(File path) throws SVNClientException { this.resolve(path, ISVNConflictResolver.Choice.chooseMerged); } public void resolve(File path, int result) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.RESOLVE); String target = fileToSVNPath(path, true); String commandLine = "resolve "; ConflictResult.Choice choice = ConflictResult.Choice.chooseMerged; switch (result) { case ISVNConflictResolver.Choice.chooseMerged: commandLine += "--accept=working "; choice = ConflictResult.Choice.chooseMerged; break; case ISVNConflictResolver.Choice.chooseBase: commandLine += "--accept=base "; choice = ConflictResult.Choice.chooseBase; break; case ISVNConflictResolver.Choice.chooseTheirsFull: commandLine += "--accept=theirs-full "; choice = ConflictResult.Choice.chooseTheirsFull; break; case ISVNConflictResolver.Choice.chooseTheirs: commandLine += "--accept=theirs-conflict "; choice = ConflictResult.Choice.chooseTheirsConflict; break; case ISVNConflictResolver.Choice.chooseMineFull: commandLine += "--accept=mine-full "; choice = ConflictResult.Choice.chooseMineFull; break; case ISVNConflictResolver.Choice.chooseMine: commandLine += "--accept=mine-conflict "; choice = ConflictResult.Choice.chooseMineConflict; break; default: choice = ConflictResult.Choice.chooseMerged; break; } commandLine += target; notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); svnClient.resolve(target, Depth.empty, choice); } catch (SubversionException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#cancelOperation() */ public void cancelOperation() throws SVNClientException { try { svnClient.cancelOperation(); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getInfoFromWorkingCopy(java.io.File) */ public ISVNInfo getInfoFromWorkingCopy(File path) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.INFO); String target = fileToSVNPath(path, false); notificationHandler.logCommandLine("info "+target); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); JhlInfoCallback callback = new JhlInfoCallback(); svnClient.info2(target, null, null, Depth.empty, null, callback); ISVNInfo[] items = callback.getInfo(); if (items == null) { return new SVNInfoUnversioned(path); } return items[0]; } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getInfo(java.io.File) */ public ISVNInfo getInfo(File path) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.INFO); String target = fileToSVNPath(path, false); notificationHandler.logCommandLine("info "+target); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); JhlInfoCallback callback = new JhlInfoCallback(); svnClient.info2(target, Revision.WORKING, Revision.BASE, Depth.infinity, null, callback); ISVNInfo[] items = callback.getInfo(); if (items == null || items.length == 0) { return new SVNInfoUnversioned(path); } else { return items[0]; } } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getInfo(java.io.File, boolean) */ public ISVNInfo[] getInfo(File path, boolean descend) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.INFO); String target = fileToSVNPath(path, false); if (descend) notificationHandler.logCommandLine("info " + target + " --depth=infinity"); else notificationHandler.logCommandLine("info " + target); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); JhlInfoCallback callback = new JhlInfoCallback(); svnClient.info2(target, null, null, Depth.infinityOrEmpty(descend), null, callback); ISVNInfo[] items = callback.getInfo(); if (items == null) { return new ISVNInfo[]{new SVNInfoUnversioned(path)}; } else { return items; } } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getInfo(org.tigris.subversion.svnclientadapter.SVNUrl) */ public ISVNInfo getInfo(SVNUrl url, SVNRevision revision, SVNRevision peg) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.INFO); String target = url.toString(); notificationHandler.logCommandLine("info "+target); // notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(url)); JhlInfoCallback callback = new JhlInfoCallback(); svnClient.info2(target, JhlConverter.convert(revision), JhlConverter.convert(peg), Depth.empty, null, callback); ISVNInfo[] items = callback.getInfo(); if (items == null || items.length == 0) { return new SVNInfoUnversioned(null); } else { return items[0]; } } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#switchUrl(org.tigris.subversion.svnclientadapter.SVNUrl, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public void switchToUrl(File path, SVNUrl url, SVNRevision revision, boolean recurse) throws SVNClientException { switchToUrl(path, url, revision, Depth.unknownOrFiles(recurse).ordinal(), false, false, true); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#switchUrl(org.tigris.subversion.svnclientadapter.SVNUrl, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, int, boolean, boolean, boolean) */ public void switchToUrl(File path, SVNUrl url, SVNRevision revision, int depth, boolean setDepth, boolean ignoreExternals, boolean force) throws SVNClientException { switchToUrl(path, url, revision, revision, depth, setDepth, ignoreExternals, force); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#switchUrl(org.tigris.subversion.svnclientadapter.SVNUrl, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, int, boolean, boolean, boolean) */ public void switchToUrl(File path, SVNUrl url, SVNRevision revision, SVNRevision pegRevision, int depth, boolean setDepth, boolean ignoreExternals, boolean force) throws SVNClientException { switchToUrl(path, url, revision, pegRevision, depth, setDepth, ignoreExternals, force, false); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#switchUrl(org.tigris.subversion.svnclientadapter.SVNUrl, java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, int, boolean, boolean, boolean, boolean) */ public void switchToUrl(File path, SVNUrl url, SVNRevision revision, SVNRevision pegRevision, int depth, boolean setDepth, boolean ignoreExternals, boolean force, boolean ignoreAncestry) throws SVNClientException { if (depth == Depth.exclude.ordinal()) { update(path, pegRevision, depth, true, ignoreExternals, force); return; } try { notificationHandler.setCommand(ISVNNotifyListener.Command.SWITCH); Depth d = JhlConverter.depth(depth); String target = fileToSVNPath(path, false); StringBuffer commandLine = new StringBuffer("switch " + url + " " + target + " -r " + revision.toString() + depthCommandLine(d)); if (ignoreExternals) commandLine.append(" --ignore-externals"); if (force) commandLine.append(" --force"); notificationHandler.logCommandLine(commandLine.toString()); File baseDir = SVNBaseDir.getBaseDir(path); notificationHandler.setBaseDir(baseDir); Revision rev = JhlConverter.convert(revision); Revision pegRev = JhlConverter.convert(pegRevision); svnClient.doSwitch(target, url.toString(),rev,pegRev,d, setDepth, ignoreExternals, force, ignoreAncestry); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#setConfigDirectory(java.io.File) */ public void setConfigDirectory(File dir) throws SVNClientException { try { svnClient.setConfigDirectory(fileToSVNPath(dir,false)); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#cleanup(java.io.File) */ public void cleanup(File path) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.CLEANUP); String target = fileToSVNPath(path, false); String commandLine = "cleanup " + target; notificationHandler.logCommandLine(commandLine); svnClient.cleanup(target); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#upgrade(java.io.File) */ public void upgrade(File path) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.UPGRADE); String target = fileToSVNPath(path, false); String commandLine = "upgrade " + target; notificationHandler.logCommandLine(commandLine); svnClient.upgrade(target); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#merge(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean, boolean, boolean, boolean) */ public void merge(SVNUrl path1, SVNRevision revision1, SVNUrl path2, SVNRevision revision2, File localPath, boolean force, boolean recurse, boolean dryRun, boolean ignoreAncestry) throws SVNClientException { merge(path1, revision1, path2, revision2, localPath, force, Depth.infinityOrFiles(recurse).ordinal(), dryRun, ignoreAncestry, false); } public void merge(SVNUrl path1, SVNRevision revision1, SVNUrl path2, SVNRevision revision2, SVNRevision pegRevision, File localPath, boolean force, int depth, boolean dryRun, boolean ignoreAncestry, boolean recordOnly) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.MERGE); Depth d = JhlConverter.depth(depth); String target = fileToSVNPath(localPath, false); String commandLine = "merge"; boolean samePath = false; if (dryRun) { commandLine += " --dry-run"; } commandLine += depthCommandLine(d); if (force) { commandLine += " --force"; } if (ignoreAncestry) { commandLine += " --ignore-ancestry"; } if (path1.toString().equals(path2.toString())) { samePath = true; if (revision1 == null || revision2 == null) commandLine += " " + path1; else commandLine += " -r" + revision1.toString() + ":" + revision2.toString() + " " + path1; } else { commandLine += " " + path1 + "@" + revision1.toString() + " " + path2 + "@" + revision2.toString(); } commandLine += " " + target; notificationHandler.logCommandLine(commandLine); File baseDir = SVNBaseDir.getBaseDir(localPath); notificationHandler.setBaseDir(baseDir); if (samePath) { Revision rev1; Revision rev2; if (revision1 == null) rev1 = Revision.START; else rev1 = JhlConverter.convert(revision1); if (revision2 == null) rev2 = Revision.START; else rev2 = JhlConverter.convert(revision2); List revisionRanges = new ArrayList(); revisionRanges.add(new RevisionRange(rev1, rev2)); svnClient.merge(path1.toString(), JhlConverter.convert(pegRevision), revisionRanges, target, force, d, ignoreAncestry, dryRun, recordOnly ); } else svnClient.merge(path1.toString(), JhlConverter.convert(revision1), path2.toString(), JhlConverter.convert(revision2), target, force, d, ignoreAncestry, dryRun, recordOnly ); if (dryRun) notificationHandler.logCompleted("Dry-run merge complete."); else notificationHandler.logCompleted("Merge complete."); } catch (ClientException e) { notificationHandler.logException(e); if (dryRun) notificationHandler.logCompleted("Dry-run merge completed abnormally."); else notificationHandler.logCompleted("Merge completed abnormally."); SVNClientException svnClientException = new SVNClientException(e); svnClientException.setAprError(e.getAprError()); throw svnClientException; } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#merge(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean, int, boolean, boolean) */ public void merge(SVNUrl path1, SVNRevision revision1, SVNUrl path2, SVNRevision revision2, File localPath, boolean force, int depth, boolean dryRun, boolean ignoreAncestry, boolean recordOnly) throws SVNClientException { SVNUrlWithPegRevision svnUrlWithPegRevision = new SVNUrlWithPegRevision(path1); SVNRevision pegRevision = svnUrlWithPegRevision.getPegRevision(); if (pegRevision == null) { if (revision2 == null) pegRevision = SVNRevision.HEAD; else pegRevision = revision2; } merge(svnUrlWithPegRevision.getUrl(), revision1, new SVNUrlWithPegRevision(path2).getUrl(), revision2, pegRevision, localPath, force, depth, dryRun, ignoreAncestry, recordOnly); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#mergeReintegrate(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean, boolean) */ public void mergeReintegrate(SVNUrl path, SVNRevision pegRevision, File localPath, boolean force, boolean dryRun) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.MERGE); String target = fileToSVNPath(localPath, false); String commandLine = "merge --reintegrate"; if (dryRun) { commandLine += " --dry-run"; } if (force) { commandLine += " --force"; } commandLine += " " + path + " " + target; notificationHandler.logCommandLine(commandLine); File baseDir = SVNBaseDir.getBaseDir(localPath); notificationHandler.setBaseDir(baseDir); Revision peg = JhlConverter.convert(pegRevision); if (peg == null) peg = Revision.HEAD; svnClient.mergeReintegrate(path.toString(), peg, target, dryRun); if (dryRun) notificationHandler.logCompleted("Dry-run merge complete."); else notificationHandler.logCompleted("Merge complete."); } catch (ClientException e) { notificationHandler.logException(e); if (dryRun) notificationHandler.logCompleted("Dry-run merge completed abnormally."); else notificationHandler.logCompleted("Merge completed abnormally."); SVNClientException svnClientException = new SVNClientException(e); svnClientException.setAprError(e.getAprError()); throw svnClientException; } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#addPasswordCallback(org.tigris.subversion.svnclientadapter.ISVNPromptUserPassword) */ public void addPasswordCallback(ISVNPromptUserPassword callback) { if (callback != null) { JhlPromptUserPassword prompt = new JhlPromptUserPassword(callback); this.setPromptUserPassword(prompt); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#lock(org.tigris.subversion.svnclientadapter.SVNUrl[], java.lang.String, boolean) */ public void lock(SVNUrl[] uris, String comment, boolean force) throws SVNClientException { notImplementedYet(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#unlock(org.tigris.subversion.svnclientadapter.SVNUrl[], boolean) */ public void unlock(SVNUrl[] uris, boolean force) throws SVNClientException { notImplementedYet(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#lock(java.lang.String[], java.lang.String, boolean) */ public void lock(File[] paths, String comment, boolean force) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.LOCK); Set files = new HashSet(paths.length); String commandLine = "lock -m \""+comment+"\""; if (force) commandLine+=" --force"; for (int i = 0; i < paths.length; i++) { files.add(fileToSVNPath(paths[i], false)); } commandLine = appendPaths(commandLine, files); notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(paths)); svnClient.lock(files, comment, force); for (String file : files) { notificationHandler.notifyListenersOfChange(file); } } catch (ClientException e) { notificationHandler.logException(e); // throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#unlock(java.io.File[], boolean) */ public void unlock(File[] paths, boolean force) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.LOCK); Set files = new HashSet(paths.length); String commandLine = "unlock "; if (force) commandLine+=" --force"; for (int i = 0; i < paths.length; i++) { files.add(fileToSVNPath(paths[i], false)); } commandLine = appendPaths(commandLine, files); notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(paths)); svnClient.unlock(files, force); for (String file : files) { notificationHandler.notifyListenersOfChange(file); } } catch (ClientException e) { notificationHandler.logException(e); // throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#setRevProperty(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision.Number, java.lang.String, java.lang.String, boolean) */ public void setRevProperty(SVNUrl url, SVNRevision.Number revisionNo, String propName, String propertyData, boolean force) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.PROPSET); notificationHandler.logCommandLine( "propset --revprop -r " + revisionNo.toString() + (force ? " --force " : "") + " \"" + propName + "\" \"" + propertyData + "\" " + url.toString()); notificationHandler.setBaseDir(); if (propName.startsWith("svn:")) { svnClient.setRevProperty(url.toString(), propName, Revision.getInstance(revisionNo.getNumber()), fixSVNString(propertyData), null, true); } else { svnClient.setRevProperty(url.toString(), propName, Revision.getInstance(revisionNo.getNumber()), propertyData, null, true); } } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getRevProperty(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision.Number) */ public String getRevProperty(SVNUrl url, SVNRevision.Number revisionNo, String propName) throws SVNClientException { String propData = null; try { notificationHandler.setCommand(ISVNNotifyListener.Command.PROPGET); notificationHandler.logCommandLine( "propget --revprop -r " + revisionNo.toString() + " \"" + propName + "\" " + url.toString()); notificationHandler.setBaseDir(); byte[] bytes = svnClient.revProperty(url.toString(), propName, Revision.getInstance(revisionNo.getNumber())); //setRevProperty(url.toString(), propName, Revision.getInstance(revisionNo.getNumber()), fixSVNString(propertyData), true); try { // Assume property data is UTF8. Technically, only svn: props are forced // to be UTF8. propData = new String(bytes, "UTF8"); } catch (UnsupportedEncodingException e) { propData = new String(bytes); } if (propName.startsWith("svn:")) { fixSVNString(propData); } } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } return propData; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getRevProperties(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision.Number) */ public ISVNProperty[] getRevProperties(SVNUrl url, SVNRevision.Number revisionNo) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.PROPLIST); String target = url.toString(); notificationHandler.logCommandLine( "proplist --revprop -r " + revisionNo.toString() + target); notificationHandler.setBaseDir(); Map propertiesData = svnClient.revProperties(target, Revision.getInstance(revisionNo.getNumber())); if (propertiesData == null) { // no properties return new JhlPropertyData[0]; } Set keys = propertiesData.keySet(); JhlPropertyData[] svnProperties = new JhlPropertyData[keys.size()]; int i=0; for (String key : keys) { svnProperties[i] = JhlPropertyData.newForUrl(target, key, propertiesData.get(key)); i++; } return svnProperties; } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getAdminDirectoryName() */ public String getAdminDirectoryName() { return svnClient.getAdminDirectoryName(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#isAdminDirectory(java.lang.String) */ public boolean isAdminDirectory(String name) { return svnClient.isAdminDirectory(name); } private void getLogMessages(String target, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions, String[] requestedProperties, ISVNLogMessageCallback worker) throws SVNClientException { try { notificationHandler.setCommand( ISVNNotifyListener.Command.LOG); String logExtras = ""; if (includeMergedRevisions) logExtras = logExtras + " -g"; if (stopOnCopy) logExtras = logExtras + " --stop-on-copy"; if (limit > 0 ) logExtras = logExtras + " --limit " + limit; notificationHandler.logCommandLine( "log -r " + revisionStart.toString() + ":" + revisionEnd.toString() + " " + target + logExtras); JhlLogMessageCallback callback = new JhlLogMessageCallback(worker); Set revProps = new HashSet(requestedProperties.length); for (int i = 0; i < requestedProperties.length; i++) { revProps.add(requestedProperties[i]); } List range = new ArrayList(); range.add(new RevisionRange(JhlConverter.convert(revisionStart), JhlConverter.convert(revisionEnd))); svnClient.logMessages(target, JhlConverter.convert(pegRevision), range, stopOnCopy, fetchChangePath, includeMergedRevisions, revProps, limit, callback); } catch (ClientException e) { if (e.getAprError() == ErrorCodes.unsupportedFeature && includeMergedRevisions) { getLogMessages(target, pegRevision, revisionStart, revisionEnd, stopOnCopy, fetchChangePath, limit, false, requestedProperties, worker); } else { if ((e.getAprError() == ErrorCodes.fsNotFound || e.getAprError() == ErrorCodes.clientUnrelatedResources) && pegRevision != null && !pegRevision.equals(revisionStart)) { getLogMessages(target, pegRevision, pegRevision, revisionEnd, stopOnCopy, fetchChangePath, limit, includeMergedRevisions, requestedProperties, worker); } else { notificationHandler.logException(e); throw new SVNClientException(e); } } } } public void getLogMessages( File path, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions, String [] requestedProperties, ISVNLogMessageCallback worker) throws SVNClientException { String target = fileToSVNPath(path, false); notificationHandler.setBaseDir(); this.getLogMessages(target, pegRevision, revisionStart, revisionEnd, stopOnCopy, fetchChangePath, limit, includeMergedRevisions, requestedProperties, worker); } public void getLogMessages( SVNUrl url, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions, String [] requestedProperties, ISVNLogMessageCallback worker) throws SVNClientException { String target = url.toString(); notificationHandler.setBaseDir(); this.getLogMessages(target, pegRevision, revisionStart, revisionEnd, stopOnCopy, fetchChangePath, limit, includeMergedRevisions, requestedProperties, worker); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#relocate(java.lang.String, java.lang.String, java.lang.String, boolean) */ public void relocate(String from, String to, String path, boolean recurse) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.RELOCATE); notificationHandler.logCommandLine("switch --relocate "+ from + " " + to + " " + path); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(new File(path))); boolean ignoreAncestry = false; svnClient.relocate(from, to, path, ignoreAncestry); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#diff(java.io.File, org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean) */ public void diff(File path, SVNUrl url, SVNRevision urlRevision, File outFile, boolean recurse) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF); // we don't want canonical file path (otherwise the complete file name // would be in the patch). This way the user can choose to use a relative // path String wcPath = fileToSVNPath(path, false); String svnOutFile = fileToSVNPath(outFile, false); String commandLine = "diff --old " + wcPath + " "; commandLine += "--new " + url.toString(); if (!urlRevision.equals(SVNRevision.HEAD)) commandLine += "@"+ urlRevision.toString(); notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path)); svnClient.diff(wcPath,Revision.WORKING,url.toString(),JhlConverter.convert(urlRevision), null, svnOutFile, Depth.infinityOrEmpty(recurse), null, false, true, false, true); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } public void mkdir(SVNUrl url, boolean makeParents, String message) throws SVNClientException { try { String fixedMessage = fixSVNString(message); if (fixedMessage == null) fixedMessage = ""; notificationHandler.setCommand(ISVNNotifyListener.Command.MKDIR); Set target = new HashSet(); target.add(url.toString()); if (makeParents) notificationHandler.logCommandLine( "mkdir --parents -m \""+getFirstMessageLine(fixedMessage)+"\" "+target); else notificationHandler.logCommandLine( "mkdir -m \""+getFirstMessageLine(fixedMessage)+"\" "+target); notificationHandler.setBaseDir(); svnClient.mkdir(target, makeParents, null, new JhlCommitMessage(fixedMessage), null); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } public void merge(SVNUrl url, SVNRevision pegRevision, SVNRevisionRange[] revisions, File localPath, boolean force, int depth, boolean ignoreAncestry, boolean dryRun, boolean recordOnly) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.MERGE); String target = fileToSVNPath(localPath, false); String commandLine = "merge"; if (dryRun) { commandLine += " --dry-run"; } Depth d = JhlConverter.depth(depth); commandLine += depthCommandLine(d); if (force) { commandLine += " --force"; } if (ignoreAncestry) { commandLine += " --ignore-ancestry"; } List range = JhlConverter.convert(revisions); for (int i = 0; i < revisions.length; i++) { commandLine += " " + revisions[i].toMergeString(); } commandLine += " " + url.toString(); commandLine += " " + target; notificationHandler.logCommandLine(commandLine); File baseDir = SVNBaseDir.getBaseDir(localPath); notificationHandler.setBaseDir(baseDir); Revision peg = JhlConverter.convert(pegRevision); if (peg == null) peg = Revision.HEAD; svnClient.merge(url.toString(), peg, range, target, force, d, ignoreAncestry, dryRun, recordOnly); if (dryRun) notificationHandler.logCompleted("Dry-run merge complete."); else notificationHandler.logCompleted("Merge complete."); } catch (ClientException e) { notificationHandler.logException(e); if (dryRun) notificationHandler.logCompleted("Dry-run merge completed abnormally."); else notificationHandler.logCompleted("Merge completed abnormally."); SVNClientException svnClientException = new SVNClientException(e); svnClientException.setAprError(e.getAprError()); throw svnClientException; } } private String depthCommandLine(Depth depth) { switch (depth) { case empty: return " --depth=empty"; case files: return " --depth=files"; case immediates: return " --depth=immediates"; case infinity: return " --depth=infinity"; case exclude: return " --depth=exclude"; default: return ""; } } public ISVNMergeInfo getMergeInfo(File path, SVNRevision revision) throws SVNClientException { return this.getMergeInfo(fileToSVNPath(path, false), JhlConverter.convert(revision)); } public ISVNMergeInfo getMergeInfo(SVNUrl url, SVNRevision revision) throws SVNClientException { return this.getMergeInfo(url.toString(), JhlConverter.convert(revision)); } private ISVNMergeInfo getMergeInfo(String path, Revision revision) throws SVNClientException { try { Mergeinfo info = svnClient.getMergeinfo(path, revision); if (info == null) return null; return new JhlMergeInfo(info); } catch (SubversionException e) { throw new SVNClientException(e); } } public void addConflictResolutionCallback(ISVNConflictResolver callback) { if (callback == null) conflictResolver = null; else conflictResolver = new JhlConflictResolver(callback); svnClient.setConflictResolver(conflictResolver); } public void setProgressListener(ISVNProgressListener listener) { progressListener.setWorker(listener); } private SVNDiffSummary[] diffSummarize(String target1, SVNRevision revision1, String target2, SVNRevision revision2, int depth, boolean ignoreAncestry) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF); if (revision1 == null) revision1 = SVNRevision.HEAD; if (revision2 == null) revision2 = SVNRevision.HEAD; String commandLine = "diff --summarize"; Depth d = JhlConverter.depth(depth); commandLine += depthCommandLine(d); if (ignoreAncestry) commandLine += " --ignoreAncestry"; commandLine += " " + target1 + "@" + revision1 + " " + target2 + "@" + revision2; notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(); JhlDiffSummaryReceiver callback = new JhlDiffSummaryReceiver(); svnClient.diffSummarize(target1, JhlConverter.convert(revision1), target2, JhlConverter.convert(revision2), d, null, ignoreAncestry, callback); return callback.getDiffSummary(); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } private SVNDiffSummary[] diffSummarize(String target, SVNRevision pegRevision, SVNRevision startRevision, SVNRevision endRevision, int depth, boolean ignoreAncestry) throws SVNClientException { try { notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF); if (pegRevision == null) pegRevision = SVNRevision.HEAD; if (startRevision == null) startRevision = SVNRevision.HEAD; if (endRevision == null) endRevision = SVNRevision.HEAD; String commandLine = "diff --summarize"; Depth d = JhlConverter.depth(depth); commandLine += depthCommandLine(d); if (ignoreAncestry) commandLine += " --ignoreAncestry"; commandLine += " -r " + startRevision + ":" + endRevision + " " + target; notificationHandler.logCommandLine(commandLine); notificationHandler.setBaseDir(); JhlDiffSummaryReceiver callback = new JhlDiffSummaryReceiver(); svnClient.diffSummarize(target, JhlConverter.convert(pegRevision), JhlConverter.convert(startRevision), JhlConverter.convert(endRevision), d, null, ignoreAncestry, callback); return callback.getDiffSummary(); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } public SVNDiffSummary[] diffSummarize(File path, SVNRevision pegRevision, SVNRevision startRevision, SVNRevision endRevision, int depth, boolean ignoreAncestry) throws SVNClientException { String target = fileToSVNPath(path, false); return this.diffSummarize(target, pegRevision, startRevision, endRevision, depth, ignoreAncestry); } public SVNDiffSummary[] diffSummarize(SVNUrl url, SVNRevision pegRevision, SVNRevision startRevision, SVNRevision endRevision, int depth, boolean ignoreAncestry) throws SVNClientException { return this.diffSummarize(url.toString(), pegRevision, startRevision, endRevision, depth, ignoreAncestry); } public SVNDiffSummary[] diffSummarize(File target1, SVNRevision revision1, SVNUrl target2, SVNRevision revision2, int depth, boolean ignoreAncestry) throws SVNClientException { return diffSummarize(fileToSVNPath(target1, false), revision1, target2.toString(), revision2, depth, ignoreAncestry); } public SVNDiffSummary[] diffSummarize(SVNUrl target1, SVNRevision revision1, SVNUrl target2, SVNRevision revision2, int depth, boolean ignoreAncestry) throws SVNClientException { return diffSummarize(target1.toString(), revision1, target2.toString(), revision2, depth, ignoreAncestry); } // This is a bit of a hack in order to enable diff --summarize against a working copy. // This method does a diff to a temporary file and then parses that file to construct // the SVNDiffSummary array. public SVNDiffSummary[] diffSummarize(File path, SVNUrl toUrl, SVNRevision toRevision, boolean recurse) throws SVNClientException { List diffSummaryList = new ArrayList(); BufferedReader input = null; String changedResource = null; boolean deletedLines = false; boolean addedLines = false; boolean contextLines = false; boolean oldRev0 = false; boolean newRev0 = false; boolean propertyChanges = false; boolean inDiff = false; try { File diffFile = File.createTempFile("revision", ".diff"); diffFile.deleteOnExit(); diff(path, toUrl, toRevision, diffFile, recurse); input = new BufferedReader(new FileReader(diffFile)); String line = null; while ((line = input.readLine()) != null){ if (line != null && line.trim().length() > 0 && !line.startsWith("\\")) { if (line.startsWith("Index:")) { if (changedResource != null) { SVNDiffKind diffKind = getDiffKind(changedResource, deletedLines, addedLines, contextLines, oldRev0, newRev0); SVNDiffSummary diffSummary = new SVNDiffSummary(changedResource.substring(path.toString().length() + 1).replaceAll("\\\\", "/"), diffKind, propertyChanges, SVNNodeKind.FILE.toInt()); diffSummaryList.add(diffSummary); deletedLines = false; addedLines = false; contextLines = false; propertyChanges = false; oldRev0 = false; newRev0 = false; } inDiff = false; changedResource = line.substring(7); } else if (line.startsWith("--- ")) { if (line.endsWith("(revision 0)")) { oldRev0 = true; } } else if (line.startsWith("+++ ")) { if (line.endsWith("(revision 0)")) { newRev0 = true; } } else if (line.startsWith("@@")) { inDiff = true; } else if (line.equals("Property changes on: " + changedResource)) { propertyChanges = true; inDiff = false; } else if (inDiff) { if (line.startsWith("+")) addedLines = true; else if (line.startsWith("-")) deletedLines = true; else contextLines = true; } } } if (changedResource != null) { SVNDiffKind diffKind = getDiffKind(changedResource, deletedLines, addedLines, contextLines, oldRev0, newRev0); SVNDiffSummary diffSummary = new SVNDiffSummary(changedResource.substring(path.toString().length() + 1), diffKind, propertyChanges, SVNNodeKind.FILE.toInt()); diffSummaryList.add(diffSummary); } } catch (Exception e) { throw new SVNClientException(e); } finally { if (input != null) { try { input.close(); } catch (IOException e) {} } } SVNDiffSummary[] diffSummary = new SVNDiffSummary[diffSummaryList.size()]; diffSummaryList.toArray(diffSummary); return diffSummary; } private SVNDiffKind getDiffKind(String changedResource, boolean deletedLines, boolean addedLines, boolean contextLines, boolean oldRev0, boolean newRev0) { SVNDiffKind diffKind; if (oldRev0 && newRev0) { diffKind = SVNDiffKind.DELETED; } else if (addedLines && !deletedLines && !contextLines) diffKind = SVNDiffKind.ADDED; else if ((!deletedLines && !addedLines) || deletedLines && !addedLines && !contextLines) { if (exists(changedResource)) { diffKind = SVNDiffKind.DELETED; } else { diffKind = SVNDiffKind.ADDED; } } else diffKind = SVNDiffKind.MODIFIED; return diffKind; } private boolean exists(String changedResource) { File file = new File(changedResource); return file.exists(); } public String[] suggestMergeSources(File path) throws SVNClientException { String[] sources = null; try { Set s = svnClient.suggestMergeSources(fileToSVNPath(path, false), Revision.HEAD); sources = new String[s.size()]; s.toArray(sources); } catch (SubversionException e) { throw new SVNClientException(e); } return sources; } public String[] suggestMergeSources(SVNUrl url, SVNRevision peg) throws SVNClientException { String[] sources = null; try { Set s = svnClient.suggestMergeSources(url.toString(), JhlConverter.convert(peg)); sources = new String[s.size()]; s.toArray(sources); } catch (SubversionException e) { throw new SVNClientException(e); } return sources; } public void createPatch(File[] paths, File relativeToPath, File outFile, boolean recurse) throws SVNClientException { FileOutputStream os = null; try { List tempFiles = new ArrayList(); for (int i = 0; i < paths.length; i++) { File tempFile = File.createTempFile("tempDiff", ".txt"); tempFile.deleteOnExit(); this.diffRelative(paths[i], SVNRevision.BASE, paths[i], SVNRevision.WORKING, tempFile, recurse, false, false, false, relativeToPath); tempFiles.add(tempFile); } os = new FileOutputStream(outFile); for (File tempFile : tempFiles) { FileInputStream is = new FileInputStream(tempFile); byte[] buffer = new byte[4096]; int bytes_read; while ((bytes_read = is.read(buffer)) != -1) os.write(buffer, 0, bytes_read); is.close(); } } catch (Exception e) { throw new SVNClientException(e); } finally { if (os != null) try {os.close();} catch (IOException e) {} } } public void dispose() { svnClient.dispose(); } public ISVNLogMessage[] getMergeinfoLog(int kind, File path, SVNRevision pegRevision, SVNUrl mergeSourceUrl, SVNRevision srcPegRevision, boolean discoverChangedPaths) throws SVNClientException { return this.getMergeinfoLog(kind, fileToSVNPath(path, false), pegRevision, mergeSourceUrl, srcPegRevision, discoverChangedPaths); } public ISVNLogMessage[] getMergeinfoLog(int kind, SVNUrl url, SVNRevision pegRevision, SVNUrl mergeSourceUrl, SVNRevision srcPegRevision, boolean discoverChangedPaths) throws SVNClientException { return this.getMergeinfoLog(kind, url.toString(), pegRevision, mergeSourceUrl, srcPegRevision, discoverChangedPaths); } private ISVNLogMessage[] getMergeinfoLog(int kind, String target, SVNRevision pegRevision, SVNUrl mergeSourceUrl, SVNRevision srcPegRevision, boolean discoverChangedPaths) throws SVNClientException { try { notificationHandler.setCommand( ISVNNotifyListener.Command.MERGEINFO); String show = ""; org.apache.subversion.javahl.types.Mergeinfo.LogKind mergeKind = org.apache.subversion.javahl.types.Mergeinfo.LogKind.eligible; if (kind == ISVNMergeinfoLogKind.eligible) show = show + " --show-revs eligible "; if (kind == ISVNMergeinfoLogKind.merged) { show = show + " --show-revs merged "; mergeKind = org.apache.subversion.javahl.types.Mergeinfo.LogKind.merged; } notificationHandler.logCommandLine( "mergeinfo " + show + mergeSourceUrl.toString() + " " + target); SVNLogMessageCallback worker = new SVNLogMessageCallback(); JhlLogMessageCallback callback = new JhlLogMessageCallback(worker); Set revProps = new HashSet(); revProps.add("svn:author"); revProps.add("svn:date"); revProps.add("svn:log"); svnClient.getMergeinfoLog(mergeKind, target, JhlConverter.convert(pegRevision), mergeSourceUrl.toString(), JhlConverter.convert(srcPegRevision), discoverChangedPaths, Depth.infinity, revProps, callback); return worker.getLogMessages(); } catch (ClientException e) { if (e.getAprError() == ErrorCodes.unsupportedFeature) { return this.getLogMessages(mergeSourceUrl, srcPegRevision, new SVNRevision.Number(0), SVNRevision.HEAD, true, discoverChangedPaths, 0, false); } notificationHandler.logException(e); throw new SVNClientException(e); } } private String appendPaths(String commandLine, Set paths) { StringBuffer stringBuffer = new StringBuffer(commandLine); if (paths.size() > 5) stringBuffer.append(" (" + paths.size() + " paths specified)"); else { for (String s : paths) { stringBuffer.append(" " + s); } } return stringBuffer.toString(); } private String getFirstMessageLine(String message) { StringTokenizer tokenizer = new StringTokenizer(message, "\n"); int count = tokenizer.countTokens(); if (count > 1) return tokenizer.nextToken() + "..."; else return message; } /** * Applies any SVN rules to strings (commit messages and property values). * Currently that means making all line-endings LF * @param message * @return */ protected String fixSVNString(String message) { if (message == null) return null; // Normalize all line endings to LF return message.replaceAll("\r\n", "\n").replaceAll("\r", "\n"); } } svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/ErrorCodes.java000066400000000000000000000312171203563747500332450ustar00rootroot00000000000000package org.tigris.subversion.svnclientadapter.javahl; /** * Provide mappings from error codes generated by the C runtime to meaningful * Java values. For a better description of each error, please see * svn_error_codes.h in the C source. */ public class ErrorCodes { public static final int categorySize = 5000; public static final int badContainingPool = 125000; public static final int badFilename = 125001; public static final int badUrl = 125002; public static final int badDate = 125003; public static final int badMimeType = 125004; public static final int badPropertyValue = 125005; public static final int badVersionFileFormat = 125006; public static final int badRelativePath = 125007; public static final int badUuid = 125008; public static final int xmlAttribNotFound = 130000; public static final int xmlMissingAncestry = 130001; public static final int xmlUnknownEncoding = 130002; public static final int xmlMalformed = 130003; public static final int xmlUnescapableData = 130004; public static final int ioInconsistentEol = 135000; public static final int ioUnknownEol = 135001; public static final int ioCorruptEol = 135002; public static final int ioUniqueNamesExhausted = 135003; public static final int ioPipeFrameError = 135004; public static final int ioPipeReadError = 135005; public static final int ioWriteError = 135006; public static final int streamUnexpectedEof = 140000; public static final int streamMalformedData = 140001; public static final int streamUnrecognizedData = 140002; public static final int nodeUnknownKind = 145000; public static final int nodeUnexpectedKind = 145001; public static final int entryNotFound = 150000; public static final int entryExists = 150002; public static final int entryMissingRevision = 150003; public static final int entryMissingUrl = 150004; public static final int entryAttributeInvalid = 150005; public static final int wcObstructedUpdate = 155000; public static final int wcUnwindMismatch = 155001; public static final int wcUnwindEmpty = 155002; public static final int wcUnwindNotEmpty = 155003; public static final int wcLocked = 155004; public static final int wcNotLocked = 155005; public static final int wcInvalidLock = 155006; public static final int wcNotDirectory = 155007; public static final int wcNotFile = 155008; public static final int wcBadAdmLog = 155009; public static final int wcPathNotFound = 155010; public static final int wcNotUpToDate = 155011; public static final int wcLeftLocalMod = 155012; public static final int wcScheduleConflict = 155013; public static final int wcPathFound = 155014; public static final int wcFoundConflict = 155015; public static final int wcCorrupt = 155016; public static final int wcCorruptTextBase = 155017; public static final int wcNodeKindChange = 155018; public static final int wcInvalidOpOnCwd = 155019; public static final int wcBadAdmLogStart = 155020; public static final int wcUnsupportedFormat = 155021; public static final int wcBadPath = 155022; public static final int wcInvalidSchedule = 155023; public static final int wcInvalidRelocation = 155024; public static final int wcInvalidSwitch = 155025; public static final int wcMismatchedChangelist = 155026; public static final int wcConflictResolverFailure = 155027; public static final int wcCopyfromPathNotFound = 155028; public static final int wcChangelistMove = 155029; public static final int fsGeneral = 160000; public static final int fsCleanup = 160001; public static final int fsAlreadyOpen = 160002; public static final int fsNotOpen = 160003; public static final int fsCorrupt = 160004; public static final int fsPathSyntax = 160005; public static final int fsNoSuchRevision = 160006; public static final int fsNoSuchTransaction = 160007; public static final int fsNoSuchEntry = 160008; public static final int fsNoSuchRepresentation = 160009; public static final int fsNoSuchString = 160010; public static final int fsNoSuchCopy = 160011; public static final int fsTransactionNotMutable = 160012; public static final int fsNotFound = 160013; public static final int fsIdNotFound = 160014; public static final int fsNotId = 160015; public static final int fsNotDirectory = 160016; public static final int fsNotFile = 160017; public static final int fsNotSinglePathComponent = 160018; public static final int fsNotMutable = 160019; public static final int fsAlreadyExists = 160020; public static final int fsRootDir = 160021; public static final int fsNotTxnRoot = 160022; public static final int fsNotRevisionRoot = 160023; public static final int fsConflict = 160024; public static final int fsRepChanged = 160025; public static final int fsRepNotMutable = 160026; public static final int fsMalformedSkel = 160027; public static final int fsTxnOutOfDate = 160028; public static final int fsBerkeleyDb = 160029; public static final int fsBerkeleyDbDeadlock = 160030; public static final int fsTransactionDead = 160031; public static final int fsTransactionNotDead = 160032; public static final int fsUnknownFsType = 160033; public static final int fsNoUser = 160034; public static final int fsPathAlreadyLocked = 160035; public static final int fsPathNotLocked = 160036; public static final int fsBadLockToken = 160037; public static final int fsNoLockToken = 160038; public static final int fsLockOwnerMismatch = 160039; public static final int fsNoSuchLock = 160040; public static final int fsLockExpired = 160041; public static final int fsOutOfDate = 160042; public static final int fsUnsupportedFormat = 160043; public static final int fsRepBeingWritten = 160044; public static final int fsTxnNameTooLong = 160045; public static final int fsNoSuchNodeOrigin = 160046; public static final int reposLocked = 165000; public static final int reposHookFailure = 165001; public static final int reposBadArgs = 165002; public static final int reposNoDataForReport = 165003; public static final int reposBadRevisionReport = 165004; public static final int reposUnsupportedVersion = 165005; public static final int reposDisabledFeature = 165006; public static final int reposPostCommitHookFailed = 165007; public static final int reposPostLockHookFailed = 165008; public static final int reposPostUnlockHookFailed = 165009; public static final int raIllegalUrl = 170000; public static final int raNotAuthorized = 170001; public static final int raUnknownAuth = 170002; public static final int raNotImplemented = 170003; public static final int raOutOfDate = 170004; public static final int raNoReposUuid = 170005; public static final int raUnsupportedAbiVersion = 170006; public static final int raNotLocked = 170007; public static final int raUnknownCapability = 170008; public static final int raPartialReplayNotSupported = 170009; public static final int raDavSockInit = 175000; public static final int raDavCreatingRequest = 175001; public static final int raDavRequestFailed = 175002; public static final int raDavOptionsReqFailed = 175003; public static final int raDavPropsNotFound = 175004; public static final int raDavAlreadyExists = 175005; public static final int raDavInvalidConfigValue = 175006; public static final int raDavPathNotFound = 175007; public static final int raDavProppatchFailed = 175008; public static final int raDavMalformedData = 175009; public static final int raDavResponseHeaderBadness = 175010; public static final int raDavRelocated = 175011; public static final int raLocalReposNotFound = 180000; public static final int raLocalReposOpenFailed = 180001; public static final int svndiffInvalidHeader = 185000; public static final int svndiffCorruptWindow = 185001; public static final int svndiffBackwardView = 185002; public static final int svndiffInvalidOps = 185003; public static final int svndiffUnexpectedEnd = 185004; public static final int svndiffInvalidCompressedData = 185005; public static final int apmodMissingPathToFs = 190000; public static final int apmodMalformedUri = 190001; public static final int apmodActivityNotFound = 190002; public static final int apmodBadBaseline = 190003; public static final int apmodConnectionAborted = 190004; public static final int clientVersionedPathRequired = 195000; public static final int clientRaAccessRequired = 195001; public static final int clientBadRevision = 195002; public static final int clientDuplicateCommitUrl = 195003; public static final int clientIsBinaryFile = 195004; public static final int clientInvalidExternalsDescription = 195005; public static final int clientModified = 195006; public static final int clientIsDirectory = 195007; public static final int clientRevisionRange = 195008; public static final int clientInvalidRelocation = 195009; public static final int clientRevisionAuthorContainsNewline = 195010; public static final int clientPropertyName = 195011; public static final int clientUnrelatedResources = 195012; public static final int clientMissingLockToken = 195013; public static final int clientMultipleSourcesDisallowed = 195014; public static final int clientNoVersionedParent = 195015; public static final int clientNotReadyToMerge = 195016; public static final int base = 200000; public static final int pluginLoadFailure = 200001; public static final int malformedFile = 200002; public static final int incompleteData = 200003; public static final int incorrectParams = 200004; public static final int unversionedResource = 200005; public static final int testFailed = 200006; public static final int unsupportedFeature = 200007; public static final int badPropKind = 200008; public static final int illegalTarget = 200009; public static final int deltaMd5ChecksumAbsent = 200010; public static final int dirNotEmpty = 200011; public static final int externalProgram = 200012; public static final int swigPyExceptionSet = 200013; public static final int checksumMismatch = 200014; public static final int cancelled = 200015; public static final int invalidDiffOption = 200016; public static final int propertyNotFound = 200017; public static final int noAuthFilePath = 200018; public static final int versionMismatch = 200019; public static final int mergeinfoParseError = 200020; public static final int ceaseInvocation = 200021; public static final int revnumParseFailure = 200022; public static final int iterBreak = 200023; public static final int unknownChangelist = 200024; public static final int clArgParsingError = 205000; public static final int clInsufficientArgs = 205001; public static final int clMutuallyExclusiveArgs = 205002; public static final int clAdmDirReserved = 205003; public static final int clLogMessageIsVersionedFile = 205004; public static final int clLogMessageIsPathname = 205005; public static final int clCommitInAddedDir = 205006; public static final int clNoExternalEditor = 205007; public static final int clBadLogMessage = 205008; public static final int clUnnecessaryLogMessage = 205009; public static final int clNoExternalMergeTool = 205010; public static final int last = 205011; public static final int raSvnCmdErr = 210000; public static final int raSvnUnknownCmd = 210001; public static final int raSvnConnectionClosed = 210002; public static final int raSvnIoError = 210003; public static final int raSvnMalformedData = 210004; public static final int raSvnReposNotFound = 210005; public static final int raSvnBadVersion = 210006; public static final int raSvnNoMechanisms = 210007; public static final int authnCredsUnavailable = 215000; public static final int authnNoProvider = 215001; public static final int authnProvidersExhausted = 215002; public static final int authnCredsNotSaved = 215003; public static final int authnFailed = 215004; public static final int authzRootUnreadable = 220000; public static final int authzUnreadable = 220001; public static final int authzPartiallyReadable = 220002; public static final int authzInvalidConfig = 220003; public static final int authzUnwritable = 220004; public static final int diffDatasourceModified = 225000; public static final int raSerfSspiInitialisationFailed = 230000; }svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/JhlAnnotations.java000066400000000000000000000062031203563747500341260ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import java.io.UnsupportedEncodingException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; import org.apache.subversion.javahl.ClientException; import org.apache.subversion.javahl.callback.BlameCallback; import org.tigris.subversion.svnclientadapter.Annotations; /** * JavaHL specific subclass of {@link Annotations}. * It implements a {@link org.tigris.subversion.javahl.BlameCallback} * as means of constructing the annotation records. * */ public class JhlAnnotations extends Annotations implements BlameCallback { private static final DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); private void singleLine(Date changed, long revision, String author, Date merged_date, long merged_revision, String merged_author, String mergedPath, String line) { if (merged_revision == -1 || revision <= merged_revision) addAnnotation(new Annotation(revision, author, changed, line)); else addAnnotation(new Annotation(merged_revision, merged_author, merged_date, line)); } public void singleLine(long lineNum, long revision, Map revProps, long mergedRevision, Map mergedRevProps, String mergedPath, String line, boolean localChange) throws ClientException { String author = null; String mergedAuthor = null; try { author = new String(revProps.get("svn:author"), "UTF8"); } catch (UnsupportedEncodingException e) { author = new String(revProps.get("svn:author")); } if (mergedRevProps != null) { try { mergedAuthor = new String(mergedRevProps.get("svn:author"), "UTF8"); } catch (UnsupportedEncodingException e) { mergedAuthor = new String(mergedRevProps.get("svn:author")); } } try { singleLine( df.parse(new String(revProps.get("svn:date"))), revision, author, mergedRevProps == null ? null : df.parse(new String(mergedRevProps.get("svn:date"))), mergedRevision, mergedAuthor, mergedPath, line); } catch (ParseException e) { throw ClientException.fromException(e); } } } JhlClientAdapter.java000066400000000000000000000142561203563747500343000ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileChannel; import java.text.MessageFormat; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import org.apache.subversion.javahl.ClientException; import org.apache.subversion.javahl.types.CopySource; import org.apache.subversion.javahl.types.Revision; import org.apache.subversion.javahl.SVNClient; import org.apache.subversion.javahl.SVNRepos; import org.tigris.subversion.svnclientadapter.ISVNNotifyListener; import org.tigris.subversion.svnclientadapter.ISVNProperty; import org.tigris.subversion.svnclientadapter.SVNBaseDir; import org.tigris.subversion.svnclientadapter.SVNClientException; /** * A JavaHL base implementation of {@link org.tigris.subversion.svnclientadapter.ISVNClientAdapter}. * * @author C�dric Chabanois (cchabanois at no-log.org) * @author Panagiotis Korros (pkorros at bigfoot.com) * */ public class JhlClientAdapter extends AbstractJhlClientAdapter { private SVNRepos svnAdmin; /** * Default constructor */ public JhlClientAdapter() { svnClient = new SVNClient(); svnAdmin = new SVNRepos(); notificationHandler = new JhlNotificationHandler(); progressListener = new JhlProgressListener(); svnClient.notification2(notificationHandler); svnClient.setPrompt(new DefaultPromptUserPassword()); svnClient.setProgressCallback(progressListener); } public boolean isThreadsafe() { return false; } /** * tells if JhlClientAdapter is usable * @return true if Jhl client adapter is available * @deprecated */ public static boolean isAvailable() { return JhlClientAdapterFactory.isAvailable(); } /** * @return an error string describing problems during loading platform native libraries (if any) * @deprecated */ public static String getLibraryLoadErrors() { return JhlClientAdapterFactory.getLibraryLoadErrors(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#createRepository(java.io.File) */ public void createRepository(File path, String repositoryType) throws SVNClientException { try { String fsType = (repositoryType == null) ? REPOSITORY_FSTYPE_FSFS : repositoryType; notificationHandler.setCommand(ISVNNotifyListener.Command.CREATE_REPOSITORY); notificationHandler.logCommandLine( MessageFormat.format( "create --fstype {0} {1}", (Object[])new String[] { fsType, fileToSVNPath(path, false) })); svnAdmin.create(path, false, false, null, fsType); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } public boolean statusReturnsRemoteInfo() { return true; } /* * Overridden to fix issue where move of a file with svn:keywords updates * the file contents. Only an issue for JavaHL. * * If you are moving a file and it has svn:keywords, then we change to * copy, overwrite contents and delete. This is so that file contents * are not modified by the move. * * For folders, and files without keywords, we just delegate to super() * */ public void move(File srcPath, File destPath, boolean force) throws SVNClientException { if (srcPath.isFile()) { ISVNProperty prop = this.propertyGet(srcPath, ISVNProperty.KEYWORDS); if (prop != null) { try { notificationHandler.setCommand(ISVNNotifyListener.Command.MOVE); String src = fileToSVNPath(srcPath, false); String dest = fileToSVNPath(destPath, false); notificationHandler.logCommandLine( "move "+src+' '+dest); notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(new File[] {srcPath, destPath})); List copySources = new ArrayList(); copySources.add(new CopySource(src, Revision.WORKING, Revision.WORKING)); svnClient.copy(copySources, dest, true, true, true, null, null, null); try { overwriteFile(srcPath, destPath); } catch (IOException e) { // If file contents do not copy, just // proceed. } Set paths = new HashSet(); paths.add(src); svnClient.remove(paths, true, false, null, null, null); } catch (ClientException e) { notificationHandler.logException(e); throw new SVNClientException(e); } return; } } super.move(srcPath, destPath, force); } private void overwriteFile(File srcFile, File destFile) throws IOException { if (!destFile.exists()) { destFile.createNewFile(); } FileChannel source = null; FileChannel destination = null; try { source = new FileInputStream(srcFile).getChannel(); destination = new FileOutputStream(destFile).getChannel(); destination.transferFrom(source, 0, source.size()); } finally { if (source != null) { source.close(); } if (destination != null) { destination.close(); } } } public String getNativeLibraryVersionString() { return svnClient.getVersion().toString(); } } JhlClientAdapterFactory.java000066400000000000000000000175471203563747500356360ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import org.apache.subversion.javahl.ISVNClient; import org.apache.subversion.javahl.SVNClient; import org.apache.subversion.javahl.types.Version; import org.tigris.subversion.svnclientadapter.ISVNClientAdapter; import org.tigris.subversion.svnclientadapter.SVNClientAdapterFactory; import org.tigris.subversion.svnclientadapter.SVNClientException; /** * Concrete implementation of SVNClientAdapterFactory for javahl interface. * To register this factory, just call {@link JhlClientAdapterFactory#setup()} */ public class JhlClientAdapterFactory extends SVNClientAdapterFactory { private static final String[] WINDOWSLIBS = new String[] { "msvcr100", "msvcp100", "libapr-1", "libapriconv-1", "libeay32", "ssleay32", "libaprutil-1", "dbghelp", "libsasl", // libraries as of 1.5 "libsvn_subr-1", "libsvn_delta-1", "libsvn_diff-1", "libsvn_wc-1", "libsvn_fs-1", "libsvn_repos-1", "libsvn_ra-1", "libsvn_client-1" }; private static boolean availabilityCached = false; private static boolean available; private static StringBuffer javaHLErrors = new StringBuffer("Failed to load JavaHL Library.\nThese are the errors that were encountered:\n"); /** Client adapter implementation identifier */ public static final String JAVAHL_CLIENT = "javahl"; /** * Private constructor. * Clients are expected the use {@link #createSVNClientImpl()}, res. * ask the {@link SVNClientAdapterFactory} */ private JhlClientAdapterFactory() { super(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.SVNClientAdapterFactory#createSVNClientImpl() */ protected ISVNClientAdapter createSVNClientImpl() { return new JhlClientAdapter(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.SVNClientAdapterFactory#getClientType() */ protected String getClientType() { return JAVAHL_CLIENT; } /** * Setup the client adapter implementation and register it in the adapters factory * @throws SVNClientException */ public static void setup() throws SVNClientException { if (!isAvailable()) { throw new SVNClientException("Javahl client adapter is not available"); } SVNClientAdapterFactory.registerAdapterFactory(new JhlClientAdapterFactory()); } @SuppressWarnings("rawtypes") public static boolean isAvailable() { if (!availabilityCached) { Class c = null; try { // load a JavaHL class to see if it is found. Do not use SVNClient as // it will try to load native libraries and we do not want that yet c = Class.forName("org.apache.subversion.javahl.ClientException"); if (c == null) return false; } catch (Throwable t) { availabilityCached = true; return false; } // if library is already loaded, it will not be reloaded //workaround to solve Subclipse ISSUE #83 // we will ignore these exceptions to handle scenarios where // javaHL was built diffently. Ultimately, if javaHL fails to load // because of a problem in one of these libraries the proper behavior // will still occur -- meaning JavaHL adapter is disabled. if(isOsWindows()) { for (int i = 0; i < WINDOWSLIBS.length; i++) { try { System.loadLibrary(WINDOWSLIBS[i]); } catch (Exception e) { javaHLErrors.append(e.getMessage()).append("\n"); } catch (UnsatisfiedLinkError e) { javaHLErrors.append(e.getMessage()).append("\n"); } } } //workaround to solve Subclipse ISSUE #83 available = false; try { /* * see if the user has specified the fully qualified path to the native * library */ try { String specifiedLibraryName = System.getProperty("subversion.native.library"); if(specifiedLibraryName != null) { System.load(specifiedLibraryName); available = true; } } catch(UnsatisfiedLinkError ex) { javaHLErrors.append(ex.getMessage()).append("\n"); } if (!available) { /* * first try to load the library by the new name. * if that fails, try to load the library by the old name. */ try { System.loadLibrary("libsvnjavahl-1"); } catch(UnsatisfiedLinkError ex) { javaHLErrors.append(ex.getMessage() + "\n"); try { System.loadLibrary("svnjavahl-1"); } catch (UnsatisfiedLinkError e) { javaHLErrors.append(e.getMessage()).append("\n"); System.loadLibrary("svnjavahl"); } } available = true; } } catch (Exception e) { available = false; javaHLErrors.append(e.getMessage()).append("\n"); } catch (UnsatisfiedLinkError e) { available = false; javaHLErrors.append(e.getMessage()).append("\n"); } finally { availabilityCached = true; } if (!available) { String libraryPath = System.getProperty("java.library.path"); if (libraryPath != null) javaHLErrors.append("java.library.path = " + libraryPath); // System.out.println(javaHLErrors.toString()); } else { // At this point, the library appears to be available, but // it could be too old version of JavaHL library. We have to try // to get the version of the library to be sure. try { ISVNClient svnClient = new SVNClient(); Version version = svnClient.getVersion(); if (version.getMajor() == 1 && version.getMinor() == 7) available = true; else { available = false; javaHLErrors = new StringBuffer("Incompatible JavaHL library loaded. Subversion 1.7.x required."); } } catch (UnsatisfiedLinkError e) { available = false; javaHLErrors = new StringBuffer("Incompatible JavaHL library loaded. 1.7.x or later required."); } } } return available; } /** * Answer whether running on Windows OS. * (Actual code extracted from org.apache.commons.lang.SystemUtils.IS_OS_WINDOWS) * (For such one simple method it does make sense to introduce dependency on whole commons-lang.jar) * @return true when the underlying */ public static boolean isOsWindows() { try { return System.getProperty("os.name").startsWith("Windows"); } catch (SecurityException ex) { // we are not allowed to look at this property return false; } } /** * @return an error string describing problems during loading platform native libraries (if any) */ public static String getLibraryLoadErrors() { if (isAvailable()) return ""; else return javaHLErrors.toString(); } } JhlCommitCallback.java000066400000000000000000000017571203563747500344300ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahlpackage org.tigris.subversion.svnclientadapter.javahl; import java.util.Date; import org.apache.subversion.javahl.CommitInfo; import org.apache.subversion.javahl.callback.CommitCallback; public class JhlCommitCallback implements CommitCallback { CommitInfo commitInfo; public void commitInfo(CommitInfo info) { commitInfo = info; } /** * retrieve the revision of the commit */ public long getRevision() { if (commitInfo == null) return 0L; return commitInfo.getRevision(); } /** * return the date of the commit */ public Date getDate() { if (commitInfo == null) return null; return commitInfo.getDate(); } /** * return the author of the commit */ public String getAuthor() { if (commitInfo == null) return null; return commitInfo.getAuthor(); } public String getPostCommitError() { if (commitInfo == null) return null; return commitInfo.getPostCommitError(); } } JhlCommitMessage.java000066400000000000000000000007231203563747500343100ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahlpackage org.tigris.subversion.svnclientadapter.javahl; import java.util.Set; import org.apache.subversion.javahl.CommitItem; import org.apache.subversion.javahl.callback.CommitMessageCallback; public class JhlCommitMessage implements CommitMessageCallback { private String message; public JhlCommitMessage(String message) { super(); this.message = message; } public String getLogMessage(Set elementsToBeCommited) { return message; } } JhlConflictResolver.java000066400000000000000000000020701203563747500350330ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahlpackage org.tigris.subversion.svnclientadapter.javahl; import org.apache.subversion.javahl.ConflictDescriptor; import org.apache.subversion.javahl.ConflictResult; import org.apache.subversion.javahl.SubversionException; import org.apache.subversion.javahl.callback.ConflictResolverCallback; import org.tigris.subversion.svnclientadapter.ISVNConflictResolver; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNConflictResult; public class JhlConflictResolver implements ConflictResolverCallback { ISVNConflictResolver worker; public JhlConflictResolver(ISVNConflictResolver worker) { super(); this.worker = worker; } public ConflictResult resolve(ConflictDescriptor descrip) throws SubversionException { try { SVNConflictResult svnConflictResult = worker.resolve(JhlConverter.convertConflictDescriptor(descrip)); return new ConflictResult(JhlConverter.convert(svnConflictResult), svnConflictResult.getMergedPath()); } catch (SVNClientException e) { throw new JhlException(e); } } } svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/JhlConverter.java000066400000000000000000000317751203563747500336140ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.logging.Logger; import org.apache.subversion.javahl.types.ChangePath; import org.apache.subversion.javahl.ConflictDescriptor; import org.apache.subversion.javahl.ConflictResult; import org.apache.subversion.javahl.DiffSummary; import org.apache.subversion.javahl.ISVNClient; import org.apache.subversion.javahl.types.DirEntry; import org.apache.subversion.javahl.types.Info; import org.apache.subversion.javahl.types.Lock; import org.apache.subversion.javahl.types.Revision; import org.apache.subversion.javahl.types.RevisionRange; import org.apache.subversion.javahl.types.Status; import org.tigris.subversion.svnclientadapter.ISVNLogMessageChangePath; import org.tigris.subversion.svnclientadapter.SVNConflictDescriptor; import org.tigris.subversion.svnclientadapter.SVNConflictResult; import org.tigris.subversion.svnclientadapter.SVNConflictVersion; import org.tigris.subversion.svnclientadapter.SVNDiffSummary; import org.tigris.subversion.svnclientadapter.SVNLogMessageChangePath; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNRevisionRange; import org.tigris.subversion.svnclientadapter.SVNScheduleKind; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.utils.Depth; /** * Convert from javahl types to subversion.svnclientadapter.* types * * @author philip schatz */ public class JhlConverter { private static final Logger log = Logger.getLogger(JhlConverter.class.getName()); private JhlConverter() { //non-instantiable } /** * Convert clientAdapter's {@link SVNRevision} into JavaHL's {@link Revision} * @param svnRevision * @return a {@link Revision} representing suppplied SVNRevision */ public static Revision convert(SVNRevision svnRevision) { if (svnRevision == null) return null; switch(svnRevision.getKind()) { case SVNRevision.Kind.base : return Revision.BASE; case SVNRevision.Kind.committed : return Revision.COMMITTED; case SVNRevision.Kind.date : return new Revision.DateSpec(((SVNRevision.DateSpec)svnRevision).getDate()); case SVNRevision.Kind.head : return Revision.HEAD; case SVNRevision.Kind.number : return new Revision.Number(((SVNRevision.Number)svnRevision).getNumber()); case SVNRevision.Kind.previous : return Revision.PREVIOUS; case SVNRevision.Kind.unspecified : return Revision.START; case SVNRevision.Kind.working : return Revision.WORKING; default: { log.severe("unknown revision kind :"+svnRevision.getKind()); return Revision.START; // should never go here } } } /** * Convert clientAdapter's {@link SVNRevisionRange} into JavaHL's {@link RevisionRange} * @param svnRevisionRange * @return a {@link RevisionRange} representing suppplied SVNRevisionRange */ public static RevisionRange convert(SVNRevisionRange svnRevisionRange) { return new RevisionRange(JhlConverter.convert(svnRevisionRange.getFromRevision()), JhlConverter.convert(svnRevisionRange.getToRevision())); } /** * Convert JavaHL's {@link RevisionRange} into clientAdapter's {@link SVNRevisionRange} * @param RevisionRange * @return a {@link SVNRevisionRange} representing suppplied RevisionRange */ public static SVNRevisionRange convert(RevisionRange svnRevisionRange) { return new SVNRevisionRange(JhlConverter.convert(svnRevisionRange.getFromRevision()), JhlConverter.convert(svnRevisionRange.getToRevision())); } public static SVNRevisionRange[] convertRevisionRange(List jhlRange) { SVNRevisionRange[] range = new SVNRevisionRange[jhlRange.size()]; int i=0; for (RevisionRange item : jhlRange) { range[i] = JhlConverter.convert(item); i++; } return range; } public static List convert(SVNRevisionRange[] range) { List jhlRange = new ArrayList(range.length); for(int i=0; i < range.length; i++) { jhlRange.add(JhlConverter.convert(range[i])); } return jhlRange; } /** * Convert JavaHL's {@link Revision} into clientAdapter's {@link SVNRevision} * @param rev * @return a {@link SVNRevision} representing suppplied Revision */ public static SVNRevision convert(Revision rev) { if (rev == null) return null; switch (rev.getKind()) { case base : return SVNRevision.BASE; case committed : return SVNRevision.COMMITTED; case number : Revision.Number n = (Revision.Number) rev; if (n.getNumber() == -1) { // we return null when resource is not managed ... return null; } else { return new SVNRevision.Number(n.getNumber()); } case previous : return SVNRevision.PREVIOUS; case working : return SVNRevision.WORKING; default : return SVNRevision.HEAD; } } static SVNRevision.Number convertRevisionNumber(long revisionNumber) { if (revisionNumber == -1) { return null; } else { return new SVNRevision.Number(revisionNumber); } } public static SVNNodeKind convertNodeKind(org.apache.subversion.javahl.types.NodeKind javahlNodeKind) { switch(javahlNodeKind) { case dir : return SVNNodeKind.DIR; case file : return SVNNodeKind.FILE; case none : return SVNNodeKind.NONE; case unknown : return SVNNodeKind.UNKNOWN; default: { log.severe("unknown node kind :"+javahlNodeKind); return SVNNodeKind.UNKNOWN; // should never go here } } } public static JhlStatus convert(Status status, ISVNClient client) { return new JhlStatus(status, client); } public static SVNStatusKind convertStatusKind(Status.Kind kind) { switch (kind) { case none : return SVNStatusKind.NONE; case normal : return SVNStatusKind.NORMAL; case added : return SVNStatusKind.ADDED; case missing : return SVNStatusKind.MISSING; case incomplete : return SVNStatusKind.INCOMPLETE; case deleted : return SVNStatusKind.DELETED; case replaced : return SVNStatusKind.REPLACED; case modified : return SVNStatusKind.MODIFIED; case merged : return SVNStatusKind.MERGED; case conflicted : return SVNStatusKind.CONFLICTED; case obstructed : return SVNStatusKind.OBSTRUCTED; case ignored : return SVNStatusKind.IGNORED; case external: return SVNStatusKind.EXTERNAL; case unversioned : return SVNStatusKind.UNVERSIONED; default : { log.severe("unknown status kind :"+kind); return SVNStatusKind.NONE; } } } static JhlDirEntry convert(DirEntry dirEntry) { return new JhlDirEntry(dirEntry); } public static JhlStatus[] convertStatus(List status, ISVNClient client) { JhlStatus[] jhlStatus = new JhlStatus[status.size()]; int i=0; for (Status stat : status) { jhlStatus[i] = new JhlStatus(stat, client); i++; } return jhlStatus; } static ISVNLogMessageChangePath[] convertChangePaths(Set changePaths) { if (changePaths == null) return new SVNLogMessageChangePath[0]; SVNLogMessageChangePath[] jhlChangePaths = new SVNLogMessageChangePath[changePaths.size()]; int i =0; for (ChangePath path : changePaths) { jhlChangePaths[i] = new JhlLogMessageChangePath(path); i++; } return jhlChangePaths; } public static SVNScheduleKind convertScheduleKind(Info.ScheduleKind kind) { switch (kind) { case normal: return SVNScheduleKind.NORMAL; case delete: return SVNScheduleKind.DELETE; case add: return SVNScheduleKind.ADD; case replace: return SVNScheduleKind.REPLACE; default : { log.severe("unknown schedule kind :"+kind); return SVNScheduleKind.NORMAL; } } } public static JhlLock convertLock(Lock lock) { return new JhlLock(lock); } public static SVNConflictDescriptor convertConflictDescriptor(ConflictDescriptor d) { if (d == null) return null; SVNConflictVersion srcLeftVersion = null; if (d.getSrcLeftVersion() != null) { srcLeftVersion = new SVNConflictVersion(d.getSrcLeftVersion().getReposURL(), d.getSrcLeftVersion().getPegRevision(), d.getSrcLeftVersion().getPathInRepos(), d.getSrcLeftVersion().getNodeKind().ordinal()); } SVNConflictVersion srcRightVersion = null; if (d.getSrcRightVersion() != null) { srcRightVersion = new SVNConflictVersion(d.getSrcRightVersion().getReposURL(), d.getSrcRightVersion().getPegRevision(), d.getSrcRightVersion().getPathInRepos(), d.getSrcRightVersion().getNodeKind().ordinal()); } return new SVNConflictDescriptor(d.getPath(), d.getKind().ordinal(), d.getNodeKind().ordinal(), d.getPropertyName(), d.isBinary(), d.getMIMEType(), d.getAction().ordinal(), d.getReason().ordinal(), d.getOperation().ordinal(), srcLeftVersion, srcRightVersion, d.getBasePath(), d.getTheirPath(), d.getMyPath(), d.getMergedPath()); } public static SVNConflictResult convertConflictResult(ConflictResult r) { return new SVNConflictResult(r.getChoice().ordinal(), r.getMergedPath()); } public static SVNDiffSummary convert(DiffSummary d) { return new SVNDiffSummary(d.getPath(), JhlConverter.convert(d.getDiffKind()), d.propsChanged(), d.getNodeKind().ordinal()); } public static SVNDiffSummary.SVNDiffKind convert(DiffSummary.DiffKind d) { if (d == DiffSummary.DiffKind.added) { return SVNDiffSummary.SVNDiffKind.ADDED; } else if (d == DiffSummary.DiffKind.modified) { return SVNDiffSummary.SVNDiffKind.MODIFIED; } else if (d == DiffSummary.DiffKind.deleted) { return SVNDiffSummary.SVNDiffKind.DELETED; } else { return SVNDiffSummary.SVNDiffKind.NORMAL; } } public static ConflictResult.Choice convert(SVNConflictResult result) { switch (result.getChoice()) { case SVNConflictResult.chooseBase: return ConflictResult.Choice.chooseBase; case SVNConflictResult.chooseMerged: return ConflictResult.Choice.chooseMerged; case SVNConflictResult.chooseMine: return ConflictResult.Choice.chooseMineConflict; case SVNConflictResult.chooseMineFull: return ConflictResult.Choice.chooseMineFull; case SVNConflictResult.chooseTheirs: return ConflictResult.Choice.chooseTheirsConflict; case SVNConflictResult.chooseTheirsFull: return ConflictResult.Choice.chooseTheirsFull; case SVNConflictResult.postpone: return ConflictResult.Choice.postpone; default: return ConflictResult.Choice.postpone; } } public static char convert(ChangePath.Action action) { switch (action) { case add: return 'A'; case delete: return 'D'; case modify: return 'M'; case replace: return 'R'; default: return '?'; } } public static org.apache.subversion.javahl.types.Depth depth(int depthValue) { switch(depthValue) { case Depth.empty: return org.apache.subversion.javahl.types.Depth.empty; case Depth.files: return org.apache.subversion.javahl.types.Depth.files; case Depth.immediates: return org.apache.subversion.javahl.types.Depth.immediates; case Depth.infinity: return org.apache.subversion.javahl.types.Depth.infinity; case Depth.exclude: return org.apache.subversion.javahl.types.Depth.exclude; default: return org.apache.subversion.javahl.types.Depth.unknown; } } } JhlDiffSummaryReceiver.java000066400000000000000000000012731203563747500354670ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahlpackage org.tigris.subversion.svnclientadapter.javahl; import java.util.ArrayList; import java.util.List; import org.apache.subversion.javahl.DiffSummary; import org.apache.subversion.javahl.callback.DiffSummaryCallback; import org.tigris.subversion.svnclientadapter.SVNDiffSummary; public class JhlDiffSummaryReceiver implements DiffSummaryCallback { List summary = new ArrayList(); public void onSummary(DiffSummary descriptor) { summary.add(JhlConverter.convert(descriptor)); } public SVNDiffSummary[] getDiffSummary() { SVNDiffSummary[] diffSummary = new SVNDiffSummary[summary.size()]; summary.toArray(diffSummary); return diffSummary; } } svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/JhlDirEntry.java000066400000000000000000000054021203563747500333710ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import java.util.Date; import org.apache.subversion.javahl.types.DirEntry; import org.tigris.subversion.svnclientadapter.ISVNDirEntry; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNRevision; /** * A JavaHL based implementation of {@link ISVNDirEntry}. * Actually just an adapter from {@link org.tigris.subversion.javahl.DirEntry} * * @author philip schatz */ public class JhlDirEntry implements ISVNDirEntry { private DirEntry _d; /** * Constructor * @param d */ public JhlDirEntry(DirEntry d) { super(); _d = d; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNDirEntry#getNodeKind() */ public SVNNodeKind getNodeKind() { return JhlConverter.convertNodeKind(_d.getNodeKind()); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNDirEntry#getHasProps() */ public boolean getHasProps() { return _d.getHasProps(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNDirEntry#getLastChangedRevision() */ public SVNRevision.Number getLastChangedRevision() { return (SVNRevision.Number)JhlConverter.convert(_d.getLastChangedRevision()); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNDirEntry#getLastChangedDate() */ public Date getLastChangedDate() { return _d.getLastChanged(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNDirEntry#getLastCommitAuthor() */ public String getLastCommitAuthor() { return _d.getLastAuthor(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNDirEntry#getPath() */ public String getPath() { return _d.getPath(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNDirEntry#getSize() */ public long getSize() { return _d.getSize(); } } JhlDirEntryWithLock.java000066400000000000000000000012761203563747500347640ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahlpackage org.tigris.subversion.svnclientadapter.javahl; import org.apache.subversion.javahl.types.DirEntry; import org.apache.subversion.javahl.types.Lock; import org.tigris.subversion.svnclientadapter.ISVNDirEntry; import org.tigris.subversion.svnclientadapter.ISVNDirEntryWithLock; import org.tigris.subversion.svnclientadapter.ISVNLock; public class JhlDirEntryWithLock implements ISVNDirEntryWithLock { private ISVNDirEntry dirEntry; private ISVNLock lock; public JhlDirEntryWithLock(DirEntry d, Lock l) { dirEntry = new JhlDirEntry(d); if (l != null) lock = new JhlLock(l); } public ISVNDirEntry getDirEntry() { return dirEntry; } public ISVNLock getLock() { return lock; } } svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/JhlException.java000066400000000000000000000006761203563747500335770ustar00rootroot00000000000000package org.tigris.subversion.svnclientadapter.javahl; import org.apache.subversion.javahl.SubversionException; import org.tigris.subversion.svnclientadapter.SVNClientException; public class JhlException extends SubversionException { private static final long serialVersionUID = 328804379812661422L; protected JhlException(String message) { super(message); } public JhlException(SVNClientException e) { super(e.getMessage()); } } svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/JhlInfo.java000066400000000000000000000132661203563747500325330ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.util.Date; import org.apache.subversion.javahl.types.Info; import org.tigris.subversion.svnclientadapter.ISVNInfo; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNRevision.Number; import org.tigris.subversion.svnclientadapter.SVNScheduleKind; import org.tigris.subversion.svnclientadapter.SVNUrl; /** * A JavaHL based implementation of {@link ISVNInfo}. * Actually just an adapter from {@link org.tigris.subversion.javahl.Info} * * @author Cédric Chabanois */ public class JhlInfo implements ISVNInfo { private Info info; private File file; /** * Constructor * @param file * @param info */ public JhlInfo(File file, Info info) { super(); this.file = file; this.info = info; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getFile() */ public File getFile() { try { return file.getCanonicalFile(); } catch (IOException e) { return null; } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getUrl() */ public SVNUrl getUrl() { try { return new SVNUrl(info.getUrl()); } catch (MalformedURLException e) { //should never happen. return null; } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getUrlString() */ public String getUrlString() { return info.getUrl(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getUuid() */ public String getUuid() { return info.getReposUUID(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getRepository() */ public SVNUrl getRepository() { try { return new SVNUrl(info.getUrl()); } catch (MalformedURLException e) { //should never happen. return null; } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getSchedule() */ public SVNScheduleKind getSchedule() { return JhlConverter.convertScheduleKind(info.getSchedule()); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getNodeKind() */ public SVNNodeKind getNodeKind() { return JhlConverter.convertNodeKind(info.getKind()); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getAuthor() */ public String getLastCommitAuthor() { return info.getLastChangedAuthor(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getRevision() */ public Number getRevision() { return JhlConverter.convertRevisionNumber(info.getRev()); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastChangedRevision() */ public Number getLastChangedRevision() { return JhlConverter.convertRevisionNumber(info.getLastChangedRev()); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastChangedDate() */ public Date getLastChangedDate() { return info.getLastChangedDate(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastDateTextUpdate() */ public Date getLastDateTextUpdate() { return info.getTextTime(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastDatePropsUpdate() */ public Date getLastDatePropsUpdate() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#isCopied() */ public boolean isCopied() { return (info.getCopyFromRev() > 0); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getCopyRev() */ public Number getCopyRev() { return JhlConverter.convertRevisionNumber(info.getCopyFromRev()); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getCopyUrl() */ public SVNUrl getCopyUrl() { try { return new SVNUrl(info.getCopyFromUrl()); } catch (MalformedURLException e) { //should never happen. return null; } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockCreationDate() */ public Date getLockCreationDate() { //Not available in info(1) return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockOwner() */ public String getLockOwner() { //Not available in info(1) return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockComment() */ public String getLockComment() { //Not available in info(1) return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getDepth() */ public int getDepth() { //Not available in info(1) return info.getDepth().ordinal(); } } svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/JhlInfo2.java000066400000000000000000000136471203563747500326200ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.util.Date; import org.apache.subversion.javahl.types.Info; import org.tigris.subversion.svnclientadapter.ISVNInfo; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNRevision.Number; import org.tigris.subversion.svnclientadapter.SVNScheduleKind; import org.tigris.subversion.svnclientadapter.SVNUrl; /** * A JavaHL based implementation of {@link ISVNInfo}. * Actually just an adapter from {@link org.tigris.subversion.javahl.Info2} * * @author Cédric Chabanois */ public class JhlInfo2 implements ISVNInfo { private Info info; private File file; /** * Constructor * @param file * @param info */ public JhlInfo2(String path, Info info) { super(); if (path == null) file = null; else file = new File(path); this.info = info; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getFile() */ public File getFile() { if (file == null) return null; try { return file.getCanonicalFile(); } catch (IOException e) { return null; } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getUrl() */ public SVNUrl getUrl() { try { return new SVNUrl(info.getUrl()); } catch (MalformedURLException e) { //should never happen. return null; } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getUrlString() */ public String getUrlString() { return info.getUrl(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getUuid() */ public String getUuid() { return info.getReposUUID(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getRepository() */ public SVNUrl getRepository() { try { return new SVNUrl(info.getReposRootUrl()); } catch (MalformedURLException e) { //should never happen. return null; } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getSchedule() */ public SVNScheduleKind getSchedule() { return JhlConverter.convertScheduleKind(info.getSchedule()); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getNodeKind() */ public SVNNodeKind getNodeKind() { return JhlConverter.convertNodeKind(info.getKind()); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getAuthor() */ public String getLastCommitAuthor() { return info.getLastChangedAuthor(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getRevision() */ public Number getRevision() { return JhlConverter.convertRevisionNumber(info.getRev()); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastChangedRevision() */ public Number getLastChangedRevision() { return JhlConverter.convertRevisionNumber(info.getLastChangedRev()); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastChangedDate() */ public Date getLastChangedDate() { return info.getLastChangedDate(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastDateTextUpdate() */ public Date getLastDateTextUpdate() { return info.getTextTime(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastDatePropsUpdate() */ public Date getLastDatePropsUpdate() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#isCopied() */ public boolean isCopied() { return (info.getCopyFromRev() > 0); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getCopyRev() */ public Number getCopyRev() { return JhlConverter.convertRevisionNumber(info.getCopyFromRev()); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getCopyUrl() */ public SVNUrl getCopyUrl() { try { return new SVNUrl(info.getCopyFromUrl()); } catch (MalformedURLException e) { //should never happen. return null; } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockCreationDate() */ public Date getLockCreationDate() { if (info.getLock() == null) return null; else return info.getLock().getCreationDate(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockOwner() */ public String getLockOwner() { if (info.getLock() == null) return null; else return info.getLock().getOwner(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockComment() */ public String getLockComment() { if (info.getLock() == null) return null; else return info.getLock().getComment(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getDepth() */ public int getDepth() { return info.getDepth().ordinal(); } } JhlInfoCallback.java000066400000000000000000000011251203563747500340600ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahlpackage org.tigris.subversion.svnclientadapter.javahl; import java.util.ArrayList; import java.util.List; import org.apache.subversion.javahl.types.Info; import org.apache.subversion.javahl.callback.InfoCallback; import org.tigris.subversion.svnclientadapter.ISVNInfo; public class JhlInfoCallback implements InfoCallback { List items = new ArrayList(); public void singleInfo(Info info) { items.add(new JhlInfo2(info.getPath(), info)); } public ISVNInfo[] getInfo() { ISVNInfo[] itemArray = new ISVNInfo[items.size()]; return items.toArray(itemArray); } } svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/JhlLock.java000066400000000000000000000046521203563747500325270ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import java.util.Date; import org.apache.subversion.javahl.types.Lock; import org.tigris.subversion.svnclientadapter.ISVNLock; /** * A JavaHL based implementation of {@link ISVNLock}. * Actually just an adapter from {@link org.tigris.subversion.javahl.Lock} * * @author Mark Phippard */ public class JhlLock implements ISVNLock { private Lock _l; /** * Constructor * @param lock */ public JhlLock(Lock lock) { super(); _l = lock; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLock#getOwner() */ public String getOwner() { return _l.getOwner(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLock#getPath() */ public String getPath() { return _l.getPath(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLock#getToken() */ public String getToken() { return _l.getToken(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLock#getComment() */ public String getComment() { return _l.getComment(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLock#getCreationDate() */ public Date getCreationDate() { return _l.getCreationDate(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLock#getExpirationDate() */ public Date getExpirationDate() { return _l.getExpirationDate(); } } svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/JhlLogMessage.java000066400000000000000000000113071203563747500336600ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import java.io.UnsupportedEncodingException; import java.text.ParseException; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.subversion.javahl.types.ChangePath; import org.apache.subversion.javahl.types.LogDate; import org.tigris.subversion.svnclientadapter.ISVNLogMessage; import org.tigris.subversion.svnclientadapter.ISVNLogMessageChangePath; import org.tigris.subversion.svnclientadapter.SVNRevision; /** * A JavaHL based implementation of {@link ISVNLogMessage}. * Actually just an adapter from {@link org.tigris.subversion.javahl.LogMessage} * * @author philip schatz */ public class JhlLogMessage implements ISVNLogMessage { private static final String EMPTY = ""; private List children; private boolean hasChildren; private ISVNLogMessageChangePath[] changedPaths; private SVNRevision.Number revision; private Map revprops; private LogDate logDate; public JhlLogMessage(Set changedPaths, long revision, Map revprops, boolean hasChildren) { this.changedPaths = JhlConverter.convertChangePaths(changedPaths); this.revision = new SVNRevision.Number(revision); this.revprops = revprops; if (this.revprops == null) { this.revprops = new HashMap(2); // avoid NullPointerErrors this.revprops.put(AUTHOR, EMPTY.getBytes()); this.revprops.put(MESSAGE, EMPTY.getBytes()); } this.hasChildren = hasChildren; try { logDate = new LogDate(new String(this.revprops.get(DATE))); } catch (ParseException e) { } } public void addChild(ISVNLogMessage msg) { if (children == null) children = new ArrayList(); children.add(msg); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLogMessage#getRevision() */ public SVNRevision.Number getRevision() { return revision; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLogMessage#getAuthor() */ public String getAuthor() { byte[] author = revprops.get(AUTHOR); if (author == null) { return ""; } else { try { return new String(author, "UTF8"); } catch (UnsupportedEncodingException e) { return new String(author); } } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLogMessage#getDate() */ public Date getDate() { if (logDate == null) return new Date(0L); return logDate.getDate(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLogMessage#getMessage() */ public String getMessage() { byte[] message = revprops.get(MESSAGE); if (message == null) { return ""; } else { try { return new String(message, "UTF8"); } catch (UnsupportedEncodingException e) { return new String(message); } } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLogMessage#getChangedPaths() */ public ISVNLogMessageChangePath[] getChangedPaths() { return changedPaths; } /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { return getMessage(); } public ISVNLogMessage[] getChildMessages() { if (hasChildren && children != null) { ISVNLogMessage[] childArray = new JhlLogMessage[children.size()]; children.toArray(childArray); return childArray; } else return null; } public long getNumberOfChildren() { if (hasChildren && children != null) return children.size(); else return 0L; } public long getTimeMillis() { if (logDate == null) return 0L; return logDate.getTimeMillis(); } public long getTimeMicros() { if (logDate == null) return 0L; return logDate.getTimeMicros(); } public boolean hasChildren() { return hasChildren; } } JhlLogMessageCallback.java000066400000000000000000000016451203563747500352220ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahlpackage org.tigris.subversion.svnclientadapter.javahl; import java.util.Map; import java.util.Set; import org.apache.subversion.javahl.types.ChangePath; import org.apache.subversion.javahl.types.Revision; import org.apache.subversion.javahl.callback.LogMessageCallback; import org.tigris.subversion.svnclientadapter.ISVNLogMessageCallback; public class JhlLogMessageCallback implements LogMessageCallback { private ISVNLogMessageCallback worker = null; public JhlLogMessageCallback(ISVNLogMessageCallback callback) { super(); worker = callback; } public JhlLogMessageCallback() { super(); } public void singleMessage(Set changedPaths, long revision, Map revprops, boolean hasChildren) { if (revision == Revision.SVN_INVALID_REVNUM) { worker.singleMessage(null); } else { worker.singleMessage(new JhlLogMessage(changedPaths, revision, revprops, hasChildren)); } } } JhlLogMessageChangePath.java000066400000000000000000000033221203563747500355220ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/******************************************************************************* * Copyright (c) 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import org.apache.subversion.javahl.types.ChangePath; import org.tigris.subversion.svnclientadapter.SVNLogMessageChangePath; import org.tigris.subversion.svnclientadapter.SVNRevision; /** * JavaHL specific implementation of the {@link org.tigris.subversion.svnclientadapter.ISVNLogMessageChangePath}. * Actually just an adapter from {@link org.tigris.subversion.javahl.ChangePath} * */ public class JhlLogMessageChangePath extends SVNLogMessageChangePath { /** * Constructor * @param changePath */ public JhlLogMessageChangePath(ChangePath changePath) { super( changePath.getPath(), (changePath.getCopySrcRevision() != -1) ? new SVNRevision.Number( changePath.getCopySrcRevision()) : null, changePath.getCopySrcPath(), JhlConverter.convert(changePath.getAction())); } } svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/JhlMergeInfo.java000066400000000000000000000043641203563747500335120ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2007 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import org.apache.subversion.javahl.types.Mergeinfo; import org.tigris.subversion.svnclientadapter.ISVNMergeInfo; import org.tigris.subversion.svnclientadapter.SVNRevisionRange; public class JhlMergeInfo implements ISVNMergeInfo { Mergeinfo info; public JhlMergeInfo() { super(); info = new Mergeinfo(); } public JhlMergeInfo(Mergeinfo info) { super(); this.info = info; } public void addRevisionRange(String path, SVNRevisionRange range) { if (info == null) info = new Mergeinfo(); info.addRevisionRange(path, JhlConverter.convert(range)); } public void addRevisions(String path, SVNRevisionRange[] range) { if (info == null) info = new Mergeinfo(); info.addRevisions(path, JhlConverter.convert(range)); } public String[] getPaths() { if (info == null) return null; return (String[]) info.getPaths().toArray(); } public SVNRevisionRange[] getRevisionRange(String path) { if (info == null) return null; return JhlConverter.convertRevisionRange(info.getRevisionRange(path)); } public SVNRevisionRange[] getRevisions(String path) { if (info == null) return null; return JhlConverter.convertRevisionRange(info.getRevisions(path)); } public void loadFromMergeInfoProperty(String mergeInfo) { if (info == null) info = new Mergeinfo(); info.loadFromMergeinfoProperty(mergeInfo); } } JhlNotificationHandler.java000066400000000000000000000637751203563747500355170ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import org.apache.subversion.javahl.ClientNotifyInformation; import org.apache.subversion.javahl.types.Revision; import org.apache.subversion.javahl.types.RevisionRange; import org.apache.subversion.javahl.callback.ClientNotifyCallback; import org.tigris.subversion.svnclientadapter.ISVNNotifyListener; import org.tigris.subversion.svnclientadapter.SVNConflictVersion.NodeKind; import org.tigris.subversion.svnclientadapter.SVNNotificationHandler; import org.tigris.subversion.svnclientadapter.utils.Messages; /** * Notification handler : * It listens to events from javahl jni implementation and handles * notifications from SVNClientAdapter. * It sends notifications to all listeners * * It mimics svn output (see subversion/clients/cmdline/notify.c) * * */ public class JhlNotificationHandler extends SVNNotificationHandler implements ClientNotifyCallback { private boolean receivedSomeChange; private boolean sentFirstTxdelta; private int updates; private int adds; private int deletes; private int conflicts; private int merges; private int exists; private int propConflicts; private int treeConflicts; private int propMerges; private int propUpdates; private boolean inExternal; private boolean holdStats; private String lastUpdate; private String lastExternalUpdate; private boolean statsCommand = false; private static final int COMMIT_ACROSS_WC_COMPLETED = -11; private static final int ENDED_ABNORMAL = -1; public void onNotify(ClientNotifyInformation info) { // for some actions, we don't want to call notifyListenersOfChange : // when the status of the target has not been modified boolean notify = true; switch (info.getAction()) { case foreign_merge_begin : if (info.getMergeRange() != null) { if (info.getMergeRange().getFromRevision().equals(info.getMergeRange().getToRevision())) logMessage("--- Merging (from foreign repository) r" + info.getMergeRange().getFromRevision().toString() + " into " + info.getPath()); else if (info.getMergeRange().getToRevision().equals(Revision.HEAD) || RevisionRange.getRevisionAsLong(info.getMergeRange().getToRevision()).longValue() > RevisionRange.getRevisionAsLong(info.getMergeRange().getFromRevision()).longValue()) logMessage("--- Merging (from foreign repository) r" + info.getMergeRange().getFromRevision().toString() + " through r" + info.getMergeRange().getToRevision().toString() + " into " + info.getPath()); else logMessage("--- Reverse-merging (from foreign repository) r" + info.getMergeRange().getFromRevision().toString() + " through r" + info.getMergeRange().getToRevision().toString() + " into " + info.getPath()); } else { logMessage("--- Merging differences between foreign repository URLs into " + info.getPath()); } notify = false; break; case merge_begin : if (info.getMergeRange() != null) { if (info.getMergeRange().getFromRevision().equals(info.getMergeRange().getToRevision())) logMessage("--- Merging r" + info.getMergeRange().getFromRevision().toString() + " into " + info.getPath()); else if (info.getMergeRange().getToRevision().equals(Revision.HEAD) || RevisionRange.getRevisionAsLong(info.getMergeRange().getToRevision()).longValue() > RevisionRange.getRevisionAsLong(info.getMergeRange().getFromRevision()).longValue()) logMessage("--- Merging r" + info.getMergeRange().getFromRevision().toString() + " through r" + info.getMergeRange().getToRevision().toString() + " into " + info.getPath()); else logMessage("--- Reverse-merging r" + info.getMergeRange().getFromRevision().toString() + " through r" + info.getMergeRange().getToRevision().toString() + " into " + info.getPath()); } else { logMessage("--- Merging differences between repository URLs into " + info.getPath()); } notify = false; break; case skip : notify = logSkipped(info, Messages.bind("notify.skipped", info.getPath())); //$NON-NLS-1$ break; case update_skip_obstruction : notify = logSkipped(info, Messages.bind("notify.update.skip.obstruction", info.getPath())); //$NON-NLS-1$ break; case update_skip_working_only : notify = logSkipped(info, Messages.bind("notify.update.skip.working.only", info.getPath())); //$NON-NLS-1$ break; case update_skip_access_denied : notify = logSkipped(info, Messages.bind("notify.update.skip.access.denied", info.getPath())); //$NON-NLS-1$ break; case failed_lock: notify = logFailedOperation(info, Messages.bind("notify.lock.failed", info.getPath())); //$NON-NLS-1$ break; case failed_unlock: notify = logFailedOperation(info, Messages.bind("notify.unlock.failed", info.getPath())); //$NON-NLS-1$ break; case locked: if (info.getLock() != null && info.getLock().getOwner() != null) logMessage(Messages.bind("notify.lock.other", info.getLock().getPath(), info.getLock().getOwner())); //$NON-NLS-1$ else logMessage(Messages.bind("notify.lock", info.getPath())); //$NON-NLS-1$ notify = false; // for JavaHL bug break; case unlocked: logMessage(Messages.bind("notify.unlock", info.getPath())); //$NON-NLS-1$ notify = false; // for JavaHL bug break; case update_delete : case update_shadowed_delete : logMessage("D " + info.getPath()); //$NON-NLS-1$ receivedSomeChange = true; deletes += 1; break; case update_replaced : logMessage("R " + info.getPath()); //$NON-NLS-1$ receivedSomeChange = true; adds += 1; deletes += 1; break; case update_add : case update_shadowed_add : logMessage("A " + info.getPath()); //$NON-NLS-1$ receivedSomeChange = true; adds += 1; break; case exists : logMessage("E " + info.getPath()); //$NON-NLS-1$ receivedSomeChange = true; exists += 1; break; case changelist_set : logMessage(Messages.bind("notify.changelist.set", info.getPath())); //$NON-NLS-1$ notify = false; break; case changelist_clear : logMessage(Messages.bind("notify.changelist.clear", info.getPath())); //$NON-NLS-1$ notify = false; break; case changelist_moved : logMessage(Messages.bind("notify.changelist.moved", info.getPath())); //$NON-NLS-1$ notify = false; break; case restore : logMessage(Messages.bind("notify.restored", info.getPath())); //$NON-NLS-1$ break; case revert : logMessage(Messages.bind("notify.reverted", info.getPath())); //$NON-NLS-1$ break; case failed_revert : logError(Messages.bind("notify.revert.failed", info.getPath())); //$NON-NLS-1$ notify = false; break; case resolved : logMessage(Messages.bind("notify.resolved", info.getPath())); //$NON-NLS-1$ break; case add : logMessage("A " + info.getPath()); //$NON-NLS-1$ break; case copy : logMessage(Messages.bind("notify.copy", info.getPath())); //$NON-NLS-1$ notify = false; break; case delete : logMessage("D " + info.getPath()); //$NON-NLS-1$ receivedSomeChange = true; break; case tree_conflict : logError(" C " + info.getPath()); //$NON-NLS-1$ receivedSomeChange = true; treeConflicts += 1; break; case update_update : case update_shadowed_update : boolean error = false; if (!((info.getKind().ordinal() == NodeKind.directory) && ((info.getPropState() == ClientNotifyInformation.Status.inapplicable) || (info.getPropState() == ClientNotifyInformation.Status.unknown) || (info.getPropState() == ClientNotifyInformation.Status.unchanged)))) { receivedSomeChange = true; char[] statecharBuf = new char[] { ' ', ' ' }; if (info.getKind().ordinal() == NodeKind.file) { if (info.getContentState() == ClientNotifyInformation.Status.conflicted) { statecharBuf[0] = 'C'; conflicts += 1; error = true; } else if (info.getContentState() == ClientNotifyInformation.Status.merged) { statecharBuf[0] = 'G'; merges += 1; error = true; } else if (info.getContentState() == ClientNotifyInformation.Status.changed) { statecharBuf[0] = 'U'; updates += 1; } else if (info.getContentState() == ClientNotifyInformation.Status.unchanged && info.getPropState().ordinal() < ClientNotifyInformation.Status.obstructed.ordinal()) break; } if (info.getPropState() == ClientNotifyInformation.Status.conflicted) { statecharBuf[1] = 'C'; propConflicts += 1; error = true; } else if (info.getPropState() == ClientNotifyInformation.Status.merged) { statecharBuf[1] = 'G'; propMerges += 1; error = true; } else if (info.getPropState() == ClientNotifyInformation.Status.changed) { statecharBuf[1] = 'U'; propUpdates += 1; } if (info.getContentState() == ClientNotifyInformation.Status.unknown && info.getPropState() == ClientNotifyInformation.Status.unknown) break; if (error) logError("" + statecharBuf[0] + statecharBuf[1] + " " + info.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ else logMessage("" + statecharBuf[0] + statecharBuf[1] + " " + info.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ } break; case update_external : logMessage(Messages.bind("notify.update.external", info.getPath())); //$NON-NLS-1$ inExternal = true; break; case update_external_removed : logMessage(Messages.bind("notify.update.external.removed", info.getPath())); //$NON-NLS-1$ break; case update_completed : notify = false; if (info.getRevision() >= 0) { logRevision( info.getRevision(), info.getPath() ); if (command == ISVNNotifyListener.Command.EXPORT) { logCompleted(Messages.bind("notify.export", Long.toString(info.getRevision()))); //$NON-NLS-1$ } else if (command == ISVNNotifyListener.Command.CHECKOUT) { logCompleted(Messages.bind("notify.checkout", Long.toString(info.getRevision()))); //$NON-NLS-1$ } else if (receivedSomeChange) { if (holdStats) { // Hold off until the releaseStats() method // is executed. Keeps noise out of the log. if (inExternal) lastExternalUpdate = Messages.bind("notify.update", Long.toString(info.getRevision())); //$NON-NLS-1$ else lastUpdate = Messages.bind("notify.update", Long.toString(info.getRevision())); //$NON-NLS-1$ } else logCompleted(Messages.bind("notify.update", Long.toString(info.getRevision()))); //$NON-NLS-1$ } else { logCompleted(Messages.bind("notify.at", Long.toString(info.getRevision()))); //$NON-NLS-1$ } } else { if (command == ISVNNotifyListener.Command.EXPORT) { logCompleted(Messages.bind("notify.export.complete")); //$NON-NLS-1$ } else if (command == ISVNNotifyListener.Command.CHECKOUT) { logCompleted(Messages.bind("notify.checkout.complete")); //$NON-NLS-1$ } else { logCompleted(Messages.bind("notify.update.complete")); //$NON-NLS-1$ } } break; case status_external : if (!skipCommand()) logMessage(Messages.bind("notify.status.external", info.getPath())); //$NON-NLS-1$ notify = false; break; case status_completed : notify = false; if (info.getRevision() >= 0) { logRevision(info.getRevision(), info.getPath()); if (!skipCommand()) logMessage(Messages.bind("notify.status.revision", Long.toString(info.getRevision()))); //$NON-NLS-1$ } break; case commit_modified : logMessage(Messages.bind("notify.commit.modified", info.getPath())); //$NON-NLS-1$ break; case commit_added : case commit_copied : logMessage(Messages.bind("notify.commit.add", info.getPath())); //$NON-NLS-1$ break; case commit_deleted : logMessage(Messages.bind("notify.commit.delete", info.getPath())); //$NON-NLS-1$ break; case commit_replaced : case commit_copied_replaced : logMessage(Messages.bind("notify.commit.replace", info.getPath())); //$NON-NLS-1$ break; case commit_postfix_txdelta : notify = false; if (!sentFirstTxdelta) { logMessage(Messages.bind("notify.commit.transmit")); //$NON-NLS-1$ sentFirstTxdelta = true; } break; case url_redirect : break; case property_added: logMessage(Messages.bind("notify.property.set", info.getPath())); //$NON-NLS-1$ break; case property_modified: logMessage(Messages.bind("notify.property.set", info.getPath())); //$NON-NLS-1$ break; case property_deleted: logMessage(Messages.bind("notify.property.deleted", info.getPath())); //$NON-NLS-1$ break; case property_deleted_nonexistent: notify = false; logMessage(Messages.bind("notify.property.deleted.nonexistent")); //$NON-NLS-1$ break; case revprop_set: notify = false; logMessage(Messages.bind("notify.revision.property.set")); //$NON-NLS-1$ break; case revprop_deleted: notify = false; logMessage(Messages.bind("notify.revision.property.deleted")); //$NON-NLS-1$ break; case merge_completed: break; case blame_revision: break; case update_started: break; case merge_record_info: logMessage(Messages.bind("notify.merge.record.info", info.getPath())); //$NON-NLS-1$ propUpdates += 1; break; case merge_record_info_begin: break; case merge_elide_info: break; case patch: notify = false; logMessage(Messages.bind("notify.patch")); //$NON-NLS-1$ break; case patch_applied_hunk: logMessage(Messages.bind("notify.patch.applied.hunk", info.getPath())); //$NON-NLS-1$ break; case patch_rejected_hunk: notify = logFailedOperation(info, Messages.bind("notify.patch.rejected.hunk", info.getPath())); break; case patch_hunk_already_applied: notify = logFailedOperation(info, Messages.bind("notify.patch.hunk.already.applied", info.getPath())); break; case upgraded_path: logMessage(Messages.bind("notify.upgraded.path", info.getPath())); //$NON-NLS-1$ break; case failed_external: notify = logFailedOperation(info, Messages.bind("notify.external", info.getPath())); //$NON-NLS-1$ break; case failed_conflict: notify = logFailedOperation(info, Messages.bind("notify.conflict", info.getPath())); //$NON-NLS-1$ break; case failed_missing: notify = logFailedOperation(info, Messages.bind("notify.missing", info.getPath())); //$NON-NLS-1$ break; case failed_out_of_date: notify = logFailedOperation(info, Messages.bind("notify.out.of.date", info.getPath())); //$NON-NLS-1$ break; case failed_no_parent: notify = logFailedOperation(info, Messages.bind("notify.no.parent")); //$NON-NLS-1$ break; case failed_locked: notify = logFailedOperation(info, Messages.bind("notify.locked", info.getPath())); //$NON-NLS-1$ break; case failed_forbidden_by_server: notify = logFailedOperation(info, Messages.bind("notify.forbidden.by.server")); //$NON-NLS-1$ break; case path_nonexistent: notify = logFailedOperation(info, Messages.bind("notify.path.nonexistent", info.getPath())); //$NON-NLS-1$ break; case exclude: logMessage(Messages.bind("notify.exclude", info.getPath())); break; default: if (info.getAction().ordinal() == ENDED_ABNORMAL) { if (command == ISVNNotifyListener.Command.COMMIT) logError(Messages.bind("notify.commit.abnormal")); //$NON-NLS-1$ else logError(Messages.bind("notify.end.abnormal")); //$NON-NLS-1$ if (info.getErrMsg() != null) logError(info.getErrMsg()); notify = false; break; } if (info.getAction().ordinal() == COMMIT_ACROSS_WC_COMPLETED) { notify = false; logCompleted(Messages.bind("notify.commit", Long.toString(info.getRevision()))); //$NON-NLS-1$ break; } logMessage("Unknown action received: " + info.getAction()); } if (notify) { // only when the status changed notifyListenersOfChange(info.getPath(), JhlConverter.convertNodeKind(info.getKind())); } } private boolean logFailedOperation(ClientNotifyInformation info, String defaultErrorMessage) { if (info.getErrMsg() == null) logError(defaultErrorMessage); else logError(info.getErrMsg()); return false; } private boolean logSkipped(ClientNotifyInformation info, String defaultErrorMessage) { if (info.getErrMsg() == null) logMessage(defaultErrorMessage); else logError(info.getErrMsg()); return false; } public void setCommand(int command) { receivedSomeChange = false; sentFirstTxdelta = false; if (command == ISVNNotifyListener.Command.UPDATE || command == ISVNNotifyListener.Command.MERGE || command == ISVNNotifyListener.Command.SWITCH) { clearStats(); statsCommand = true; } super.setCommand(command); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.SVNNotificationHandler#logCompleted(java.lang.String) */ public void logCompleted(String message) { super.logCompleted(message); if (inExternal) inExternal = false; else logStats(); } private void clearStats(){ adds = 0; updates = 0; deletes = 0; conflicts = 0; merges = 0; exists = 0; propConflicts = 0; treeConflicts = 0; propMerges = 0; propUpdates = 0; inExternal = false; holdStats = false; lastUpdate = null; lastExternalUpdate = null; } private void logStats() { if (holdStats) return; if (statsCommand) { if (fileStats()) { logMessage(Messages.bind("notify.stats.file.head")); //$NON-NLS-1$ if (merges > 0) logMessage(Messages.bind("notify.stats.merge", Integer.toString(merges))); //$NON-NLS-1$ if (deletes > 0) logMessage(Messages.bind("notify.stats.delete", Integer.toString(deletes))); //$NON-NLS-1$ if (adds > 0) logMessage(Messages.bind("notify.stats.add", Integer.toString(adds))); //$NON-NLS-1$ if (updates > 0) logMessage(Messages.bind("notify.stats.update", Integer.toString(updates))); //$NON-NLS-1$ if (exists > 0) logMessage(Messages.bind("notify.stats.exists", Integer.toString(exists))); //$NON-NLS-1$ } if (propStats()){ logMessage(Messages.bind("notify.stats.prop.head")); //$NON-NLS-1$ if (propMerges > 0) logMessage(Messages.bind("notify.stats.merge", Integer.toString(propMerges))); //$NON-NLS-1$ if (propUpdates > 0) logMessage(Messages.bind("notify.stats.update", Integer.toString(propUpdates))); //$NON-NLS-1$ } if (conflictStats()) { logMessage(Messages.bind("notify.stats.conflict.head")); //$NON-NLS-1$ if (conflicts > 0) logMessage(Messages.bind("notify.stats.conflict", Integer.toString(conflicts))); //$NON-NLS-1$ if (propConflicts > 0) logMessage(Messages.bind("notify.stats.prop.conflicts", Integer.toString(propConflicts))); //$NON-NLS-1$ if (treeConflicts > 0) { logMessage(Messages.bind("notify.stats.tree.conflicts", Integer.toString(treeConflicts))); //$NON-NLS-1$ } } statsCommand = false; clearStats(); } } private boolean fileStats() { if (updates > 0 || adds > 0 || deletes > 0 || merges > 0 || exists > 0) return true; return false; } private boolean conflictStats() { if (treeConflicts > 0 || propConflicts > 0 || conflicts > 0) return true; return false; } private boolean propStats() { if (propUpdates > 0 || propMerges > 0) return true; return false; } /** * Put a hold on the logging of stats. This method allows * the update method to hold off logging stats until all of * a set of updates are completed. */ public void holdStats() { this.holdStats = true; } /** * Perform the logging of any accumulated stats. * The update method will call this after the command completes * so that the stats logging can wait until the very end. */ public void releaseStats() { this.holdStats = false; if (command == ISVNNotifyListener.Command.UPDATE) { // In addition to the stats, need to send the // Updated to revision N. messages that normally // appear in the log. if (lastExternalUpdate != null) logCompleted(lastExternalUpdate); if (lastUpdate != null) logCompleted(lastUpdate); } logStats(); } }JhlProgressListener.java000066400000000000000000000012571203563747500350700ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahlpackage org.tigris.subversion.svnclientadapter.javahl; import org.apache.subversion.javahl.ProgressEvent; import org.apache.subversion.javahl.callback.ProgressCallback; import org.tigris.subversion.svnclientadapter.ISVNProgressListener; import org.tigris.subversion.svnclientadapter.SVNProgressEvent; public class JhlProgressListener implements ProgressCallback { ISVNProgressListener worker; public JhlProgressListener() { super(); } public void onProgress(ProgressEvent event) { if (worker != null ) worker.onProgress(new SVNProgressEvent(event.getProgress(), event.getTotal())); } public void setWorker(ISVNProgressListener worker) { this.worker = worker; } } JhlPromptUserPassword.java000066400000000000000000000073601203563747500354220ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import org.apache.subversion.javahl.callback.UserPasswordCallback; import org.tigris.subversion.svnclientadapter.ISVNPromptUserPassword; /** * A JavaHL's PromptUserPassword3 implementation. * Actually an adapter to {@link ISVNPromptUserPassword} */ public class JhlPromptUserPassword implements UserPasswordCallback { private ISVNPromptUserPassword worker; /** * Constructor * @param arg0 */ public JhlPromptUserPassword(ISVNPromptUserPassword arg0) { super(); this.worker = arg0; } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword3#prompt(java.lang.String, java.lang.String, boolean) */ public boolean prompt(String realm, String username, boolean maySave) { return this.worker.prompt(realm, username, maySave); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword3#askQuestion(java.lang.String, java.lang.String, boolean, boolean) */ public String askQuestion(String realm, String question, boolean showAnswer, boolean maySave) { return this.worker.askQuestion(realm, question, showAnswer, maySave); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword3#userAllowedSave() */ public boolean userAllowedSave() { return this.worker.userAllowedSave(); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword2#askTrustSSLServer(java.lang.String, boolean) */ public int askTrustSSLServer(String info, boolean allowPermanently) { return this.worker.askTrustSSLServer(info, allowPermanently); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword#prompt(java.lang.String, java.lang.String) */ public boolean prompt(String realm, String username) { return this.prompt(realm, username, true); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword#askYesNo(java.lang.String, java.lang.String, boolean) */ public boolean askYesNo(String realm, String question, boolean yesIsDefault) { return this.worker.askYesNo(realm, question, yesIsDefault); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword#askQuestion(java.lang.String, java.lang.String, boolean) */ public String askQuestion(String realm, String question, boolean showAnswer) { return this.askQuestion(realm, question, showAnswer, true); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword#getUsername() */ public String getUsername() { return this.worker.getUsername(); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword#getPassword() */ public String getPassword() { return this.worker.getPassword(); } } JhlPropertyData.java000066400000000000000000000067511203563747500342000ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import java.io.File; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import org.tigris.subversion.svnclientadapter.ISVNProperty; import org.tigris.subversion.svnclientadapter.SVNUrl; /** * A JavaHL based implementation of {@link ISVNProperty}. * Actually just an adapter from {@link org.tigris.subversion.javahl.PropertyData} * * @author philip schatz */ public class JhlPropertyData implements ISVNProperty { private String key; private byte[] data; private String path; private boolean isForUrl; /** * Factory method for properties on local resource (file or dir) * @param propertyData * @return a JhlPropertyData constructed from supplied propertyData */ public static JhlPropertyData newForFile(String path, String key, byte[] data) { return new JhlPropertyData(path, key, data, false); } /** * Factory method for properties on remote resource (url) * @param propertyData * @return a JhlPropertyData constructed from supplied propertyData */ public static JhlPropertyData newForUrl(String path, String key, byte[] data) { return new JhlPropertyData(path, key, data, true); } /** * Constructor * @param propertyData */ private JhlPropertyData(String path, String key, byte[] data, boolean isForUrl) { this.path = path; this.key = key; this.data = data; this.isForUrl = isForUrl; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNProperty#getName() */ public String getName() { return key; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNProperty#getValue() */ public String getValue() { try { return new String(data, "UTF8"); } catch (UnsupportedEncodingException e) { return new String(data); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNProperty#getFile() */ public File getFile() { return isForUrl ? null : new File(path).getAbsoluteFile(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNProperty#getUrl() */ public SVNUrl getUrl() { try { return isForUrl ? new SVNUrl(path) : null; } catch (MalformedURLException e) { //should never happen. return null; } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNProperty#getData() */ public byte[] getData() { return data; } } JhlProplistCallback.java000066400000000000000000000017211203563747500350030ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahlpackage org.tigris.subversion.svnclientadapter.javahl; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.subversion.javahl.callback.ProplistCallback; import org.tigris.subversion.svnclientadapter.ISVNProperty; public class JhlProplistCallback implements ProplistCallback { private boolean isFile; List props; public JhlProplistCallback(boolean file) { isFile = file; props = new ArrayList(); } public void singlePath(String path, Map properties) { Set keys = properties.keySet(); for (String key : keys) { if (isFile) { props.add(JhlPropertyData.newForFile(path, key, properties.get(key))); } else { props.add(JhlPropertyData.newForUrl(path, key, properties.get(key))); } } } public ISVNProperty[] getPropertyData() { ISVNProperty[] propArray = new ISVNProperty[props.size()]; return props.toArray(propArray); } } svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/JhlStatus.java000066400000000000000000000256071203563747500331250ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.javahl; import java.io.File; import java.net.MalformedURLException; import java.util.Date; import org.apache.subversion.javahl.ClientException; import org.apache.subversion.javahl.ConflictDescriptor; import org.apache.subversion.javahl.ISVNClient; import org.apache.subversion.javahl.callback.InfoCallback; import org.apache.subversion.javahl.types.Depth; import org.apache.subversion.javahl.types.Info; import org.apache.subversion.javahl.types.Status; import org.tigris.subversion.svnclientadapter.ISVNStatus; import org.tigris.subversion.svnclientadapter.SVNConflictDescriptor; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.SVNUrl; /** * A JavaHL based implementation of {@link ISVNStatus}. * Actually just an adapter from {@link org.tigris.subversion.javahl.Status} * * @author philip schatz */ public class JhlStatus implements ISVNStatus { protected Status _s; private SVNRevision.Number lastChangedRevision; private String lastChangedAuthor; private Date lastChangedDate; private boolean treeConflict = false; private ConflictDescriptor conflictDescriptor; private String conflictOld; private String conflictWorking; private String conflictNew; /** * Constructor * @param status */ public JhlStatus(Status status, ISVNClient client) { // note that status.textStatus must be different than 0 (the resource must exist) super(); _s = status; // This is a workaround for an SVNKit bug that results in _s.isConflicted == false for an old format // working copy, even if the file is text conflicted. boolean textConflicted = _s.getTextStatus() != null && _s.getTextStatus().equals(Status.Kind.conflicted); try { if (client != null && (_s.isConflicted() || textConflicted)) populateInfo(client, _s.getPath()); } catch (ClientException e) { // Ignore } } private void populateInfo(ISVNClient aClient, String path) throws ClientException { class MyInfoCallback implements InfoCallback { Info info; public void singleInfo(Info aInfo) { info = aInfo; } public Info getInfo() { return info; } } MyInfoCallback callback = new MyInfoCallback(); aClient.info2(path, null, null, Depth.empty, null, callback); Info aInfo = callback.getInfo(); if (aInfo == null) return; if (aInfo.getConflicts() != null) { for (ConflictDescriptor conflict : aInfo.getConflicts()) { switch (conflict.getKind()) { case tree: this.treeConflict = true; this.conflictDescriptor = conflict; break; case text: this.conflictOld = conflict.getBasePath(); this.conflictWorking = conflict.getMyPath(); this.conflictNew = conflict.getTheirPath(); break; case property: // Ignore break; } } } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getUrl() */ public SVNUrl getUrl() { try { return (_s.getUrl() != null) ? new SVNUrl(_s.getUrl()) : null; } catch (MalformedURLException e) { //should never happen. return null; } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getUrlString() */ public String getUrlString() { return _s.getUrl(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLastChangedRevision() */ public SVNRevision.Number getLastChangedRevision() { // we don't use // return (SVNRevision.Number)JhlConverter.convert(_s.getLastChangedRevision()); // as _s.getLastChangedRevision() is currently broken if revision is -1 if (lastChangedRevision != null) return lastChangedRevision; if (_s.getReposLastCmtAuthor() == null) return JhlConverter.convertRevisionNumber(_s.getLastChangedRevisionNumber()); else if (_s.getReposLastCmtRevisionNumber() == 0) return null; return JhlConverter.convertRevisionNumber(_s.getReposLastCmtRevisionNumber()); } public SVNRevision.Number getReposLastChangedRevision() { return JhlConverter.convertRevisionNumber(_s.getReposLastCmtRevisionNumber()); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLastChangedDate() */ public Date getLastChangedDate() { if (lastChangedDate != null) return lastChangedDate; if (_s.getReposLastCmtAuthor() == null) return _s.getLastChangedDate(); else return _s.getReposLastCmtDate(); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLastCommitAuthor() */ public String getLastCommitAuthor() { if (lastChangedAuthor != null) return lastChangedAuthor; if (_s.getReposLastCmtAuthor() == null) return _s.getLastCommitAuthor(); else return _s.getReposLastCmtAuthor(); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getTextStatus() */ public SVNStatusKind getTextStatus() { return JhlConverter.convertStatusKind(_s.getTextStatus()); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getPropStatus() */ public SVNStatusKind getPropStatus() { return JhlConverter.convertStatusKind(_s.getPropStatus()); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getRevision() */ public SVNRevision.Number getRevision() { return JhlConverter.convertRevisionNumber(_s.getRevisionNumber()); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#isCopied() */ public boolean isCopied() { return _s.isCopied(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#isWcLocked() */ public boolean isWcLocked() { return _s.isLocked(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#isSwitched() */ public boolean isSwitched() { return _s.isSwitched(); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getPath() */ public String getPath() { return _s.getPath(); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getFile() */ public File getFile() { return new File(getPath()).getAbsoluteFile(); } /* * (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getNodeKind() */ public SVNNodeKind getNodeKind() { SVNNodeKind nodeKind; if (_s.getReposLastCmtAuthor() == null) nodeKind = JhlConverter.convertNodeKind(_s.getNodeKind()); else nodeKind = JhlConverter.convertNodeKind(_s.getReposKind()); return nodeKind; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getRepositoryTextStatus() */ public SVNStatusKind getRepositoryTextStatus() { return JhlConverter.convertStatusKind(_s.getRepositoryTextStatus()); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getRepositoryPropStatus() */ public SVNStatusKind getRepositoryPropStatus() { return JhlConverter.convertStatusKind(_s.getRepositoryPropStatus()); } /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { return getPath() + " "+getTextStatus().toString(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getConflictNew() */ public File getConflictNew() { String path = conflictNew; return (path != null) ? new File(path) .getAbsoluteFile() : null; } /* * (non-Javadoc) * * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getConflictOld() */ public File getConflictOld() { String path = conflictOld; return (path != null) ? new File(path) .getAbsoluteFile() : null; } /* * (non-Javadoc) * * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getConflictWorking() */ public File getConflictWorking() { String path = conflictWorking; return (path != null) ? new File(path) .getAbsoluteFile() : null; } /* * (non-Javadoc) * * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLockCreationDate() */ public Date getLockCreationDate() { if (_s.getLocalLock() == null) return null; return _s.getLocalLock().getCreationDate(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLockOwner() */ public String getLockOwner() { if (_s.getLocalLock() == null) return null; return _s.getLocalLock().getOwner(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLockComment() */ public String getLockComment() { if (_s.getLocalLock() == null) return null; return _s.getLocalLock().getComment(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getTreeConflicted() */ public boolean hasTreeConflict() { return treeConflict; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#isFileExternal() */ public boolean isFileExternal() { return _s.isFileExternal(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getConflictDescriptor() */ public SVNConflictDescriptor getConflictDescriptor() { return JhlConverter.convertConflictDescriptor(conflictDescriptor); } public void updateFromStatus(JhlStatus info) { lastChangedRevision = info.getLastChangedRevision(); lastChangedAuthor = info.getLastCommitAuthor(); lastChangedDate = info.getLastChangedDate(); } /** * A special JhlStatus subclass representing svn:external resource. */ public static class JhlStatusExternal extends JhlStatus { /** * Constructor * @param status */ public JhlStatusExternal(JhlStatus status, ISVNClient client) { super(status._s, client); } public SVNStatusKind getTextStatus() { return SVNStatusKind.EXTERNAL; } } } JhlStatusCallback.java000066400000000000000000000014351203563747500344540ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahlpackage org.tigris.subversion.svnclientadapter.javahl; import java.util.ArrayList; import java.util.List; import org.apache.subversion.javahl.callback.StatusCallback; import org.apache.subversion.javahl.types.Status; import org.tigris.subversion.svnclientadapter.ISVNStatusCallback; public class JhlStatusCallback implements StatusCallback { private List statusList = new ArrayList(); private ISVNStatusCallback worker; public JhlStatusCallback(ISVNStatusCallback callback) { super(); worker = callback; } public void doStatus(String path, Status status) { worker.doStatus(path, new JhlStatus(status, null)); if (status != null) { statusList.add(status); } } public List getStatusList() { return statusList; } } SVNUrlWithPegRevision.java000066400000000000000000000021121203563747500352470ustar00rootroot00000000000000svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahlpackage org.tigris.subversion.svnclientadapter.javahl; import java.net.MalformedURLException; import java.text.ParseException; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNUrl; public class SVNUrlWithPegRevision { private SVNUrl url; private SVNRevision pegRevision; public SVNUrlWithPegRevision(SVNUrl url) { parse(url); } public SVNUrl getUrl() { return url; } public SVNRevision getPegRevision() { return pegRevision; } private void parse(SVNUrl url) { String urlString = url.toString(); if (!urlString.endsWith("@")) { int index = urlString.lastIndexOf("@"); if (index != -1) { String rev = urlString.substring(index + 1); try { pegRevision = SVNRevision.getRevision(rev); } catch (ParseException e) {} if (pegRevision != null) { urlString = urlString.substring(0, index); try { this.url = new SVNUrl(urlString); } catch (MalformedURLException e) { this.url = url; pegRevision = null; } return; } } } this.url = url; } } svnclientadapter-1.8.16/src/main/000077500000000000000000000000001203563747500167045ustar00rootroot00000000000000svnclientadapter-1.8.16/src/main/org/000077500000000000000000000000001203563747500174735ustar00rootroot00000000000000svnclientadapter-1.8.16/src/main/org/tigris/000077500000000000000000000000001203563747500207745ustar00rootroot00000000000000svnclientadapter-1.8.16/src/main/org/tigris/subversion/000077500000000000000000000000001203563747500231735ustar00rootroot00000000000000svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/000077500000000000000000000000001203563747500265415ustar00rootroot00000000000000svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/AbstractClientAdapter.java000066400000000000000000000445371203563747500336240ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; /** * Default implementation of some of the methods of ISVNClientAdapter * * @author Cédric Chabanois (cchabanois at no-log.org) * @author Panagiotis Korros (pkorros at bigfoot.com) */ public abstract class AbstractClientAdapter implements ISVNClientAdapter { /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#setKeywords(java.io.File, org.tigris.subversion.svnclientadapter.SVNKeywords, boolean) */ public void setKeywords(File path, SVNKeywords keywords, boolean recurse) throws SVNClientException { propertySet(path, ISVNProperty.KEYWORDS, keywords.toString(), recurse); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#addKeywords(java.io.File, org.tigris.subversion.svnclientadapter.SVNKeywords) */ public SVNKeywords addKeywords(File path, SVNKeywords keywords) throws SVNClientException { SVNKeywords currentKeywords = getKeywords(path); if (keywords.isHeadUrl()) currentKeywords.setHeadUrl(true); if (keywords.isId()) currentKeywords.setId(true); if (keywords.isLastChangedBy()) currentKeywords.setLastChangedBy(true); if (keywords.isLastChangedDate()) currentKeywords.setLastChangedBy(true); if (keywords.isLastChangedRevision()) currentKeywords.setLastChangedRevision(true); setKeywords(path,currentKeywords,false); return currentKeywords; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#removeKeywords(java.io.File, org.tigris.subversion.svnclientadapter.SVNKeywords) */ public SVNKeywords removeKeywords(File path, SVNKeywords keywords) throws SVNClientException { SVNKeywords currentKeywords = getKeywords(path); if (keywords.isHeadUrl()) currentKeywords.setHeadUrl(false); if (keywords.isId()) currentKeywords.setId(false); if (keywords.isLastChangedBy()) currentKeywords.setLastChangedBy(false); if (keywords.isLastChangedDate()) currentKeywords.setLastChangedBy(false); if (keywords.isLastChangedRevision()) currentKeywords.setLastChangedRevision(false); setKeywords(path,currentKeywords,false); return currentKeywords; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getIgnoredPatterns(java.io.File) */ public List getIgnoredPatterns(File path) throws SVNClientException { if (!path.isDirectory()) return null; List list = new ArrayList(); ISVNProperty pd = propertyGet(path, ISVNProperty.IGNORE); if (pd == null) return list; String patterns = pd.getValue(); StringTokenizer st = new StringTokenizer(patterns,"\n\r"); while (st.hasMoreTokens()) { String entry = st.nextToken(); if ((entry != null) && (entry.length() > 0)) { list.add(entry); } } return list; } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#getLogMessages(java.io.File, org.tigris.subversion.subclipse.client.ISVNRevision, org.tigris.subversion.subclipse.client.ISVNRevision) */ public ISVNLogMessage[] getLogMessages(File arg0, SVNRevision arg1, SVNRevision arg2) throws SVNClientException { return getLogMessages(arg0, arg1, arg2, true); } /* (non-Javadoc) * @see org.tigris.subversion.subclipse.client.ISVNClientAdapter#getLogMessages(java.net.URL, org.tigris.subversion.subclipse.client.ISVNRevision, org.tigris.subversion.subclipse.client.ISVNRevision) */ public ISVNLogMessage[] getLogMessages(SVNUrl arg0, SVNRevision arg1, SVNRevision arg2) throws SVNClientException { return getLogMessages(arg0, arg1, arg2, true); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages(org.tigris.subversion.svnclientadapter.SVNUrl, java.lang.String[], org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean, boolean) */ public ISVNLogMessage[] getLogMessages(final SVNUrl url, final String[] paths, SVNRevision revStart, SVNRevision revEnd, boolean stopOnCopy, boolean fetchChangePath) throws SVNClientException { return this.getLogMessages(url, SVNRevision.HEAD, revStart, revEnd, stopOnCopy, fetchChangePath, 0, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public ISVNLogMessage[] getLogMessages(File path, SVNRevision revisionStart, SVNRevision revisionEnd, boolean fetchChangePath) throws SVNClientException { return this.getLogMessages(path, SVNRevision.HEAD, revisionStart, revisionEnd, false, fetchChangePath, 0, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean, boolean) */ public ISVNLogMessage[] getLogMessages(File path, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath) throws SVNClientException { return this.getLogMessages(path, SVNRevision.HEAD, revisionStart, revisionEnd, stopOnCopy, fetchChangePath, 0, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages(java.io.File, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean, boolean, long) */ public ISVNLogMessage[] getLogMessages(File path, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit) throws SVNClientException { //If the file is an uncommitted rename/move, we have to refer to original/source, not the new copy. ISVNInfo info = getInfoFromWorkingCopy(path); if ((SVNScheduleKind.ADD == info.getSchedule()) && (info.getCopyUrl() != null)) { return this.getLogMessages(info.getCopyUrl(), SVNRevision.HEAD, revisionStart, revisionEnd, stopOnCopy, fetchChangePath, limit, false); } else { return this.getLogMessages(path, SVNRevision.HEAD, revisionStart, revisionEnd, stopOnCopy, fetchChangePath, limit, false); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean) */ public ISVNLogMessage[] getLogMessages(SVNUrl url, SVNRevision revisionStart, SVNRevision revisionEnd, boolean fetchChangePath) throws SVNClientException { return this.getLogMessages(url, SVNRevision.HEAD, revisionStart, revisionEnd, false, fetchChangePath, 0, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getLogMessages(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNRevision, boolean, boolean, long) */ public ISVNLogMessage[] getLogMessages(SVNUrl url, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit) throws SVNClientException { return this.getLogMessages(url, pegRevision, revisionStart, revisionEnd, stopOnCopy, fetchChangePath, limit, false); } public ISVNLogMessage[] getLogMessages(File path, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions) throws SVNClientException { SVNLogMessageCallback worker = new SVNLogMessageCallback(); this.getLogMessages(path, pegRevision, revisionStart, revisionEnd, stopOnCopy, fetchChangePath, limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, worker); return worker.getLogMessages(); } public ISVNLogMessage[] getLogMessages(SVNUrl url, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions) throws SVNClientException { SVNLogMessageCallback worker = new SVNLogMessageCallback(); this.getLogMessages(url, pegRevision, revisionStart, revisionEnd, stopOnCopy, fetchChangePath, limit, includeMergedRevisions, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, worker); return worker.getLogMessages(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#setIgnoredPatterns(java.io.File, java.util.List) */ public void setIgnoredPatterns(File path, List patterns) throws SVNClientException { if (!path.isDirectory()) return; String separator = System.getProperty("line.separator"); StringBuffer value = new StringBuffer(); for (Iterator it = patterns.iterator(); it.hasNext();) { String pattern = (String)it.next(); value.append(pattern + separator); } propertySet(path, ISVNProperty.IGNORE, value.toString(), false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#addToIgnoredPatterns(java.io.File, java.lang.String) */ public void addToIgnoredPatterns(File path, String pattern) throws SVNClientException { List patterns = getIgnoredPatterns(path); if (patterns == null) // not a directory return; // verify that the pattern has not already been added for (Iterator it = patterns.iterator(); it.hasNext();) { if (((String)it.next()).equals(pattern)) return; // already added } patterns.add(pattern); setIgnoredPatterns(path,patterns); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#getKeywords(java.io.File) */ public SVNKeywords getKeywords(File path) throws SVNClientException { ISVNProperty prop = propertyGet(path, ISVNProperty.KEYWORDS); if (prop == null) return new SVNKeywords(); // value is a space-delimited list of the keywords names String value = prop.getValue(); return new SVNKeywords(value); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#addPasswordCallback(org.tigris.subversion.svnclientadapter.ISVNPromptUserPassword) */ public void addPasswordCallback(ISVNPromptUserPassword callback) { // Default implementation does nothing } public boolean statusReturnsRemoteInfo() { return false; } public long[] commitAcrossWC(File[] paths, String message, boolean recurse, boolean keepLocks, boolean Atomic) throws SVNClientException { notImplementedYet(); return null; } protected void notImplementedYet() throws SVNClientException { throw new SVNClientException("Not implemented yet"); } public boolean canCommitAcrossWC() { return false; } public void mkdir(SVNUrl url, boolean makeParents, String message) throws SVNClientException { if (makeParents) { SVNUrl parent = url.getParent(); if (parent != null) { ISVNInfo info = null; try { info = this.getInfo(parent); } catch (SVNClientException e) { } if (info == null) this.mkdir(parent, makeParents, message); } } this.mkdir(url, message); } /** * Answer whether running on Windows OS. * (Actual code extracted from org.apache.commons.lang.SystemUtils.IS_OS_WINDOWS) * (For such one simple method it does make sense to introduce dependency on whole commons-lang.jar) * @return true when the underlying */ public static boolean isOsWindows() { try { return System.getProperty("os.name").startsWith("Windows"); } catch (SecurityException ex) { // we are not allowed to look at this property return false; } } public ISVNInfo getInfo(SVNUrl url) throws SVNClientException { return getInfo(url, SVNRevision.HEAD, SVNRevision.HEAD); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#merge(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean, boolean, boolean) */ public void merge(SVNUrl path1, SVNRevision revision1, SVNUrl path2, SVNRevision revision2, File localPath, boolean force, boolean recurse, boolean dryRun) throws SVNClientException { merge(path1, revision1, path2, revision2, localPath, force, recurse, dryRun, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#merge(org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, org.tigris.subversion.svnclientadapter.SVNUrl, org.tigris.subversion.svnclientadapter.SVNRevision, java.io.File, boolean, boolean) */ public void merge(SVNUrl path1, SVNRevision revision1, SVNUrl path2, SVNRevision revision2, File localPath, boolean force, boolean recurse) throws SVNClientException { merge(path1, revision1, path2, revision2, localPath, force, recurse, false, false); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#propertyGet(org.tigris.subversion.svnclientadapter.SVNUrl, java.lang.String) */ public ISVNProperty propertyGet(SVNUrl url, String propertyName) throws SVNClientException { return propertyGet(url, SVNRevision.HEAD, SVNRevision.HEAD, propertyName); } public void diff(File[] paths, File outFile, boolean recurse) throws SVNClientException { FileOutputStream os = null; try { ArrayList tempFiles = new ArrayList(); for (int i = 0; i < paths.length; i++) { File tempFile = File.createTempFile("tempDiff", ".txt"); tempFile.deleteOnExit(); diff(paths[i], tempFile, recurse); tempFiles.add(tempFile); } os = new FileOutputStream(outFile); Iterator iter = tempFiles.iterator(); while (iter.hasNext()) { File tempFile = (File)iter.next(); FileInputStream is = new FileInputStream(tempFile); byte[] buffer = new byte[4096]; int bytes_read; while ((bytes_read = is.read(buffer)) != -1) os.write(buffer, 0, bytes_read); is.close(); } } catch (Exception e) { throw new SVNClientException(e); } finally { if (os != null) try {os.close();} catch (IOException e) {} } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNClientAdapter#createPatch(java.io.File[], java.io.File, java.io.File, boolean) */ public void createPatch(File[] paths, File relativeToPath, File outFile, boolean recurse) throws SVNClientException { File tmpFile; try { tmpFile = File.createTempFile("svn","patch"); tmpFile.deleteOnExit(); } catch (IOException e) { throw new SVNClientException(e); } this.diff(paths, tmpFile, recurse); stripPathsFromPatch(tmpFile, outFile, relativeToPath); } /** * Takes svn diff output and processes it to remove absolute paths and * convert them to relative paths which makes it easier to apply patch * * @param tmpFile - disk file containing diff output * @param outFile - file to store the updated diff output * @param relativeToPath - path to make file references relative to or null * for absolute paths * @throws SVNClientException */ private void stripPathsFromPatch(File tmpFile, File outFile, File relativeToPath) throws SVNClientException { String relativeStr = null; if (relativeToPath != null) { try { if (relativeToPath.isDirectory()) relativeStr = relativeToPath.getCanonicalPath(); else relativeStr = relativeToPath.getParentFile().getCanonicalPath(); } catch (IOException e1) { if (relativeToPath.isDirectory()) relativeStr = relativeToPath.getAbsolutePath(); else relativeStr = relativeToPath.getParentFile().getAbsolutePath(); } relativeStr += "/"; relativeStr = relativeStr.replace('\\', '/'); } FileInputStream fis = null; FileOutputStream fos = null; try { fis = new FileInputStream(tmpFile); fos = new FileOutputStream(outFile); byte b[] = new byte[fis.available()]; fis.read(b); if (relativeToPath != null) { byte o[] = new String(b).replaceAll(relativeStr, "").getBytes(); fos.write(o); } else { fos.write(b); } } catch (FileNotFoundException e) { throw new SVNClientException(e); } catch (IOException e) { throw new SVNClientException(e); } finally { try { if (fis != null) fis.close(); } catch (IOException e) { } try { if (fos != null) fos.close(); } catch (IOException e) { } } } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/Annotations.java000066400000000000000000000147531203563747500317130ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.List; /** * Generic implementation of {@link ISVNAnnotations} interface. * It's expected to be filled with annotation data by * {@link #addAnnotation(Annotations.Annotation)} method. * */ public class Annotations implements ISVNAnnotations { /** list of annotation records (lines) */ private List annotations = new ArrayList(); protected Annotation getAnnotation(int i) { if (i >= this.annotations.size()) { return null; } return (Annotation) this.annotations.get(i); } /** * Append the given annotation record the list of annotation * @param annotation */ public void addAnnotation(Annotation annotation) { this.annotations.add(annotation); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNAnnotations#getRevision(int) */ public long getRevision(int lineNumber) { Annotation annotation = getAnnotation(lineNumber); if (annotation == null) { return -1; } else { return annotation.getRevision(); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNAnnotations#getAuthor(int) */ public String getAuthor(int lineNumber) { Annotation annotation = getAnnotation(lineNumber); if (annotation == null) { return null; } else { return annotation.getAuthor(); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNAnnotations#getChanged(int) */ public Date getChanged(int lineNumber) { Annotation annotation = getAnnotation(lineNumber); if (annotation == null) { return null; } else { return annotation.getChanged(); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNAnnotations#getLine(int) */ public String getLine(int lineNumber) { Annotation annotation = getAnnotation(lineNumber); if (annotation == null) { return null; } else { return annotation.getLine(); } } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNAnnotations#getInputStream() */ public InputStream getInputStream() { return new AnnotateInputStream(this); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNAnnotations#numberOfLines() */ public int numberOfLines() { return this.annotations.size(); } /** * Class represeting one line of the annotations, i.e. an annotation record * */ public static class Annotation { private long revision; private String author; private Date changed; private String line; /** * Constructor * * @param revision * @param author * @param changed * @param line */ public Annotation(long revision, String author, Date changed, String line) { super(); if (revision == -1) { this.revision = 0; this.author = "No change"; this.changed = new Date(); } else { this.revision = revision; this.author = author; this.changed = changed; } this.line = line; } /** * @return Returns the author. */ public String getAuthor() { return author; } /** * @return Returns the changed. */ public Date getChanged() { return changed; } /** * @return Returns the line. */ public String getLine() { return line; } /** * @param line The line to set. */ public void setLine(String line) { this.line = line; } /** * @return Returns the revision. */ public long getRevision() { return revision; } /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { return getRevision() + ":" + getAuthor() + ":" + getLine(); } } protected static class AnnotateInputStream extends InputStream { private ISVNAnnotations annotations; private int currentLineNumber; private int currentPos; private String currentLine; private int available; /** * Constructor * @param annotations */ public AnnotateInputStream(ISVNAnnotations annotations) { this.annotations = annotations; initialize(); } private void initialize() { currentLine = annotations.getLine(0); currentLineNumber = 0; currentPos = 0; available = 0; int annotationsSize = annotations.numberOfLines(); for (int i = 0; i < annotationsSize;i++) { available += annotations.getLine(i).length(); if (i != annotationsSize-1) { available++; // +1 for \n } } } private void getNextLine() { currentLineNumber++; currentPos = 0; currentLine = annotations.getLine(currentLineNumber); } /* (non-Javadoc) * @see java.io.InputStream#read() */ public int read() throws IOException { if (currentLineNumber >= annotations.numberOfLines()) return -1; // end of stream if (currentPos > currentLine.length()) { getNextLine(); if (currentLineNumber >= annotations.numberOfLines()) return -1; // end of stream } int character; if (currentPos == currentLine.length()) character = '\n'; else character = currentLine.charAt(currentPos); currentPos++; available--; return character; } /* (non-Javadoc) * @see java.io.InputStream#available() */ public int available() throws IOException { return available; } /* (non-Javadoc) * @see java.io.InputStream#reset() */ public synchronized void reset() throws IOException { initialize(); } } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNAnnotations.java000066400000000000000000000043751203563747500324120ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.io.InputStream; import java.util.Date; /** * An interface defining the result of a call to svn blame/annotate. For each * line in the file, last modification data are returned. * */ public interface ISVNAnnotations { /** * Get the date of the last change for the given lineNumber * * @param lineNumber * @return date of last change */ public abstract Date getChanged(int lineNumber); /** * Get the revision of the last change for the given lineNumber * * @param lineNumber * @return the revision of last change */ public abstract long getRevision(int lineNumber); /** * Get the author of the last change for the given lineNumber * * @param lineNumber * @return the author of last change or null */ public abstract String getAuthor(int lineNumber); /** * Get the content (line itself) of the given lineNumber * * @param lineNumber * @return the line content */ public abstract String getLine(int lineNumber); /** * Get an input stream providing the content of the file being annotated. * * @return an inputstream of the content of the file */ public abstract InputStream getInputStream(); /** * Get the number of annotated lines * * @return number of lines of file being annotated */ public abstract int numberOfLines(); }svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNClientAdapter.java000066400000000000000000001747241203563747500326420ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.List; /** * High level API for Subversion * */ public interface ISVNClientAdapter { /** constant identifying the "bdb" repository type */ public final static String REPOSITORY_FSTYPE_BDB = "bdb"; /** constant identifying the "fsfs" repository type */ public final static String REPOSITORY_FSTYPE_FSFS = "fsfs"; public final static String[] DEFAULT_LOG_PROPERTIES = new String[] {"svn:author", "svn:date", "svn:log"}; /** * Returns whether the client adapter implementation is threadsafe */ public abstract boolean isThreadsafe(); /** * Add a notification listener * @param listener */ public abstract void addNotifyListener(ISVNNotifyListener listener); /** * Remove a notification listener * @param listener */ public abstract void removeNotifyListener(ISVNNotifyListener listener); /** * @return the notification handler */ public abstract SVNNotificationHandler getNotificationHandler(); /** * Sets the username. * @param username */ public abstract void setUsername(String username); /** * Sets the password. * @param password */ public abstract void setPassword(String password); /** * Add a callback for prompting for username, password SSL etc... * @param callback */ public abstract void addPasswordCallback(ISVNPromptUserPassword callback); /** * Add a callback for resolving conflicts during up/sw/merge * @param callback */ public abstract void addConflictResolutionCallback(ISVNConflictResolver callback); /** * Set a progress listener * @param progressListener */ public abstract void setProgressListener(ISVNProgressListener progressListener); /** * Adds a file (or directory) to the repository. * @param file * @throws SVNClientException */ public abstract void addFile(File file) throws SVNClientException; /** * Adds a directory to the repository. * @param dir * @param recurse * @throws SVNClientException */ public abstract void addDirectory(File dir, boolean recurse) throws SVNClientException; /** * Adds a directory to the repository. * @param dir * @param recurse * @param force * @throws SVNClientException */ public abstract void addDirectory(File dir, boolean recurse, boolean force) throws SVNClientException; /** * Executes a revision checkout. * @param moduleName name of the module to checkout. * @param destPath destination directory for checkout. * @param revision the revision number to checkout. If the number is -1 * then it will checkout the latest revision. * @param recurse whether you want it to checkout files recursively. * @exception SVNClientException */ public abstract void checkout( SVNUrl moduleName, File destPath, SVNRevision revision, boolean recurse) throws SVNClientException; /** * Executes a revision checkout. * @param moduleName name of the module to checkout. * @param destPath destination directory for checkout. * @param revision the revision number to checkout. If the number is -1 * then it will checkout the latest revision. * @param depth how deep to checkout files recursively. * @param ignoreExternals if externals are ignored during checkout. * @param force allow unversioned paths that obstruct adds. * @exception SVNClientException */ public abstract void checkout( SVNUrl moduleName, File destPath, SVNRevision revision, int depth, boolean ignoreExternals, boolean force) throws SVNClientException; /** * Commits changes to the repository. This usually requires * authentication, see Auth. * @return Returns a long representing the revision. It returns a * -1 if the revision number is invalid. * @param paths files to commit. * @param message log message. * @param recurse whether the operation should be done recursively. * @exception SVNClientException */ public abstract long commit(File[] paths, String message, boolean recurse) throws SVNClientException; /** * Commits changes to the repository. This usually requires * authentication, see Auth. * @return Returns a long representing the revision. It returns a * -1 if the revision number is invalid. * @param paths files to commit. * @param message log message. * @param recurse whether the operation should be done recursively. * @param keepLocks * @exception SVNClientException */ public abstract long commit(File[] paths, String message, boolean recurse, boolean keepLocks) throws SVNClientException; /** * Commits changes to the repository. This usually requires * authentication, see Auth. * * This differs from the normal commit method in that it can accept paths from * more than one working copy. * * @return Returns an array of longs representing the revisions. It returns a * -1 if the revision number is invalid. * @param paths files to commit. * @param message log message. * @param recurse whether the operation should be done recursively. * @param keepLocks whether to keep locks on files that are committed. * @param atomic whether to attempt to perform the commit from multiple * working copies atomically. Files from the same repository will be * processed with one commit operation. If files span multiple repositories * they will be processed in multiple commits. * When atomic is false, you will get one commit per WC. * @exception SVNClientException */ public abstract long[] commitAcrossWC(File[] paths, String message, boolean recurse, boolean keepLocks, boolean atomic) throws SVNClientException; public String getPostCommitError(); /** * List directory entries of a URL * @param url * @param revision * @param recurse * @return an array of ISVNDirEntries * @throws SVNClientException */ public abstract ISVNDirEntry[] getList( SVNUrl url, SVNRevision revision, boolean recurse) throws SVNClientException; /** * List directory entries of a URL * @param url * @param revision * @param pegRevision * @param recurse * @return an array of ISVNDirEntries * @throws SVNClientException */ public abstract ISVNDirEntry[] getList( SVNUrl url, SVNRevision revision, SVNRevision pegRevision, boolean recurse) throws SVNClientException; /** * List directory entries of a URL with lock information * @param url * @param revision * @param pegRevision * @param recurse * @return an array of ISVNDirEntries * @throws SVNClientException */ public abstract ISVNDirEntryWithLock[] getListWithLocks( SVNUrl url, SVNRevision revision, SVNRevision pegRevision, boolean recurse) throws SVNClientException; /** * List directory entries of a directory * @param path * @param revision * @param recurse * @return an array of ISVNDirEntries * @throws SVNClientException */ public ISVNDirEntry[] getList(File path, SVNRevision revision, boolean recurse) throws SVNClientException; /** * List directory entries of a directory * @param path * @param revision * @param pegRevision * @param recurse * @return an array of ISVNDirEntries * @throws SVNClientException */ public ISVNDirEntry[] getList(File path, SVNRevision revision, SVNRevision pegRevision, boolean recurse) throws SVNClientException; /** * get the dirEntry for the given url * @param url * @param revision * @return an ISVNDirEntry * @throws SVNClientException */ public ISVNDirEntry getDirEntry(SVNUrl url, SVNRevision revision) throws SVNClientException; /** * get the dirEntry for the given directory * @param path * @param revision * @return an ISVNDirEntry * @throws SVNClientException */ public ISVNDirEntry getDirEntry(File path, SVNRevision revision) throws SVNClientException; /** * Returns the status of a single file in the path. * * @param path File to gather status. * @return a Status * @throws SVNClientException */ public abstract ISVNStatus getSingleStatus(File path) throws SVNClientException; /** * Returns the status of given resources * @param path * @return the status of given resources * @throws SVNClientException */ public abstract ISVNStatus[] getStatus(File[] path) throws SVNClientException; /** * Returns the status of path and its children. * If descend is true, recurse fully, else do only immediate children. * If getAll is set, retrieve all entries; otherwise, retrieve only * "interesting" entries (local mods and/or out-of-date). * * @param path File to gather status. * @param descend get recursive status information * @param getAll get status information for all files * @return a Status * @throws SVNClientException */ public abstract ISVNStatus[] getStatus(File path, boolean descend, boolean getAll) throws SVNClientException; /** * Returns the status of path and its children. * If descend is true, recurse fully, else do only immediate children. * If getAll is set, retrieve all entries; otherwise, retrieve only * "interesting" entries (local mods and/or out-of-date). Use the * contactServer option to get server change information. * * @param path File to gather status. * @param descend get recursive status information * @param getAll get status information for all files * @param contactServer contact server to get remote changes * @return a Status * @throws SVNClientException */ public abstract ISVNStatus[] getStatus(File path, boolean descend, boolean getAll, boolean contactServer) throws SVNClientException; /** * Returns the status of path and its children. * If descend is true, recurse fully, else do only immediate children. * If getAll is set, retrieve all entries; otherwise, retrieve only * "interesting" entries (local mods and/or out-of-date). Use the * contactServer option to get server change information. * * @param path File to gather status. * @param descend get recursive status information * @param getAll get status information for all files * @param contactServer contact server to get remote changes * @param ignoreExternals if externals are ignored during status * @return a Status * @throws SVNClientException */ public abstract ISVNStatus[] getStatus(File path, boolean descend, boolean getAll, boolean contactServer, boolean ignoreExternals) throws SVNClientException; /** * Returns the status of path and its children. * If descend is true, recurse fully, else do only immediate children. * If getAll is set, retrieve all entries; otherwise, retrieve only * "interesting" entries (local mods and/or out-of-date). Use the * contactServer option to get server change information. * * @param path File to gather status. * @param descend get recursive status information * @param getAll get status information for all files * @param contactServer contact server to get remote changes * @param ignoreExternals if externals are ignored during status * @param callback callback to collect statuses * @return a Status * @throws SVNClientException */ public abstract ISVNStatus[] getStatus(File path, boolean descend, boolean getAll, boolean contactServer, boolean ignoreExternals, ISVNStatusCallback callback) throws SVNClientException; /** * copy and schedule for addition (with history) * @param srcPath * @param destPath * @throws SVNClientException */ public abstract void copy(File srcPath, File destPath) throws SVNClientException; /** * immediately commit a copy of WC to URL * @param srcPath * @param destUrl * @param message * @throws SVNClientException */ public abstract void copy(File srcPath, SVNUrl destUrl, String message) throws SVNClientException; /** * immediately commit a copy of WC to URL * @param srcPaths * @param destUrl * @param message * @param copyAsChild * @param makeParents * @throws SVNClientException */ public abstract void copy(File[] srcPaths, SVNUrl destUrl, String message, boolean copyAsChild, boolean makeParents) throws SVNClientException; /** * check out URL into WC, schedule for addition * @param srcUrl * @param destPath * @param revision * @throws SVNClientException */ public abstract void copy(SVNUrl srcUrl, File destPath, SVNRevision revision) throws SVNClientException; /** * check out URL into WC, schedule for addition * @param srcUrl * @param destPath * @param revision * @param boolean * @param boolean * @throws SVNClientException */ public abstract void copy(SVNUrl srcUrl, File destPath, SVNRevision revision, boolean copyAsChild, boolean makeParents) throws SVNClientException; /** * check out URL into WC, schedule for addition * @param srcUrl * @param destPath * @param revision * @param pegRevision * @param boolean * @param boolean * @throws SVNClientException */ public abstract void copy(SVNUrl srcUrl, File destPath, SVNRevision revision, SVNRevision pegRevision, boolean copyAsChild, boolean makeParents) throws SVNClientException; /** * complete server-side copy; used to branch & tag * @param srcUrl * @param destUrl * @param message * @param revision * @throws SVNClientException */ public abstract void copy( SVNUrl srcUrl, SVNUrl destUrl, String message, SVNRevision revision) throws SVNClientException; /** * complete server-side copy with option to create intermediate folders; used to branch & tag * @param srcUrl * @param destUrl * @param message * @param revision * @param make parents * @throws SVNClientException */ public abstract void copy( SVNUrl srcUrl, SVNUrl destUrl, String message, SVNRevision revision, boolean makeParents) throws SVNClientException; /** * complete server-side copy with option to create intermediate folders; used to branch & tag * @param srcUrl * @param destUrl * @param message * @param revision * @param copyAsChild * @param make parents * @throws SVNClientException */ public abstract void copy( SVNUrl[] srcUrls, SVNUrl destUrl, String message, SVNRevision revision, boolean copyAsChild, boolean makeParents) throws SVNClientException; /** * item is deleted from the repository via an immediate commit. * @param url * @param message * @throws SVNClientException */ public abstract void remove(SVNUrl url[], String message) throws SVNClientException; /** * the item is scheduled for deletion upon the next commit. * Files, and directories that have not been committed, are immediately * removed from the working copy. The command will not remove TARGETs * that are, or contain, unversioned or modified items; * use the force option to override this behaviour. * @param file * @param force * @throws SVNClientException */ public abstract void remove(File file[], boolean force) throws SVNClientException; /** * Exports a clean directory tree from the repository specified by * srcUrl, at revision revision * @param srcUrl * @param destPath * @param revision * @param force * @throws SVNClientException */ public abstract void doExport( SVNUrl srcUrl, File destPath, SVNRevision revision, boolean force) throws SVNClientException; /** * Exports a clean directory tree from the working copy specified by * PATH1 into PATH2. all local changes will be preserved, but files * not under revision control will not be copied. * @param srcPath * @param destPath * @param force * @throws SVNClientException */ public abstract void doExport(File srcPath, File destPath, boolean force) throws SVNClientException; /** * Import file or directory PATH into repository directory URL at head * @param path * @param url * @param message * @param recurse * @throws SVNClientException */ public abstract void doImport( File path, SVNUrl url, String message, boolean recurse) throws SVNClientException; /** * Creates a directory directly in a repository * @param url * @param message * @throws SVNClientException */ public abstract void mkdir(SVNUrl url, String message) throws SVNClientException; /** * Creates a directory directly in a repository * @param url * @param makeParents * @param message * @throws SVNClientException */ public abstract void mkdir(SVNUrl url, boolean makeParents, String message) throws SVNClientException; /** * creates a directory on disk and schedules it for addition. * @param file * @throws SVNClientException */ public abstract void mkdir(File file) throws SVNClientException; /** * Moves or renames a file. * @param srcPath * @param destPath * @param force * @throws SVNClientException */ public abstract void move(File srcPath, File destPath, boolean force) throws SVNClientException; /** * Moves or renames a file. * @param srcUrl * @param destUrl * @param message * @param revision * @throws SVNClientException */ public abstract void move( SVNUrl srcUrl, SVNUrl destUrl, String message, SVNRevision revision) throws SVNClientException; /** * Update a file or a directory * @param path * @param revision * @param recurse * @return Returns a long representing the revision. It returns a * -1 if the revision number is invalid. * @throws SVNClientException */ public abstract long update(File path, SVNRevision revision, boolean recurse) throws SVNClientException; /** * Update a file or a directory * @param path * @param revision * @param depth * @param setDepth * @param ignoreExternals * @param force * @return Returns a long representing the revision. It returns a * -1 if the revision number is invalid. * @throws SVNClientException */ public abstract long update(File path, SVNRevision revision, int depth, boolean setDepth, boolean ignoreExternals, boolean force) throws SVNClientException; /** * Updates the directories or files from repository * @param path array of target files. * @param revision the revision number to update. * @param recurse recursively update. * @param ignoreExternals if externals are ignored during update * @return Returns an array of longs representing the revision. It returns a * -1 if the revision number is invalid. * @throws SVNClientException * @since 1.2 */ public abstract long[] update( File[] path, SVNRevision revision, boolean recurse, boolean ignoreExternals) throws SVNClientException; /** * Updates the directories or files from repository * @param path array of target files. * @param revision the revision number to update. * @param depth the depth to recursively update. * @param setDepth change working copy to specified depth * @param ignoreExternals if externals are ignored during update. * @param force allow unversioned paths that obstruct adds. * @return Returns an array of longs representing the revision. It returns a * -1 if the revision number is invalid. * @throws SVNClientException */ public abstract long[] update( File[] path, SVNRevision revision, int depth, boolean setDepth, boolean ignoreExternals, boolean force) throws SVNClientException; /** * Restore pristine working copy file (undo all local edits) * @param path * @param recurse * @throws SVNClientException */ public abstract void revert(File path, boolean recurse) throws SVNClientException; /** * Get the log messages for a set of revision(s) * @param url * @param revisionStart * @param revisionEnd * @return The list of log messages. * @throws SVNClientException */ public abstract ISVNLogMessage[] getLogMessages( SVNUrl url, SVNRevision revisionStart, SVNRevision revisionEnd) throws SVNClientException; /** * Get the log messages for a set of revision(s) * @param url * @param revisionStart * @param revisionEnd * @param fetchChangePath Whether or not to interogate the * repository for the verbose log information containing the list * of paths touched by the delta specified by * revisionStart and revisionEnd. * Setting this to false results in a more performant * and memory efficient operation. * @return The list of log messages. * @throws SVNClientException */ public abstract ISVNLogMessage[] getLogMessages( SVNUrl url, SVNRevision revisionStart, SVNRevision revisionEnd, boolean fetchChangePath) throws SVNClientException; /** * Get the log messages for a set paths and revision(s) * @param url * @param paths * @param revStart * @param revEnd * @param stopOnCopy * @param fetchChangePath * @return The list of log messages. * @throws SVNClientException */ public ISVNLogMessage[] getLogMessages(final SVNUrl url, final String [] paths, SVNRevision revStart, SVNRevision revEnd, boolean stopOnCopy, boolean fetchChangePath) throws SVNClientException; /** * Get the log messages for a set of revision(s) * @param path * @param revisionStart * @param revisionEnd * @return The list of log messages. * @throws SVNClientException */ public abstract ISVNLogMessage[] getLogMessages( File path, SVNRevision revisionStart, SVNRevision revisionEnd) throws SVNClientException; /** * Get the log messages for a set of revision(s) * @param path * @param revisionStart * @param revisionEnd * @param fetchChangePath Whether or not to interogate the * repository for the verbose log information containing the list * of paths touched by the delta specified by * revisionStart and revisionEnd. * Setting this to false results in a more performant * and memory efficient operation. * @return The list of log messages. * @throws SVNClientException */ public abstract ISVNLogMessage[] getLogMessages( File path, SVNRevision revisionStart, SVNRevision revisionEnd, boolean fetchChangePath) throws SVNClientException; /** * Retrieve the log messages for an item * @param path path or url to get the log message for. * @param revisionStart first revision to show * @param revisionEnd last revision to show * @param stopOnCopy do not continue on copy operations * @param fetchChangePath returns the paths of the changed items in the * returned objects * @return array of LogMessages * @throws SVNClientException */ public abstract ISVNLogMessage[] getLogMessages( File path, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath) throws SVNClientException; /** * Retrieve the log messages for an item * @param path path to get the log message for. * @param revisionStart first revision to show * @param revisionEnd last revision to show * @param stopOnCopy do not continue on copy operations * @param fetchChangePath returns the paths of the changed items in the * returned objects * @param limit limit the number of log messages (if 0 or less no * limit) * @return array of LogMessages * @throws SVNClientException */ public abstract ISVNLogMessage[] getLogMessages( File path, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit) throws SVNClientException; /** * Retrieve the log messages for an item * @param path path to get the log message for. * @param pegRevision peg revision for URL * @param revisionStart first revision to show * @param revisionEnd last revision to show * @param stopOnCopy do not continue on copy operations * @param fetchChangePath returns the paths of the changed items in the * returned objects * @param limit limit the number of log messages (if 0 or less no * limit) * @param includeMergedRevisions include revisions that were merged * @return array of LogMessages * @throws SVNClientException */ public abstract ISVNLogMessage[] getLogMessages( File path, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions) throws SVNClientException; /** * Retrieve the log messages for an item * @param url url to get the log message for. * @param pegRevision peg revision for URL * @param revisionStart first revision to show * @param revisionEnd last revision to show * @param stopOnCopy do not continue on copy operations * @param fetchChangePath returns the paths of the changed items in the * returned objects * @param limit limit the number of log messages (if 0 or less no * limit) * @return array of LogMessages * @throws SVNClientException */ public abstract ISVNLogMessage[] getLogMessages( SVNUrl url, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit) throws SVNClientException; /** * Retrieve the log messages for an item * @param url url to get the log message for. * @param pegRevision peg revision for URL * @param revisionStart first revision to show * @param revisionEnd last revision to show * @param stopOnCopy do not continue on copy operations * @param fetchChangePath returns the paths of the changed items in the * returned objects * @param limit limit the number of log messages (if 0 or less no * limit) * @param includeMergedRevisions include revisions that were merged * @return array of LogMessages * @throws SVNClientException */ public abstract ISVNLogMessage[] getLogMessages( SVNUrl url, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions) throws SVNClientException; /** * Retrieve the log messages for an item * @param path path to get the log message for. * @param pegRevision peg revision for URL * @param revisionStart first revision to show * @param revisionEnd last revision to show * @param stopOnCopy do not continue on copy operations * @param fetchChangePath returns the paths of the changed items in the * returned objects * @param limit limit the number of log messages (if 0 or less no * limit) * @param includeMergedRevisions include revisions that were merged * @param requestedProperties the revision properties to return for each entry * @param callback callback class to receive log messages * @throws SVNClientException */ public abstract void getLogMessages( File path, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions, String[] requestedProperties, ISVNLogMessageCallback callback) throws SVNClientException; /** * Retrieve the log messages for an item * @param url url to get the log message for. * @param pegRevision peg revision for URL * @param revisionStart first revision to show * @param revisionEnd last revision to show * @param stopOnCopy do not continue on copy operations * @param fetchChangePath returns the paths of the changed items in the * returned objects * @param limit limit the number of log messages (if 0 or less no * limit) * @param includeMergedRevisions include revisions that were merged * @param requestedProperties the revision properties to return for each entry * @param callback callback class to receive log messages * @throws SVNClientException */ public abstract void getLogMessages( SVNUrl url, SVNRevision pegRevision, SVNRevision revisionStart, SVNRevision revisionEnd, boolean stopOnCopy, boolean fetchChangePath, long limit, boolean includeMergedRevisions, String[] requestedProperties, ISVNLogMessageCallback callback) throws SVNClientException; /** * get the content of a file * @param url * @param revision * @param peg revision * @return the input stream with a content of the file * @throws SVNClientException */ public abstract InputStream getContent(SVNUrl url, SVNRevision revision, SVNRevision pegRevision) throws SVNClientException; /** * get the content of a file * @param url * @param revision * @return the input stream with a content of the file * @throws SVNClientException */ public abstract InputStream getContent(SVNUrl url, SVNRevision revision) throws SVNClientException; /** * get the content of a file * @param path * @param revision * @return the input stream with a content of the file * @throws SVNClientException */ public InputStream getContent(File path, SVNRevision revision) throws SVNClientException; /** * set a property * @param path * @param propertyName * @param propertyValue * @param recurse * @throws SVNClientException */ public abstract void propertySet( File path, String propertyName, String propertyValue, boolean recurse) throws SVNClientException; /** * set a property * @param url * @param baseRev * @param propertyName * @param propertyValue * @param recurse * @throws SVNClientException */ public abstract void propertySet( SVNUrl url, SVNRevision.Number baseRev, String propertyName, String propertyValue, String message) throws SVNClientException; /** * set a property using the content of a file * @param path * @param propertyName * @param propertyFile * @param recurse * @throws SVNClientException * @throws IOException */ public abstract void propertySet( File path, String propertyName, File propertyFile, boolean recurse) throws SVNClientException, IOException; /** * get a property or null if property is not found * @param path * @param propertyName * @return a property or null * @throws SVNClientException */ public abstract ISVNProperty propertyGet(File path, String propertyName) throws SVNClientException; /** * get a property or null if property is not found * @param url * @param propertyName * @return a property or null * @throws SVNClientException */ public abstract ISVNProperty propertyGet(SVNUrl url, String propertyName) throws SVNClientException; /** * get a property or null if property is not found * @param url * @param revision * @param peg * @param propertyName * @return a property or null * @throws SVNClientException */ public abstract ISVNProperty propertyGet(SVNUrl url, SVNRevision revision, SVNRevision peg, String propertyName) throws SVNClientException; /** * delete a property * @param path * @param propertyName * @param recurse * @throws SVNClientException */ public abstract void propertyDel( File path, String propertyName, boolean recurse) throws SVNClientException; /** * set the revision property for a given revision * @param path * @param revisionNo * @param propName * @param propertyData * @param force * @throws SVNClientException */ public abstract void setRevProperty(SVNUrl path, SVNRevision.Number revisionNo, String propName, String propertyData, boolean force) throws SVNClientException; /** * get a revision property for a given revision * @param path * @param revisionNo * @param propName * @throws SVNClientException */ public abstract String getRevProperty(SVNUrl path, SVNRevision.Number revisionNo, String propName) throws SVNClientException; /** * get the ignored patterns for the given directory * if path is not a directory, returns null * @param path * @return list of ignored patterns * @throws SVNClientException */ public abstract List getIgnoredPatterns(File path) throws SVNClientException; /** * add a pattern to svn:ignore property * @param path * @param pattern * @throws SVNClientException */ public abstract void addToIgnoredPatterns(File path, String pattern) throws SVNClientException; /** * set the ignored patterns for the given directory * @param path * @param patterns * @throws SVNClientException */ public abstract void setIgnoredPatterns(File path, List patterns) throws SVNClientException; /** * display the differences between two paths. * @param oldPath * @param oldPathRevision * @param newPath * @param newPathRevision * @param outFile * @param recurse * @throws SVNClientException */ public abstract void diff( File oldPath, SVNRevision oldPathRevision, File newPath, SVNRevision newPathRevision, File outFile, boolean recurse) throws SVNClientException; /** * display the differences between two paths. * @param oldPath * @param oldPathRevision * @param newPath * @param newPathRevision * @param outFile * @param recurse * @param ignoreAncestry * @param noDiffDeleted * @param force * @throws SVNClientException */ public abstract void diff( File oldPath, SVNRevision oldPathRevision, File newPath, SVNRevision newPathRevision, File outFile, boolean recurse, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws SVNClientException; /** * display the differences between two paths. * @param path * @param outFile * @param recurse * @throws SVNClientException */ public abstract void diff( File path, File outFile, boolean recurse) throws SVNClientException; /** * display the combined differences for an array of paths. * @param paths * @param outFile * @param recurse * @throws SVNClientException */ public abstract void diff( File[] paths, File outFile, boolean recurse) throws SVNClientException; /** * create a patch from local differences. * @param paths * @param relativeToPath - create patch relative to this location * @param outFile * @param recurse * @throws SVNClientException */ public abstract void createPatch( File[] paths, File relativeToPath, File outFile, boolean recurse) throws SVNClientException; /** * display the differences between two urls. * @param oldUrl * @param oldUrlRevision * @param newUrl * @param newUrlRevision * @param outFile * @param recurse * @throws SVNClientException */ public abstract void diff( SVNUrl oldUrl, SVNRevision oldUrlRevision, SVNUrl newUrl, SVNRevision newUrlRevision, File outFile, boolean recurse) throws SVNClientException; /** * display the differences between two urls. * @param oldUrl * @param oldUrlRevision * @param newUrl * @param newUrlRevision * @param outFile * @param recurse * @param ignoreAncestry * @param noDiffDeleted * @param force * @throws SVNClientException */ public abstract void diff( SVNUrl oldUrl, SVNRevision oldUrlRevision, SVNUrl newUrl, SVNRevision newUrlRevision, File outFile, boolean recurse, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws SVNClientException; /** * Display the differences between two paths. * @param target * @param pegRevision * @param startRevision * @param endRevision * @param outFile * @param depth * @param ignoreAncestry * @param noDiffDeleted * @param force * @throws SVNClientException */ public abstract void diff( SVNUrl target, SVNRevision pegRevision, SVNRevision startRevision, SVNRevision endRevision, File outFile, int depth, boolean ignoreAncestry, boolean noDiffDeleted, boolean force) throws SVNClientException; /** * Display the differences between two paths. * @param target * @param pegRevision * @param startRevision * @param endRevision * @param outFile * @param recurse * @throws SVNClientException */ public abstract void diff( SVNUrl target, SVNRevision pegRevision, SVNRevision startRevision, SVNRevision endRevision, File outFile, boolean recurse) throws SVNClientException; /** * display the differences between two urls. * @param url * @param oldUrlRevision * @param newUrlRevision * @param outFile * @param recurse * @throws SVNClientException */ public abstract void diff( SVNUrl url, SVNRevision oldUrlRevision, SVNRevision newUrlRevision, File outFile, boolean recurse) throws SVNClientException; /** * display the differences between WC and url. * @param path * @param url * @param urlRevision * @param outFile * @param recurse * @throws SVNClientException */ public abstract void diff( File path, SVNUrl url, SVNRevision urlRevision, File outFile, boolean recurse) throws SVNClientException; /** * returns the keywords used for substitution for the given resource * @param path * @return the keywords used for substitution * @throws SVNClientException */ public abstract SVNKeywords getKeywords(File path) throws SVNClientException; /** * set the keywords substitution for the given resource * @param path * @param keywords * @param recurse * @throws SVNClientException */ public abstract void setKeywords(File path, SVNKeywords keywords, boolean recurse) throws SVNClientException; /** * add some keyword to the keywords substitution list * @param path * @param keywords * @return keywords valid after this method call * @throws SVNClientException */ public abstract SVNKeywords addKeywords(File path, SVNKeywords keywords) throws SVNClientException; /** * remove some keywords to the keywords substitution list * @param path * @param keywords * @return keywords valid after this method call * @throws SVNClientException */ public SVNKeywords removeKeywords(File path, SVNKeywords keywords) throws SVNClientException; /** * Output the content of specified url with revision and * author information in-line. * @param url * @param revisionStart * @param revisionEnd * @return annotations for the given url * @throws SVNClientException */ public ISVNAnnotations annotate(SVNUrl url, SVNRevision revisionStart, SVNRevision revisionEnd) throws SVNClientException; /** * Output the content of specified file with revision and * author information in-line. * @param file * @param revisionStart * @param revisionEnd * @return annotations for the given file * @throws SVNClientException */ public ISVNAnnotations annotate(File file, SVNRevision revisionStart, SVNRevision revisionEnd) throws SVNClientException; /** * Output the content of specified url with revision and * author information in-line. * @param url * @param revisionStart * @param revisionEnd * @param pegRevision * @param ignoreMimeType * @param includeMergedRevisons * @return annotations for the given url * @throws SVNClientException */ public ISVNAnnotations annotate(SVNUrl url, SVNRevision revisionStart, SVNRevision revisionEnd, SVNRevision pegRevision, boolean ignoreMimeType, boolean includeMergedRevisions) throws SVNClientException; /** * Output the content of specified file with revision and * author information in-line. * @param file * @param revisionStart * @param revisionEnd * @param ignoreMimeType * @param includeMergedRevisons * @return annotations for the given file * @throws SVNClientException */ public ISVNAnnotations annotate(File file, SVNRevision revisionStart, SVNRevision revisionEnd, boolean ignoreMimeType, boolean includeMergedRevisions) throws SVNClientException; /** * Output the content of specified file with revision and * author information in-line. * @param file * @param revisionStart * @param revisionEnd * @param pegRevision; * @param ignoreMimeType * @param includeMergedRevisons * @return annotations for the given file * @throws SVNClientException */ public ISVNAnnotations annotate(File file, SVNRevision revisionStart, SVNRevision revisionEnd, SVNRevision pegRevision, boolean ignoreMimeType, boolean includeMergedRevisions) throws SVNClientException; /** * Get all the properties for the given file or dir * @param path * @return the properties for the given url * @throws SVNClientException */ public abstract ISVNProperty[] getProperties(File path) throws SVNClientException; /** * Get all the properties for the given file or dir * @param path * @param descend get properties recursively * @return the properties for the given url * @throws SVNClientException */ public abstract ISVNProperty[] getProperties(File path, boolean descend) throws SVNClientException; /** * Get all the properties for the given url * @param url * @param revision * @param peg * @param recurse * @return information about an URL. * @throws SVNClientException */ public abstract ISVNProperty[] getProperties(SVNUrl url, SVNRevision revision, SVNRevision peg, boolean recurse) throws SVNClientException; /** * Get all the properties for the given url * @param url * @param revision * @param peg * @return information about an URL. * @throws SVNClientException */ public abstract ISVNProperty[] getProperties(SVNUrl url, SVNRevision revision, SVNRevision peg) throws SVNClientException; /** * Get all the properties for the given url * @param url * @return the properties for the given url * @throws SVNClientException */ public abstract ISVNProperty[] getProperties(SVNUrl url) throws SVNClientException; /** * Get all the revision properties for the given url at a revision * @param url * @param revision * @return information about an URL. * @throws SVNClientException */ public abstract ISVNProperty[] getRevProperties(SVNUrl url, SVNRevision.Number revision) throws SVNClientException; /** * Remove 'conflicted' state on working copy files or directories * @param path * @throws SVNClientException */ public abstract void resolved(File path) throws SVNClientException; /** * Remove 'conflicted' state on working copy files or directories * @param path * @param result - choose resolve option - {@link ISVNConflictResolver.Choice} * @throws SVNClientException */ public abstract void resolve(File path, int result) throws SVNClientException; /** * Create a new, empty repository at path * * @param path * @param repositoryType either {@link ISVNClientAdapter#REPOSITORY_FSTYPE_BDB} or * {@link ISVNClientAdapter#REPOSITORY_FSTYPE_FSFS} or null (will use svnadmin default) * @throws SVNClientException */ public abstract void createRepository(File path, String repositoryType) throws SVNClientException; /** * Cancel the current operation * * @throws SVNClientException */ public void cancelOperation() throws SVNClientException; /** * Get information about a file or directory from working copy. * Uses info() call which does NOT contact the repository * @param file * @return information about a file or directory from working copy. * @throws SVNClientException */ public ISVNInfo getInfoFromWorkingCopy(File file) throws SVNClientException; /** * Get information about a file or directory. * Uses info2() call which contacts the repository * @param file * @return information about a file or directory. * @throws SVNClientException */ public ISVNInfo getInfo(File file) throws SVNClientException; /** * Get information about a file or directory. * Uses info2() call which contacts the repository * @param file * @param descend get recursive information * @return information about a file or directory. * @throws SVNClientException */ public ISVNInfo[] getInfo(File file, boolean descend) throws SVNClientException; /** * Get information about an URL. * Uses info2() call which contacts the repository * @param url * @return information about an URL. * @throws SVNClientException */ public ISVNInfo getInfo(SVNUrl url) throws SVNClientException; /** * Get information about an URL. * Uses info2() call which contacts the repository * @param url * @param revision * @param peg * @return information about an URL. * @throws SVNClientException */ public ISVNInfo getInfo(SVNUrl url, SVNRevision revision, SVNRevision peg) throws SVNClientException; /** * Update the working copy to mirror a new URL within the repository. * This behaviour is similar to 'svn update', and is the way to * move a working copy to a branch or tag within the same repository. * @param url * @param path * @param revision * @param recurse * @throws SVNClientException */ public void switchToUrl(File path, SVNUrl url, SVNRevision revision, boolean recurse) throws SVNClientException; /** * Update the working copy to mirror a new URL within the repository. * This behaviour is similar to 'svn update', and is the way to * move a working copy to a branch or tag within the same repository. * @param url * @param path * @param revision * @param depth * @param setDepth * @param ignoreExternals * @param force * @throws SVNClientException */ public void switchToUrl(File path, SVNUrl url, SVNRevision revision, int depth, boolean setDepth, boolean ignoreExternals, boolean force) throws SVNClientException; /** * Update the working copy to mirror a new URL within the repository. * This behaviour is similar to 'svn update', and is the way to * move a working copy to a branch or tag within the same repository. * @param url * @param path * @param revision * @param pegRevision * @param depth * @param setDepth * @param ignoreExternals * @param force * @throws SVNClientException */ public void switchToUrl(File path, SVNUrl url, SVNRevision revision, SVNRevision pegRevision, int depth, boolean setDepth, boolean ignoreExternals, boolean force) throws SVNClientException; /** * Update the working copy to mirror a new URL within the repository. * This behaviour is similar to 'svn update', and is the way to * move a working copy to a branch or tag within the same repository. * @param url * @param path * @param revision * @param pegRevision * @param depth * @param setDepth * @param ignoreExternals * @param force * @param ignoreAncestry * @throws SVNClientException */ public void switchToUrl(File path, SVNUrl url, SVNRevision revision, SVNRevision pegRevision, int depth, boolean setDepth, boolean ignoreExternals, boolean force, boolean ignoreAncestry) throws SVNClientException; /** * Set the configuration directory. * @param dir * @throws SVNClientException */ public void setConfigDirectory(File dir) throws SVNClientException; /** * Perform a clanup on the working copy. This will remove any stale transactions * @param dir * @throws SVNClientException */ public abstract void cleanup(File dir) throws SVNClientException; /** * Recursively upgrade a working copy to a new metadata storage format. * @param dir * @throws SVNClientException */ public abstract void upgrade(File dir) throws SVNClientException; /** * Merge changes from two paths into a new local path. * @param path1 first path or url * @param revision1 first revision * @param path2 second path or url * @param revision2 second revision * @param localPath target local path * @param force overwrite local changes * @param recurse traverse into subdirectories * @exception SVNClientException */ public abstract void merge(SVNUrl path1, SVNRevision revision1, SVNUrl path2, SVNRevision revision2, File localPath, boolean force, boolean recurse) throws SVNClientException; /** * Merge changes from two paths into a new local path. * @param path1 first path or url * @param revision1 first revision * @param path2 second path or url * @param revision2 second revision * @param localPath target local path * @param force overwrite local changes * @param recurse traverse into subdirectories * @param dryRun do not update working copy * @exception SVNClientException */ public abstract void merge(SVNUrl path1, SVNRevision revision1, SVNUrl path2, SVNRevision revision2, File localPath, boolean force, boolean recurse, boolean dryRun) throws SVNClientException; /** * Merge changes from two paths into a new local path. * @param path1 first path or url * @param revision1 first revision * @param path2 second path or url * @param revision2 second revision * @param localPath target local path * @param force overwrite local changes * @param recurse traverse into subdirectories * @param dryRun do not update working copy * @param ignoreAncestry ignore ancestry when calculating merges * @exception SVNClientException */ public abstract void merge(SVNUrl path1, SVNRevision revision1, SVNUrl path2, SVNRevision revision2, File localPath, boolean force, boolean recurse, boolean dryRun, boolean ignoreAncestry) throws SVNClientException; /** * Merge changes from two paths into a new local path. * @param path1 first path or url * @param revision1 first revision * @param path2 second path or url * @param revision2 second revision * @param localPath target local path * @param force overwrite local changes * @param int depth * @param dryRun do not update working copy * @param ignoreAncestry ignore ancestry when calculating merges * @param recordOnly just records mergeinfo, does not perform merge * @exception SVNClientException */ public abstract void merge(SVNUrl path1, SVNRevision revision1, SVNUrl path2, SVNRevision revision2, File localPath, boolean force, int depth, boolean dryRun, boolean ignoreAncestry, boolean recordOnly) throws SVNClientException; /** * Perform a reintegration merge of path into localPath. * localPath must be a single-revision, infinite depth, * pristine, unswitched working copy -- in other words, it must * reflect a single revision tree, the "target". The mergeinfo on * path must reflect that all of the target has been merged into it. * Then this behaves like a merge from the target's URL to the * localPath. * * The depth of the merge is always infinity. * @param path path or url * @param pegRevision revision to interpret path * @param localPath target local path * @param force THIS IS NOT CURRENTLY USED * @param dryRun do not update working copy * @exception SVNClientException */ public abstract void mergeReintegrate(SVNUrl path, SVNRevision pegRevision, File localPath, boolean force, boolean dryRun) throws SVNClientException; /** * Lock a working copy item * @param paths path of the items to lock * @param comment * @param force break an existing lock * @throws SVNClientException */ public abstract void lock(SVNUrl[] paths, String comment, boolean force) throws SVNClientException; /** * Unlock a working copy item * @param paths path of the items to unlock * @param force break an existing lock * @throws SVNClientException */ public abstract void unlock(SVNUrl[] paths, boolean force) throws SVNClientException; /** * Lock a working copy item * @param paths path of the items to lock * @param comment * @param force break an existing lock * @throws SVNClientException */ public abstract void lock(File[] paths, String comment, boolean force) throws SVNClientException; /** * Unlock a working copy item * @param paths path of the items to unlock * @param force break an existing lock * @throws SVNClientException */ public abstract void unlock(File[] paths, boolean force) throws SVNClientException; /** * Indicates whether a status call that contacts the * server includes the remote info in the status object * @return true when the client adapter implementation delivers remote info within status */ public abstract boolean statusReturnsRemoteInfo(); /** * Indicates whether the commitAcrossWC method is * supported in the adapter * @return true when the client adapter implementation supports commitAcrossWC */ public abstract boolean canCommitAcrossWC(); /** * Returns the name of the Subversion administrative * working copy directory. Typically will be ".svn". * @return the name of the Subversion administrative wc dir */ public abstract String getAdminDirectoryName(); /** * Returns whether the passed folder name is a Subversion * administrative working copy directory. Will always return * true if ".svn" is passed. Otherwise, will be based on the * Subversion runtime * @param name * @return true whether the folder is a Subversion administrative dir */ public abstract boolean isAdminDirectory(String name); /** * Rewrite the url's in the working copy * @param from old url * @param to new url * @param path working copy path * @param recurse recurse into subdirectories * @throws SVNClientException */ public abstract void relocate(String from, String to, String path, boolean recurse) throws SVNClientException; /** * Merge set of revisions into a new local path. * @param url url * @param pegRevision revision to interpret path * @param revisions revisions to merge (must be in the form N-1:M) * @param localPath target local path * @param force overwrite local changes * @param depth how deep to traverse into subdirectories * @param ignoreAncestry ignore if files are not related * @param dryRun do not change anything * @param recordOnly just records mergeinfo, does not perform merge * @throws SVNClientException */ public abstract void merge(SVNUrl url, SVNRevision pegRevision, SVNRevisionRange[] revisions, File localPath, boolean force, int depth, boolean ignoreAncestry, boolean dryRun, boolean recordOnly) throws SVNClientException; /** * Get merge info for path at revision. * @param path Local Path. * @param revision SVNRevision at which to get the merge info for * path. * @throws SVNClientException */ public abstract ISVNMergeInfo getMergeInfo(File path, SVNRevision revision) throws SVNClientException; /** * Get merge info for url at revision. * @param url URL. * @param revision SVNRevision at which to get the merge info for * path. * @throws SVNClientException */ public abstract ISVNMergeInfo getMergeInfo(SVNUrl url, SVNRevision revision) throws SVNClientException; /** * Retrieve either merged or eligible-to-be-merged revisions. * @param kind kind of revisions to receive * @param path target of merge * @param pegRevision peg rev for path * @param mergeSourceUrl the source of the merge * @param srcPegRevision peg rev for mergeSourceUrl * @param discoverChangedPaths return paths of changed items * @return array of log messages * @throws SVNClientException */ public abstract ISVNLogMessage[] getMergeinfoLog(int kind, File path, SVNRevision pegRevision, SVNUrl mergeSourceUrl, SVNRevision srcPegRevision, boolean discoverChangedPaths) throws SVNClientException; /** * Retrieve either merged or eligible-to-be-merged revisions. * @param kind kind of revisions to receive * @param url target of merge * @param pegRevision peg rev for path * @param mergeSourceUrl the source of the merge * @param srcPegRevision peg rev for mergeSourceUrl * @param discoverChangedPaths return paths of changed items * @return array of log messages * @throws SVNClientException */ public abstract ISVNLogMessage[] getMergeinfoLog(int kind, SVNUrl url, SVNRevision pegRevision, SVNUrl mergeSourceUrl, SVNRevision srcPegRevision, boolean discoverChangedPaths) throws SVNClientException; /** * Produce a diff summary which lists the items changed between * path and revision pairs. * * @param target1 URL. * @param revision1 Revision of target1. * @param target2 URL. * @param revision2 Revision of target2. * @param depth how deep to recurse. * @param ignoreAncestry Whether to ignore unrelated files during * comparison. False positives may potentially be reported if * this parameter false, since a file might have been * modified between two revisions, but still have the same * contents. * @return the list of differences * * @throws SVNClientException */ public abstract SVNDiffSummary[] diffSummarize(SVNUrl target1, SVNRevision revision1, SVNUrl target2, SVNRevision revision2, int depth, boolean ignoreAncestry) throws SVNClientException; /** * Produce a diff summary which lists the items changed between * path and revision pairs. * * @param target URL. * @param pegRevision Revision at which to interpret * target. If {@link RevisionKind#unspecified} or * null, behave identically to {@link * diffSummarize(String, Revision, String, Revision, boolean, * boolean, DiffSummaryReceiver)}, using path for * both of that method's targets. * @param startRevision Beginning of range for comparsion of * target. * @param endRevision End of range for comparsion of * target. * @param depth how deep to recurse. * @param ignoreAncestry Whether to ignore unrelated files during * comparison. False positives may potentially be reported if * this parameter false, since a file might have been * modified between two revisions, but still have the same * contents. * @return the list of differences * * @throws SVNClientException */ public abstract SVNDiffSummary[] diffSummarize(SVNUrl target, SVNRevision pegRevision, SVNRevision startRevision, SVNRevision endRevision, int depth, boolean ignoreAncestry) throws SVNClientException; public abstract SVNDiffSummary[] diffSummarize(File path, SVNUrl toUrl, SVNRevision toRevision, boolean recurse) throws SVNClientException; /** * Return an ordered list of suggested merge source URLs. * @param path The merge target path for which to suggest sources. * @return The list of URLs, empty if there are no suggestions. * @throws SVNClientException If an error occurs. */ public abstract String[] suggestMergeSources(File path) throws SVNClientException; /** * Return an ordered list of suggested merge source URLs. * @param url The merge target path for which to suggest sources. * @param peg The peg revision for the URL * @return The list of URLs, empty if there are no suggestions. * @throws SVNClientException If an error occurs. */ public abstract String[] suggestMergeSources(SVNUrl url, SVNRevision peg) throws SVNClientException; /** * release the native peer (should not depend on finalize) */ public abstract void dispose(); } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNConflictResolver.java000066400000000000000000000031021203563747500333630ustar00rootroot00000000000000package org.tigris.subversion.svnclientadapter; public interface ISVNConflictResolver { /** * The callback method invoked for each conflict during a * merge/update/switch operation. * * @param descrip A description of the conflict. * @return The result of any conflict resolution. * @throws SubversionException If an error occurs. */ public SVNConflictResult resolve(SVNConflictDescriptor descrip) throws SVNClientException; /** * From JavaHL */ public final class Choice { /** * User did nothing; conflict remains. */ public static final int postpone = 0; /** * User chooses the base file. */ public static final int chooseBase = 1; /** * User chooses the repository file. */ public static final int chooseTheirsFull = 2; /** * User chooses own version of file. */ public static final int chooseMineFull = 3; /** * Resolve the conflict by choosing the incoming (repository) * version of the object (for conflicted hunks only). */ public static final int chooseTheirs = 4; /** * Resolve the conflict by choosing own (local) version of the * object (for conflicted hunks only). */ public static final int chooseMine = 5; /** * Resolve the conflict by choosing the merged object * (potentially manually edited). */ public static final int chooseMerged = 6; } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNDirEntry.java000066400000000000000000000034331203563747500316470ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.util.Date; /** * An interface describing subversion directory entry. * (E.g. a record returned by call to svn list) * * @author Cédric Chabanois */ public interface ISVNDirEntry { /** * @return the pathname of the entry */ String getPath(); /** * @return the date of the last change */ Date getLastChangedDate(); /** * @return the revision number of the last change */ SVNRevision.Number getLastChangedRevision(); /** * @return true if the item has properties managed by subversion */ boolean getHasProps(); /** * @return the name of the author of the last change */ String getLastCommitAuthor(); /** * @return the kind of the node (directory or file) */ SVNNodeKind getNodeKind(); /** * @return length of file text, or 0 for directories */ long getSize(); } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNDirEntryWithLock.java000066400000000000000000000002401203563747500333050ustar00rootroot00000000000000package org.tigris.subversion.svnclientadapter; public interface ISVNDirEntryWithLock { public ISVNDirEntry getDirEntry(); public ISVNLock getLock(); } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNInfo.java000066400000000000000000000073741203563747500310120ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.io.File; import java.util.Date; /** * Give information about one subversion item (file or directory) in the * working copy */ public interface ISVNInfo { /** * file on which we get info * @return file */ public File getFile(); /** * Retrieves the url of the item * @return url of the item */ public SVNUrl getUrl(); /** * Retrieves the url (string) of the item * @return url of the item */ public String getUrlString(); /** * Retrieves the uuid of the repository * @return uuid of the repository */ public String getUuid(); /** * Retrieves the url of the repository * @return url of the repository */ public SVNUrl getRepository(); /** * Retrieves the schedule of the next commit * @return schedule of the next commit */ public SVNScheduleKind getSchedule(); /** * Retrieves the nodeKind * @return nodeKind */ public SVNNodeKind getNodeKind(); /** * Retrieves the author of the last commit * @return author of the last commit */ public String getLastCommitAuthor(); /** * Retrieves the last revision the item was updated to * @return last revision the item was updated to */ public SVNRevision.Number getRevision(); /** * Retrieves the revision of the last commit * @return the revision of the last commit */ public SVNRevision.Number getLastChangedRevision(); /** * Retrieves the date of the last commit * @return the date of the last commit */ public Date getLastChangedDate(); /** * Retrieves the last date the text content was changed * @return last date the text content was changed */ public Date getLastDateTextUpdate(); /** * Retrieves the last date the properties were changed * @return last date the properties were changed */ public Date getLastDatePropsUpdate(); /** * Retrieve if the item was copied * @return the item was copied */ public boolean isCopied(); /** * Retrieves the copy source revision * @return copy source revision */ public SVNRevision.Number getCopyRev(); /** * Retrieves the copy source url * @return copy source url */ public SVNUrl getCopyUrl(); /** * Retrieves the lock owner (may be null) * @return lock owner */ public String getLockOwner(); /** * Retrieves the lock creation date (may be null) * @return lock creation date */ public Date getLockCreationDate(); /** * Retrieves the lock comment (may be null) * @return lock comment */ public String getLockComment(); /** * Retrieves the depth of the item * @return depth */ public int getDepth(); } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNLock.java000066400000000000000000000031731203563747500310000ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.util.Date; /** * An interface describing a lock as return by the lock operation. * */ public interface ISVNLock { /** * @return the owner of the lock */ public String getOwner(); /** * @return the path of the locked item */ public String getPath(); /** * @return the token provided during the lock operation */ public String getToken(); /** * @return the comment provided during the lock operation */ public String getComment(); /** * @return the date the lock was created */ public Date getCreationDate(); /** * @return the date when the lock will expire */ public Date getExpirationDate(); } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNLogMessage.java000066400000000000000000000062611203563747500321370ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.util.Date; /** * An interface defining a single subversion commit with log message, * author, date and paths changed within the commit. * * @author Philip Schatz schatzp@purdue.edu */ public interface ISVNLogMessage { public final String AUTHOR = "svn:author"; public final String MESSAGE = "svn:log"; public final String DATE = "svn:date"; public final String TIME_MICROS = "svnclientadapter:timemicros"; /** * Returns the revision number * @return the revision number */ public abstract SVNRevision.Number getRevision(); /** * Returns the author of the commit * @return the author of the commit */ public abstract String getAuthor(); /** * Returns the time of the commit * @return the time of the commit measured in the number of * microseconds since 00:00:00 January 1, 1970 UTC */ public abstract long getTimeMicros(); /** * Returns the time of the commit * @return the time of the commit measured in the number of * milliseconds since 00:00:00 January 1, 1970 UTC */ public abstract long getTimeMillis(); /** * Returns the date of the commit * @return the date of the commit */ public abstract Date getDate(); /** * Return the log message text * @return the log message text */ public abstract String getMessage(); /** * Returns the changes items by this commit * @return the changes items by this commit */ public abstract ISVNLogMessageChangePath[] getChangedPaths(); /** * Returns the number of child log messages. When merge-sensitive * log option was specified. * @return the number of revisions merged by this commit */ public abstract long getNumberOfChildren(); /** * Returns the child log messages. When merge-sensitive * log option was specified. * @return the revisions merged by this commit */ public abstract ISVNLogMessage[] getChildMessages(); /** * Add a child logMessage to an existing message */ public abstract void addChild(ISVNLogMessage msg); /** * Does this logMessage have any children */ public abstract boolean hasChildren(); }svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNLogMessageCallback.java000066400000000000000000000036071203563747500335550ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2008 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; /** * This interface is used to receive every log message for the log * messages found by a ISVNClientAdapter.getLogMessages call. * * All log messages are returned in a list, which is terminated by an * invocation of this callback with the message set to NULL. * * If the includeMergedRevisions parameter to ISVNClientAdapter.getLogMessages * is true, then messages returned through this callback may have the * hasChildren parameter set. This parameter indicates that a separate list, * which includes messages for merged revisions, will immediately follow. * This list is also terminated with NULL, after which the * previous log message list continues. * * Log message lists may be nested arbitrarily deep, depending on the ancestry * of the requested paths. */ public interface ISVNLogMessageCallback { /** * The method will be called for every log message. * * @param message the log message */ public void singleMessage(ISVNLogMessage message); } ISVNLogMessageChangePath.java000066400000000000000000000032101203563747500337720ustar00rootroot00000000000000svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; /** * An interface defining a change path for a log message * */ public interface ISVNLogMessageChangePath { /** * Retrieve the path to the commited item * @return the path to the commited item */ public abstract String getPath(); /** * Retrieve the copy source revision if any or null otherwise * @return the copy source revision (if any) */ public abstract SVNRevision.Number getCopySrcRevision(); /** * Retrieve the copy source path (if any) or null otherwise * @return the copy source path (if any) */ public abstract String getCopySrcPath(); /** * Retrieve action performed. * I.e. 'A'dd, 'D'elete, 'R'eplace, 'M'odify * * @return action performed */ public abstract char getAction(); }svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNMergeInfo.java000066400000000000000000000047371203563747500317720ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2007 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; public interface ISVNMergeInfo { /** * Add one or more SVNRevisionRange objects to merge info. If path is already * stored, the list of revisions is replaced. * @param path The merge source path. * @param range List of SVNRevisionRange objects to add. */ public void addRevisions(String path, SVNRevisionRange[] range); /** * Add a revision range to the merged revisions for a path. If * the path already has associated revision ranges, add the * revision range to the existing list. * @param path The merge source path. * @param range The revision range to add. */ public void addRevisionRange(String path, SVNRevisionRange range); /** * Get the merge source paths. * @return The merge source paths. */ public String[] getPaths(); /** * Get the revision ranges for the specified path. * @param path The merge source path. * @return List of SVNRevisionRange objects, or null. */ public SVNRevisionRange[] getRevisions(String path); /** * Get the RevisionRange objects for the specified path * @param path The merge source path. * @return Array of RevisionRange objects, or null. */ public SVNRevisionRange[] getRevisionRange(String path); /** * Parse the svn:mergeinfo property to populate the * merge source paths and revision ranges of this instance. * @param mergeInfo svn:mergeinfo property value. */ public void loadFromMergeInfoProperty(String mergeInfo); } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNMergeinfoLogKind.java000066400000000000000000000003561203563747500332730ustar00rootroot00000000000000package org.tigris.subversion.svnclientadapter; public interface ISVNMergeinfoLogKind { /** does not exist */ public static final int eligible = 0; /** exists, but uninteresting */ public static final int merged = 1; } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNNotifyListener.java000066400000000000000000000101221203563747500330560ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.io.File; /** * A callback interface used for receiving notifications of a progress of * a subversion command invocation. * * @author Cédric Chabanois cchabanois@ifrance.com */ public interface ISVNNotifyListener { /** * An enumeration class representing the supported subversion commands/actions. */ public static final class Command { public static final int UNDEFINED = 0; public static final int ADD = 1; public static final int CHECKOUT = 2; public static final int COMMIT = 3; public static final int UPDATE = 4; public static final int MOVE = 5; public static final int COPY = 6; public static final int REMOVE = 7; public static final int EXPORT = 8; public static final int IMPORT = 9; public static final int MKDIR = 10; public static final int LS = 11; public static final int STATUS = 12; public static final int LOG = 13; public static final int PROPSET = 14; public static final int PROPDEL = 15; public static final int REVERT = 16; public static final int DIFF = 17; public static final int CAT = 18; public static final int INFO = 19; public static final int PROPGET = 20; public static final int PROPLIST = 21; public static final int RESOLVED = 22; public static final int CREATE_REPOSITORY = 23; public static final int CLEANUP = 24; public static final int ANNOTATE = 25; public static final int SWITCH = 26; public static final int MERGE = 27; public static final int LOCK = 28; public static final int UNLOCK = 29; public static final int RELOCATE = 30; public static final int RESOLVE = 31; public static final int MERGEINFO = 32; public static final int UPGRADE = 33; } /** * Tell the callback the command to be executed * @param command one of {@link Command}.* constants */ public void setCommand(int command); /** * called at the beginning of the command * @param commandLine */ public void logCommandLine(String commandLine); /** * called multiple times during the execution of a command * @param message */ public void logMessage(String message); /** * called when an error happen during a command * @param message */ public void logError(String message); /** * Called when a command has completed to report * that the command completed against the specified * revision. * * @param revision * @param path - path to folder which revision is reported (either root, or some of svn:externals) */ public void logRevision(long revision, String path); /** * called when a command has completed * @param message */ public void logCompleted(String message); /** * called when a subversion action happen on a file (add, delete, update ...) * @param path the canonical path of the file or dir * @param kind file or dir or unknown */ public void onNotify(File path, SVNNodeKind kind); } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNProgressListener.java000066400000000000000000000002271203563747500334170ustar00rootroot00000000000000package org.tigris.subversion.svnclientadapter; public interface ISVNProgressListener { public void onProgress(SVNProgressEvent progressEvent); } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNPromptUserPassword.java000066400000000000000000000124441203563747500337540ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; /** * An interface describing a callback used during authentification. * */ public interface ISVNPromptUserPassword { /** reject the connection to the server */ public static final int Reject = 0; /** accept the connection to the server one time. */ public static final int AcceptTemporary = 1; /** accept the connection to the server forever */ public static final int AcceptPermanently = 2; /** * ask the user a yes/no question * @param realm for which server realm this information is requested. * @param question question to be asked * @param yesIsDefault if yes should be the default * @return the answer */ public boolean askYesNo(String realm, String question, boolean yesIsDefault); /** * retrieve the username entered during the prompt call * @return the username */ public String getUsername(); /** * retrieve the password entered during the prompt call * @return the password */ public String getPassword(); /** * If there are problems with the certifcate of the SSL-server, this * callback will be used to deside if the connection will be used. * @param info the probblems with the certificate. * @param allowPermanently if AcceptPermantly is a legal answer * @return one of Reject/AcceptTemporary/AcceptPermanently */ public int askTrustSSLServer(String info, boolean allowPermanently); /** * Request the password to be used from the user. * the save data check box status will be queried by userAllowedSave * @param realm realm for the username * @param username username in the realm * @param maySave should a save data check box be enabled. * @return password as entered or null if canceled. */ public boolean prompt(String realm, String username, boolean maySave); /** * Request the username to be used for SVN operation * the save data check box status will be queried by userAllowedSave * @param realm realm for the username * @param username username in the realm * @param maySave should a save data check box be enabled. * @return password as entered or null if canceled. */ public boolean promptUser(String realm, String username, boolean maySave); /** * Ask the user a question about authentification * the save data check box status will be queried by userAllowedSave * @param realm real of the question * @param question text of the question * @param showAnswer flag if the answer should be displayed * @param maySave should a save data check box be enabled. * @return answer as entered or null if canceled */ public String askQuestion(String realm, String question, boolean showAnswer, boolean maySave); /** * query if the user allowed the saving of the data of the last call * @return was the save data check box checked */ public boolean userAllowedSave(); /** * Request the SSH info to be used from the user. * the save data check box status will be queried by userAllowedSave * @param realm realm for the username * @param username username in the realm * @param sshPort the port number to use * @param maySave should a save data check box be enabled. * @return true if OK was pressed */ public boolean promptSSH(String realm, String username, int sshPort, boolean maySave); /** * retrieve the SSH key file entered during the prompt call * @return the key file */ public String getSSHPrivateKeyPath(); /** * retrieve the passphrase for the key file entered during * the prompt call * @return the passphrase */ public String getSSHPrivateKeyPassphrase(); /** * retrieve the SSH port entered during the prompt call * @return the port number */ public int getSSHPort(); /** * Request the SSL client certificate info to be used from the user. * the save data check box status will be queried by userAllowedSave * @param realm realm for the action * @param maySave should a save data check box be enabled. * @return true if OK was pressed */ public boolean promptSSL(String realm, boolean maySave); /** * retrieve the password for the certifcate * @return the password */ public String getSSLClientCertPassword(); /** * retrieve the SSL certificate entered during the prompt call * @return the certificate */ public String getSSLClientCertPath(); }svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNProperty.java000066400000000000000000000062331203563747500317340ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.io.File; /** * An interface describing a subversion property (e.g. as return by svn propget) * * @author Cédric Chabanois * cchabanois@ifrance.com */ public interface ISVNProperty { /** * mime type of the entry, used to flag binary files */ public static final String MIME_TYPE = "svn:mime-type"; /** * list of filenames with wildcards which should be ignored by add and * status */ public static final String IGNORE = "svn:ignore"; /** * how the end of line code should be treated during retrieval */ public static final String EOL_STYLE = "svn:eol-style"; /** * list of keywords to be expanded during retrieval */ public static final String KEYWORDS = "svn:keywords"; /** * flag if the file should be made excutable during retrieval */ public static final String EXECUTABLE = "svn:executable"; /** * value for svn:executable */ public static final String EXECUTABLE_VALUE = "*"; /** * list of directory managed outside of this working copy */ public static final String EXTERNALS = "svn:externals"; /** * the author of the revision */ public static final String REV_AUTHOR = "svn:author"; /** * the log message of the revision */ public static final String REV_LOG = "svn:log"; /** * the date of the revision */ public static final String REV_DATE = "svn:date"; /** * the original date of the revision */ public static final String REV_ORIGINAL_DATE = "svn:original-date"; /** * @return the name of the property */ String getName(); /** * Returns the string value of the property. * There is no protocol if a property is a string or a binary value * @return the string value */ String getValue(); /** * @return the file this property belongs to (or null if on remote resource) */ File getFile(); /** * @return the url this property belongs to */ SVNUrl getUrl(); /** * Returns the byte array value of the property * There is no protocol if a property is a string or a binary value * @return the byte array value */ byte[] getData(); }svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNStatus.java000066400000000000000000000107071203563747500313740ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.io.File; import java.util.Date; /** * An interface defining the status of one subversion item (file or directory) in * the working copy or repository. * * @author philip schatz */ public interface ISVNStatus { /** * @return the SVNUrl instance of url of the resource on repository */ SVNUrl getUrl(); /** * @return the url (String) of the resource in repository */ String getUrlString(); /** * @return the last changed revision or null if resource is not managed */ SVNRevision.Number getLastChangedRevision(); /** * @return date this resource last changed */ Date getLastChangedDate(); /** * get the last commit author or null if resource is not versionned * or if last commit author is unknown * @return the last commit author or null */ String getLastCommitAuthor(); /** * @return the file or directory status */ SVNStatusKind getTextStatus(); /** * @return the file or directory status of base */ SVNStatusKind getRepositoryTextStatus(); /** * @return status of properties (either Kind.NORMAL, Kind.CONFLICTED or Kind.MODIFIED) */ SVNStatusKind getPropStatus(); /** * @return the status of the properties base (either Kind.NORMAL, Kind.CONFLICTED or Kind.MODIFIED) */ SVNStatusKind getRepositoryPropStatus(); /** * @return the revision of the resource or null if not managed */ SVNRevision.Number getRevision(); /** * @return The path to this item relative to the directory from * which status was run. */ String getPath(); /** * @return The absolute path to this item. */ File getFile(); /** * @return The node kind of the managed resource, or {@link * SVNNodeKind#UNKNOWN} not managed. */ SVNNodeKind getNodeKind(); /** * @return true when the resource was copied */ boolean isCopied(); /** * @return true when the working copy directory is locked. */ boolean isWcLocked(); /** * @return true when the resource was switched relative to its parent. */ boolean isSwitched(); /** * Returns in case of conflict, the file of the most recent repository * version * @return the filename of the most recent repository version */ public File getConflictNew(); /** * Returns in case of conflict, the file of the common base version * @return the filename of the common base version */ public File getConflictOld(); /** * Returns in case of conflict, the file of the former working copy * version * @return the filename of the former working copy version */ public File getConflictWorking(); /** * Returns the lock owner * @return the lock owner */ public String getLockOwner(); /** * Returns the lock creation date * @return the lock creation date */ public Date getLockCreationDate(); /** * Returns the lock comment * @return the lock comment */ public String getLockComment(); /** * Returns the tree conflicted state * @return the tree conflicted state */ public boolean hasTreeConflict(); /** * Returns the conflict descriptor for the tree conflict * @return the conflict descriptor for the tree conflict */ public SVNConflictDescriptor getConflictDescriptor(); /** * Returns if the item is a file external * @return is the item is a file external */ public boolean isFileExternal(); } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNStatusCallback.java000066400000000000000000000002311203563747500330000ustar00rootroot00000000000000package org.tigris.subversion.svnclientadapter; public interface ISVNStatusCallback { public void doStatus(String path, ISVNStatus status); } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNBaseDir.java000066400000000000000000000136551203563747500313160ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.io.File; import java.io.IOException; import org.tigris.subversion.svnclientadapter.utils.StringUtils; /** * During notification (both with svn command line and javahl), the files and * directories are sometimes relative (with svn commit for ex). However it is * not relative to current directory but relative to the common parent of the * current directory and the working copy target * * ex : if working copy is at /home/cedric/programmation/sources/test and * current dir is /home/cedric/projects/subversion/subclipse * * $svn ci /home/cedric/programmation/sources/test/essai8 Adding * programmation/sources/test/essai8 * * @author Cedric Chabanois (cchab at tigris.org) * @author John M Flinchbaugh (john at hjsoft.com) */ public class SVNBaseDir { /** * get the common directory between file1 and file2 or null if the files * have nothing in common it always returns a directory unless file1 is the * same file than file2 * * @param file1 * @param file2 */ protected static File getCommonPart(File file1, File file2) { if (file1 == null) return null; if (file2 == null) return null; String file1AbsPath; String file2AbsPath; file1AbsPath = file1.getAbsolutePath(); file2AbsPath = file2.getAbsolutePath(); if (file1AbsPath.equals(file2AbsPath)) { return new File(file1AbsPath); } String[] file1Parts = StringUtils.split(file1AbsPath, File.separatorChar); String[] file2Parts = StringUtils.split(file2AbsPath, File.separatorChar); if (file1Parts[0].equals("")) file1Parts[0] = File.separator; if (file2Parts[0].equals("")) file2Parts[0] = File.separator; int parts1Length = file1Parts.length; int parts2Length = file2Parts.length; int minLength = (parts1Length < parts2Length) ? parts1Length : parts2Length; String part1; String part2; StringBuffer commonsPart = new StringBuffer(); for (int i = 0; i < minLength; i++) { part1 = file1Parts[i]; part2 = file2Parts[i]; if (!part1.equals(part2)) { break; } if (i > 0) { commonsPart.append(File.separatorChar); } commonsPart.append(part1); } if (commonsPart.length() == 0) { return null; // the two files have nothing in common (one on disk c: // and the other on d: for ex) } return new File(commonsPart.toString()); } /** * get the base directory for the given file * * @param file * @return the base directory for the given file or null if there is no base */ static public File getBaseDir(File file) { return getBaseDir(new File[] { file }); } /** * get the base directory for a set of files or null if there is no base * directory for the set of files * * @param files * @return the base directory for the given set of files or null if there is no base */ static public File getBaseDir(File[] files) { File rootDir = getRootDir(files); // get the common part between current directory and other files File baseDir = getCommonPart(rootDir, new File(".")); return baseDir; } /** * get the root directory for a set of files ie the ancestor of all given * files * * @param files * @return @throws * SVNClientException */ static public File getRootDir(File[] files) { if ((files == null) || (files.length == 0)) { return null; } File[] canonicalFiles = new File[files.length]; for (int i = 0; i < files.length; i++) { canonicalFiles[i] = files[i].getAbsoluteFile(); } // first get the common part between all files File commonPart = canonicalFiles[0]; for (int i = 0; i < files.length; i++) { commonPart = getCommonPart(commonPart, canonicalFiles[i]); if (commonPart == null) { return null; } } if (commonPart.isFile()) { return commonPart.getParentFile(); } else { return commonPart; } } /** * get path of file relative to rootDir * * @param rootDir * @param file * @return path of file relative to rootDir * @throws SVNClientException */ static public String getRelativePath(File rootDir, File file) throws SVNClientException { try { String rootPath = rootDir.getCanonicalPath(); String filePath = file.getCanonicalPath(); if (!filePath.startsWith(rootPath)) { return null; } return filePath.substring(rootPath.length()); } catch (IOException e) { throw SVNClientException.wrapException(e); } } }svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNClientAdapterFactory.java000066400000000000000000000076611203563747500340540ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.util.HashMap; import java.util.Map; /** * Abstract Factory for SVNClientAdapter. Real factories should extend this class and * register themselves with the method #registerAdapterFactory * * @author Cédric Chabanois * cchabanois@ifrance.com * * @author Panagiotis Korros * pkorros@bigfoot.com * */ public abstract class SVNClientAdapterFactory { private static Map ourFactoriesMap; // the first factory added is the preferred one private static SVNClientAdapterFactory preferredFactory; /** * Real Factories should implement these methods. */ protected abstract ISVNClientAdapter createSVNClientImpl(); protected abstract String getClientType(); /** * creates a new ISVNClientAdapter. You can create a javahl client or a command line * client. * * @param clientType * @return the client adapter that was requested or null if that client adapter is not * available or doesn't exist. */ public static ISVNClientAdapter createSVNClient(String clientType) { if (ourFactoriesMap == null || !ourFactoriesMap.containsKey(clientType)) { return null; } SVNClientAdapterFactory factory = (SVNClientAdapterFactory) ourFactoriesMap.get(clientType); if (factory != null) { return factory.createSVNClientImpl(); } return null; } /** * tells if the given clientType is available or not * * @param clientType * @return true if the given clientType is available */ public static boolean isSVNClientAvailable(String clientType) { return ourFactoriesMap != null && ourFactoriesMap.containsKey(clientType); } /** * @return the best svn client interface * @throws SVNClientException */ public static String getPreferredSVNClientType() throws SVNClientException { if (preferredFactory != null) { return preferredFactory.getClientType(); } throw new SVNClientException("No subversion client interface found."); } /** * Extenders should register themselves with this method. First registered factory * will be considered as the preferred one * * @throws SVNClientException when factory with specified type is already registered. */ protected static void registerAdapterFactory(SVNClientAdapterFactory factory) throws SVNClientException { if (factory == null) { return; } if (ourFactoriesMap == null) { ourFactoriesMap = new HashMap(); } String type = factory.getClientType(); if (!ourFactoriesMap.containsKey(type)) { ourFactoriesMap.put(type, factory); if (preferredFactory == null) { preferredFactory = factory; } } else { throw new SVNClientException("factory for type " + type + " already registered"); } } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNClientException.java000066400000000000000000000070111203563747500330670ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.lang.reflect.InvocationTargetException; /** * A generic exception thrown from any {@link ISVNClientAdapter} methods * * @author philip schatz */ public class SVNClientException extends Exception { private int aprError = NONE; private static final long serialVersionUID = 1L; public static final int NONE = -1; public static final int MERGE_CONFLICT = 155015; public static final int UNSUPPORTED_FEATURE = 200007; public static final String OPERATION_INTERRUPTED = "operation was interrupted"; /** * Constructs a new exception with null as its detail message. */ public SVNClientException() { super(); } /** * Constructs a new exception with the specified detail message. * @param message the detail message (which is saved for later retrieval * by the {@link #getMessage()} method). */ public SVNClientException(String message) { super(message); } /** * Constructs a new exception with the specified detail message and * cause. * @param message the detail message (which is saved for later retrieval * by the {@link #getMessage()} method). * @param cause the cause (which is saved for later retrieval by the * {@link #getCause()} method). (A null value is * permitted, and indicates that the cause is nonexistent or * unknown.) */ public SVNClientException(String message, Throwable cause) { super(message, cause); } /** * Constructs a new exception with the specified cause. * @param cause the cause (which is saved for later retrieval by the * {@link #getCause()} method). (A null value is * permitted, and indicates that the cause is nonexistent or * unknown.) */ public SVNClientException(Throwable cause) { super(cause); } /** * Facorty method for creating a delegating/wrapping exception. * @param e exception to wrap SVNClientException around * @return an SVNClientException instance */ public static SVNClientException wrapException(Exception e) { Throwable t = e; if (e instanceof InvocationTargetException) { Throwable target = ((InvocationTargetException) e).getTargetException(); if (target instanceof SVNClientException) { return (SVNClientException) target; } t = target; } return new SVNClientException(t); } public int getAprError() { return aprError; } public void setAprError(int aprError) { this.aprError = aprError; } public boolean operationInterrupted() { return getMessage() != null && getMessage().indexOf(OPERATION_INTERRUPTED) != -1; } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNConflictDescriptor.java000066400000000000000000000136641203563747500336050ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; /** * The description of a merge conflict, encountered during * merge/update/switch operations. * * copied from JavaHL ConflictDescriptor */ public class SVNConflictDescriptor { private String path; /** * @see .Kind */ private int conflictKind; /** * @see org.tigris.subversion.javahl.NodeKind */ private int nodeKind; private String propertyName; private boolean isBinary; private String mimeType; private int action; private int reason; private int operation; private SVNConflictVersion srcLeftVersion; private SVNConflictVersion srcRightVersion; // File paths, present only when the conflict involves the merging // of two files descended from a common ancestor, here are the // paths of up to four fulltext files that can be used to // interactively resolve the conflict. private String basePath; private String theirPath; private String myPath; private String mergedPath; public SVNConflictDescriptor(String path, int conflictKind, int nodeKind, String propertyName, boolean isBinary, String mimeType, int action, int reason, int operation, SVNConflictVersion srcLeftVersion, SVNConflictVersion srcRightVersion, String basePath, String theirPath, String myPath, String mergedPath) { this.path = path; this.conflictKind = conflictKind; this.nodeKind = nodeKind; this.propertyName = propertyName; this.isBinary = isBinary; this.mimeType = mimeType; this.action = action; this.reason = reason; this.srcLeftVersion = srcLeftVersion; this.srcRightVersion = srcRightVersion; this.operation = operation; this.basePath = basePath; this.theirPath = theirPath; this.myPath = myPath; this.mergedPath = mergedPath; } public SVNConflictDescriptor(String path, int action, int reason, int operation, SVNConflictVersion srcLeftVersion, SVNConflictVersion srcRightVersion) { this.path = path; this.action = action; this.reason = reason; this.operation = operation; this.srcLeftVersion = srcLeftVersion; this.srcRightVersion = srcRightVersion; } public String getPath() { return path; } public int getConflictKind() { return conflictKind; } public int getNodeKind() { return nodeKind; } public String getPropertyName() { return propertyName; } public boolean isBinary() { return isBinary; } public String getMIMEType() { return mimeType; } public int getAction() { return action; } public int getReason() { return reason; } public int getOperation() { return operation; } public SVNConflictVersion getSrcLeftVersion() { return srcLeftVersion; } public SVNConflictVersion getSrcRightVersion() { return srcRightVersion; } public String getBasePath() { return basePath; } public String getTheirPath() { return theirPath; } public String getMyPath() { return myPath; } public String getMergedPath() { return mergedPath; } /** * From JavaHL. */ public final class Kind { /** * Attempting to change text or props. */ public static final int text = 0; /** * Attempting to add object. */ public static final int property = 1; } /** * From JavaHL */ public final class Action { /** * Attempting to change text or props. */ public static final int edit = 0; /** * Attempting to add object. */ public static final int add = 1; /** * Attempting to delete object. */ public static final int delete = 2; } /** * From JavaHL */ public final class Reason { /** * Local edits are already present. */ public static final int edited = 0; /** * Another object is in the way. */ public static final int obstructed = 1; /** * Object is already schedule-delete. */ public static final int deleted = 2; /** * Object is unknown or missing. */ public static final int missing = 3; /** * Object is unversioned. */ public static final int unversioned = 4; /** * Object is already added or schedule-add. */ public static final int added = 5; } public final class Operation { public static final int _none = 0; public static final int _update = 1; public static final int _switch = 2; public static final int _merge = 3; } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNConflictResult.java000066400000000000000000000040051203563747500327320ustar00rootroot00000000000000package org.tigris.subversion.svnclientadapter; /** * The result returned by the callback API used to handle conflicts * encountered during merge/update/switch operations. */ public class SVNConflictResult { /** * Nothing done to resolve the conflict; conflict remains. */ public static final int postpone = 0; /** * Resolve the conflict by choosing the base file. */ public static final int chooseBase = 1; /** * Resolve the conflict by choosing the incoming (repository) * version of the object. */ public static final int chooseTheirsFull = 2; /** * Resolve the conflict by choosing own (local) version of the * object. */ public static final int chooseMineFull = 3; /** * Resolve the conflict by choosing the incoming (repository) * version of the object (for conflicted hunks only). */ public static final int chooseTheirs = 4; /** * Resolve the conflict by choosing own (local) version of the * object (for conflicted hunks only). */ public static final int chooseMine = 5; /** * Resolve the conflict by choosing the merged object * (potentially manually edited). */ public static final int chooseMerged = 6; /** * A value corresponding to the * svn_wc_conflict_choice_t enum. */ private int choice; /** * The path to the result of a merge, or null. */ private String mergedPath; /** * Create a new conflict result instace. */ public SVNConflictResult(int choice, String mergedPath) { this.choice = choice; this.mergedPath = mergedPath; } /** * @return A value corresponding to the * svn_wc_conflict_choice_t enum. */ public int getChoice() { return choice; } /** * @return The path to the result of a merge, or null. */ public String getMergedPath() { return mergedPath; } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNConflictVersion.java000066400000000000000000000025101203563747500331000ustar00rootroot00000000000000package org.tigris.subversion.svnclientadapter; public class SVNConflictVersion { private String reposURL; private long pegRevision; private String pathInRepos; private int nodeKind; public SVNConflictVersion(String reposURL, long pegRevision, String pathInRepos, int nodeKind) { this.reposURL = reposURL; this.pegRevision = pegRevision; this.pathInRepos = pathInRepos; this.nodeKind = nodeKind; } public String getReposURL() { return reposURL; } public long getPegRevision() { return pegRevision; } public String getPathInRepos() { return pathInRepos; } public int getNodeKind() { return nodeKind; } public String toString() { StringBuffer sb = new StringBuffer("("); switch (nodeKind) { case NodeKind.none: sb.append("none"); break; case NodeKind.file: sb.append("file"); break; case NodeKind.directory: sb.append("dir"); break; default: sb.append(nodeKind); break; } sb.append(") " + reposURL + "/" + pathInRepos + "@" + pegRevision); return sb.toString(); } public final class NodeKind { public static final int none = 0; public static final int file = 1; public static final int directory = 2; } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNConstants.java000066400000000000000000000025131203563747500317500ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; /** * Subversion related global constants * */ public class SVNConstants { /** a "entries" workingCopy metadata directory name */ public static final String SVN_ENTRIES = "wc.db"; /** a "dir-props" workingCopy metadata directory name */ public static final String SVN_DIRPROPS = "dir-props"; /** a "props" workingCopy metadata directory name */ public static final String SVN_PROPS = "props"; } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNCopySource.java000066400000000000000000000040041203563747500320640ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2007 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; public class SVNCopySource { /** * The source path or URL. */ private String path; /** * The source revision. */ private SVNRevision revision; /** * The peg revision. */ private SVNRevision pegRevision; /** * Create a new instance. * * @param path * @param revision The source revision. * @param pegRevision The peg revision. Typically interpreted as * {@link org.tigris.subversion.javahl.SVNRevision#HEAD} when * null. */ public SVNCopySource(String path, SVNRevision revision, SVNRevision pegRevision) { this.path = path; this.revision = revision; this.pegRevision = pegRevision; } /** * @return The source path or URL. */ public String getPath() { return this.path; } /** * @return The source revision. */ public SVNRevision getRevision() { return this.revision; } /** * @return The peg revision. */ public SVNRevision getPegRevision() { return this.pegRevision; } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNDiffSummary.java000066400000000000000000000123251203563747500322240ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2007 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.util.EventObject; /** * The event passed to the {@link * DiffSummarizer.summarize(SVNDiffSummary)} API in response to path * differences reported by {@link ISVNClientAdapter#diffSummarize}. * */ public class SVNDiffSummary extends EventObject { // Update the serialVersionUID when there is a incompatible change // made to this class. See any of the following, depending upon // the Java release. // http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/version.doc7.html // http://java.sun.com/j2se/1.4/pdf/serial-spec.pdf // http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/version.html#6678 // http://java.sun.com/javase/6/docs/platform/serialization/spec/version.html#6678 private static final long serialVersionUID = 1L; private SVNDiffKind diffKind; private boolean propsChanged; private int nodeKind; /** * This constructor is to be used by the native code. * * @param path The path we have a diff for. * @param diffKind The kind of diff this describes. * @param propChanged Whether any properties have changed. * @param nodeKind The type of node which changed (corresponds to * the {@link SVNNodeKind} enumeration). */ public SVNDiffSummary(String path, SVNDiffKind diffKind, boolean propsChanged, int nodeKind) { super(path); this.diffKind = diffKind; this.propsChanged = propsChanged; this.nodeKind = nodeKind; } /** * @return The path we have a diff for. */ public String getPath() { return (String) super.source; } /** * @return The kind of summary this describes. */ public SVNDiffKind getDiffKind() { return this.diffKind; } /** * @return Whether any properties have changed. */ public boolean propsChanged() { return this.propsChanged; } /** * @return The type of node which changed (corresponds to the * {@link NodeKind} enumeration). */ public int getNodeKind() { return this.nodeKind; } /** * @return The path. */ public String toString() { return getPath(); } /** * The type of difference being summarized. */ public static class SVNDiffKind { // Corresponds to the svn_client_diff_summarize_kind_t enum. public static SVNDiffKind NORMAL = new SVNDiffKind(0); public static SVNDiffKind ADDED = new SVNDiffKind(1); public static SVNDiffKind MODIFIED = new SVNDiffKind(2); public static SVNDiffKind DELETED = new SVNDiffKind(3); private int kind; private SVNDiffKind(int kind) { this.kind = kind; } /** * @return The appropriate instance. * @throws IllegalArgumentException If the diff kind is not * recognized. */ public static SVNDiffKind getInstance(int diffKind) throws IllegalArgumentException { switch (diffKind) { case 0: return NORMAL; case 1: return ADDED; case 2: return MODIFIED; case 3: return DELETED; default: throw new IllegalArgumentException("Diff kind " + diffKind + " not recognized"); } } /** * @param diffKind A DiffKind for comparison. * @return Whether both DiffKinds are of the same type. */ public boolean equals(Object diffKind) { return (((SVNDiffKind) diffKind).kind == this.kind); } public int hashCode() { // Equivalent to new Integer(this.kind).hashCode(). return this.kind; } /** * @return A textual representation of the type of diff. */ public String toString() { switch (this.kind) { case 0: return "normal"; case 1: return "added"; case 2: return "modified"; case 3: return "deleted"; default: return "unknown"; } } } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNInfoUnversioned.java000066400000000000000000000105611203563747500331130ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.io.File; import java.util.Date; import org.tigris.subversion.svnclientadapter.SVNRevision.Number; /** * A special {@link ISVNInfo} implementation that is used if a File/Folder is not versioned. * * @author Cédric Chabanois (cchabanois at no-log.org) */ public class SVNInfoUnversioned implements ISVNInfo { private File file; /** * Constructor * @param file */ public SVNInfoUnversioned(File file) { this.file = file; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getFile() */ public File getFile() { return file; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getUrl() */ public SVNUrl getUrl() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getUrlString() */ public String getUrlString() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getUuid() */ public String getUuid() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getRepository() */ public SVNUrl getRepository() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getSchedule() */ public SVNScheduleKind getSchedule() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getNodeKind() */ public SVNNodeKind getNodeKind() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastCommitAuthor() */ public String getLastCommitAuthor() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getRevision() */ public Number getRevision() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastChangedRevision() */ public Number getLastChangedRevision() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastChangedDate() */ public Date getLastChangedDate() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastDateTextUpdate() */ public Date getLastDateTextUpdate() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLastDatePropsUpdate() */ public Date getLastDatePropsUpdate() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#isCopied() */ public boolean isCopied() { return false; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getCopyRev() */ public Number getCopyRev() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getCopyUrl() */ public SVNUrl getCopyUrl() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockCreationDate() */ public Date getLockCreationDate() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockOwner() */ public String getLockOwner() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getLockComment() */ public String getLockComment() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNInfo#getDepth() */ public int getDepth() { return -2; } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNKeywords.java000066400000000000000000000113151203563747500316030ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; /** * tells which keywords are enabled for a given resource */ public class SVNKeywords { public static final String LAST_CHANGED_DATE = "LastChangedDate"; public static final String DATE = "Date"; public static final String LAST_CHANGED_REVISION = "LastChangedRevision"; public static final String REV = "Rev"; public static final String LAST_CHANGED_BY = "LastChangedBy"; public static final String AUTHOR = "Author"; public static final String HEAD_URL = "HeadURL"; public static final String URL = "URL"; public static final String ID = "Id"; private boolean lastChangedDate = false; private boolean lastChangedRevision = false; private boolean lastChangedBy = false; private boolean headUrl = false; private boolean id = false; public SVNKeywords() { } public SVNKeywords(String keywords) { if (keywords == null) return; StringTokenizer st = new StringTokenizer(keywords," "); while (st.hasMoreTokens()) { String keyword = st.nextToken(); // don't know if keywords are case sensitive or no if ((keyword.equals(SVNKeywords.HEAD_URL)) || (keyword.equals(SVNKeywords.URL))) headUrl = true; else if (keyword.equals(SVNKeywords.ID)) id = true; else if ((keyword.equals(SVNKeywords.LAST_CHANGED_BY)) || (keyword.equals(SVNKeywords.AUTHOR))) lastChangedBy = true; else if ((keyword.equals(SVNKeywords.LAST_CHANGED_DATE)) || (keyword.equals(SVNKeywords.DATE))) lastChangedDate = true; else if ((keyword.equals(SVNKeywords.LAST_CHANGED_REVISION)) || (keyword.equals(SVNKeywords.REV))) lastChangedRevision = true; } } public SVNKeywords( boolean lastChangedDate, boolean lastChangedRevision, boolean lastChangedBy, boolean headUrl, boolean id) { this.lastChangedDate = lastChangedDate; this.lastChangedRevision = lastChangedRevision; this.lastChangedBy = lastChangedBy; this.headUrl = headUrl; this.id = id; } public boolean isHeadUrl() { return headUrl; } public boolean isId() { return id; } public boolean isLastChangedBy() { return lastChangedBy; } public boolean isLastChangedDate() { return lastChangedDate; } public boolean isLastChangedRevision() { return lastChangedRevision; } /** * * @return the list of keywords */ public List getKeywordsList() { ArrayList list = new ArrayList(); if (headUrl) list.add(HEAD_URL); if (id) list.add(ID); if (lastChangedBy) list.add(LAST_CHANGED_BY); if (lastChangedDate) list.add(LAST_CHANGED_DATE); if (lastChangedRevision) list.add(LAST_CHANGED_REVISION); return list; } public String toString() { String result = ""; for (Iterator it = getKeywordsList().iterator(); it.hasNext();) { String keyword = (String) it.next(); result += keyword; if (it.hasNext()) result += ' '; } return result; } public void setHeadUrl(boolean b) { headUrl = b; } public void setId(boolean b) { id = b; } public void setLastChangedBy(boolean b) { lastChangedBy = b; } public void setLastChangedDate(boolean b) { lastChangedDate = b; } public void setLastChangedRevision(boolean b) { lastChangedRevision = b; } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNLogMessageCallback.java000066400000000000000000000013751203563747500334440ustar00rootroot00000000000000package org.tigris.subversion.svnclientadapter; import java.util.ArrayList; import java.util.List; import java.util.Stack; public class SVNLogMessageCallback implements ISVNLogMessageCallback { private List messages = new ArrayList(); private Stack stack = new Stack(); public void singleMessage(ISVNLogMessage msg) { if (msg == null) { if (!stack.empty()) stack.pop(); return; } if (stack.empty()) { messages.add(msg); } else { ISVNLogMessage current = (ISVNLogMessage) stack.peek(); current.addChild(msg); } if (msg.hasChildren()) stack.push(msg); } public ISVNLogMessage[] getLogMessages() { ISVNLogMessage[] array = new ISVNLogMessage[messages.size()]; return (ISVNLogMessage[]) messages.toArray(array); } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNLogMessageChangePath.java000066400000000000000000000052311203563747500337450ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; /** * A generic implementation of the {@link ISVNLogMessageChangePath} interface. * */ public class SVNLogMessageChangePath implements ISVNLogMessageChangePath { /** Path of commited item */ private String path; /** Source revision of copy (if any). */ private SVNRevision.Number copySrcRevision; /** Source path of copy (if any). */ private String copySrcPath; /** 'A'dd, 'D'elete, 'R'eplace, 'M'odify */ private char action; /** * Constructor * @param path * @param copySrcRevision * @param copySrcPath * @param action */ public SVNLogMessageChangePath(String path, SVNRevision.Number copySrcRevision, String copySrcPath, char action) { this.path = path; this.copySrcRevision = copySrcRevision; this.copySrcPath = copySrcPath; this.action = action; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLogMessageChangePath#getPath() */ public String getPath() { return path; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLogMessageChangePath#getCopySrcRevision() */ public SVNRevision.Number getCopySrcRevision() { return copySrcRevision; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLogMessageChangePath#getCopySrcPath() */ public String getCopySrcPath() { return copySrcPath; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNLogMessageChangePath#getAction() */ public char getAction() { return action; } /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { return getPath(); } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNNodeKind.java000066400000000000000000000077011203563747500314730ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; /** * Kind of a node (dir, file) */ public class SVNNodeKind { private int kind; private static final int none = 0; private static final int file = 1; private static final int dir = 2; private static final int unknown = 3; /** Node kind absent */ public static final SVNNodeKind NONE = new SVNNodeKind(none); /** Node kind regular file */ public static final SVNNodeKind FILE = new SVNNodeKind(file); /** Node kind Directory */ public static final SVNNodeKind DIR = new SVNNodeKind(dir); /** Node kind unknwon - something's here, but we don't know what */ public static final SVNNodeKind UNKNOWN = new SVNNodeKind(unknown); /** * Private costructor. * @param kind */ private SVNNodeKind(int kind) { this.kind = kind; } /** * @return an integer value representation of the nodeKind */ public int toInt() { return kind; } /** * Returns the SVNNodeKind corresponding to the given int representation. * (As returned by {@link SVNNodeKind#toInt()} method) * @param nodeKind * @return SVNNodeKind representing the int value */ public static SVNNodeKind fromInt(int nodeKind) { switch(nodeKind) { case none: return NONE; case file: return FILE; case dir: return DIR; case unknown: return UNKNOWN; default: return null; } } /** * Returns the SVNNodeKind corresponding to the given string or null * @param nodeKind * @return SVNNodeKind representing the string value */ public static SVNNodeKind fromString(String nodeKind) { if (NONE.toString().equals(nodeKind)) { return NONE; } else if (FILE.toString().equals(nodeKind)) { return FILE; } else if (DIR.toString().equals(nodeKind)) { return DIR; } else if ("dir".equals(nodeKind)) { return DIR; } else if (UNKNOWN.toString().equals(nodeKind)) { return UNKNOWN; } else return null; } /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { switch(kind) { case none: return "none"; case file: return "file"; case dir: return "directory"; case unknown: return "unknown"; default: return ""; } } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (!(obj instanceof SVNNodeKind)) { return false; } return ((SVNNodeKind)obj).kind == kind; } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { return new Integer(kind).hashCode(); } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNNotificationHandler.java000066400000000000000000000147131203563747500337250ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.io.File; import java.util.HashSet; import java.util.Iterator; import java.util.Set; /** * Notification handler : * It sends notifications to all listeners */ public abstract class SVNNotificationHandler { protected Set notifylisteners = new HashSet(); protected int command; protected boolean logEnabled = true; protected File baseDir = new File("."); /** * Add a notification listener * @param listener */ public void add(ISVNNotifyListener listener) { notifylisteners.add(listener); } /** * Remove a notification listener * @param listener */ public void remove(ISVNNotifyListener listener) { notifylisteners.remove(listener); } /** * restore logging */ public void enableLog() { logEnabled = true; } /** * disable all logging */ public void disableLog() { logEnabled = false; } public void logMessage(String message) { if (logEnabled) { for(Iterator it=notifylisteners.iterator(); it.hasNext();) { ISVNNotifyListener listener = (ISVNNotifyListener)it.next(); listener.logMessage(message); } } } public void logError(String message) { if (logEnabled) { for(Iterator it=notifylisteners.iterator(); it.hasNext();) { ISVNNotifyListener listener = (ISVNNotifyListener)it.next(); listener.logError(message); } } } public void logRevision(long revision, String path) { if (logEnabled) { for(Iterator it=notifylisteners.iterator(); it.hasNext();) { ISVNNotifyListener listener = (ISVNNotifyListener)it.next(); listener.logRevision(revision, path); } } } public void logCompleted(String message) { if (logEnabled) { for(Iterator it=notifylisteners.iterator(); it.hasNext();) { ISVNNotifyListener listener = (ISVNNotifyListener)it.next(); listener.logCompleted(message); } } } /** * set the command * @param command */ public void setCommand(int command) { this.command = command; for(Iterator it=notifylisteners.iterator(); it.hasNext();) { ISVNNotifyListener listener = (ISVNNotifyListener)it.next(); listener.setCommand(command); } } /** * log the command line * @param commandLine */ public void logCommandLine(String commandLine) { if (logEnabled && !skipCommand()) { for(Iterator it=notifylisteners.iterator(); it.hasNext();) { ISVNNotifyListener listener = (ISVNNotifyListener)it.next(); listener.logCommandLine(commandLine); } } } /** * To call when a method of ClientAdapter throw an exception * @param clientException */ public void logException(Exception clientException) { if (logEnabled) { Throwable e = clientException; while (e != null) { logError(e.getMessage()); e = e.getCause(); } } } /** * set the baseDir : directory to use as base directory when path is relative * @param baseDir */ public void setBaseDir(File baseDir) { if (baseDir != null) { this.baseDir = baseDir; } else { setBaseDir(); } } public void setBaseDir() { this.baseDir = new File("."); } private File getAbsoluteFile(String path) { if (path == null) return null; File f = new File(path); if (!f.isAbsolute()) { f = new File(baseDir,path); } return f; } public void notifyListenersOfChange(String path) { if (path == null) return; File f = getAbsoluteFile(path); if (f == null) { // this should not happen logMessage("Warning : invalid path :"+path); return; } SVNNodeKind kind; if (f.isFile()) { kind = SVNNodeKind.FILE; } else if (f.isDirectory()) { kind = SVNNodeKind.DIR; } else { kind = SVNNodeKind.UNKNOWN; } for(Iterator it=notifylisteners.iterator(); it.hasNext();) { ISVNNotifyListener listener = (ISVNNotifyListener)it.next(); listener.onNotify(f, kind); } } public void notifyListenersOfChange(String path, SVNNodeKind kind) { if (path == null) return; File f = getAbsoluteFile(path); if (f == null) { // this should not happen logMessage("Warning : invalid path :"+path); return; } for(Iterator it=notifylisteners.iterator(); it.hasNext();) { ISVNNotifyListener listener = (ISVNNotifyListener)it.next(); listener.onNotify(f, kind); } } /** * For certain commands we just want to skip the logging of the * command line */ protected boolean skipCommand() { if (command == ISVNNotifyListener.Command.CAT || command == ISVNNotifyListener.Command.INFO || command == ISVNNotifyListener.Command.LOG || command == ISVNNotifyListener.Command.LS || command == ISVNNotifyListener.Command.PROPGET || command == ISVNNotifyListener.Command.PROPLIST || command == ISVNNotifyListener.Command.STATUS ) return true; else return false; } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNProgressEvent.java000066400000000000000000000006061203563747500326030ustar00rootroot00000000000000package org.tigris.subversion.svnclientadapter; public class SVNProgressEvent { private long progress; private long total; public final static long UNKNOWN = -1; public SVNProgressEvent(long progress, long total) { super(); this.progress = progress; this.total = total; } public long getProgress() { return progress; } public long getTotal() { return total; } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNRevision.java000066400000000000000000000206651203563747500316020ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; /** * Class to specify a revision in a svn command. * This class has been copied directly from javahl and renamed to SVNRevision * the static method getRevision has then been added to the class * */ public class SVNRevision { // See chapter 3 section 3.3 of the SVN book for valid date strings protected static final DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd'T'HHmmssZ"); protected int revKind; public SVNRevision(int kind) { revKind = kind; } public int getKind() { return revKind; } public String toString() { switch(revKind) { case Kind.unspecified : return "START"; case Kind.base : return "BASE"; case Kind.committed : return "COMMITTED"; case Kind.head : return "HEAD"; case Kind.previous : return "PREV"; case Kind.working : return "WORKING"; } return super.toString(); } public boolean equals(Object target) { if (this == target) return true; if (!(target instanceof SVNRevision)) return false; return ((SVNRevision)target).revKind == revKind; } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { return revKind; } public static final SVNRevision HEAD = new SVNRevision(Kind.head); public static final SVNRevision START = new SVNRevision(Kind.unspecified); public static final SVNRevision COMMITTED = new SVNRevision(Kind.committed); public static final SVNRevision PREVIOUS = new SVNRevision(Kind.previous); public static final SVNRevision BASE = new SVNRevision(Kind.base); public static final SVNRevision WORKING = new SVNRevision(Kind.working); public static final int SVN_INVALID_REVNUM = -1; public static final SVNRevision.Number INVALID_REVISION = new SVNRevision.Number(SVN_INVALID_REVNUM); public static class Number extends SVNRevision implements Comparable { protected long revNumber; public Number(long number) { super(Kind.number); revNumber = number; } public long getNumber() { return revNumber; } public String toString() { return Long.toString(revNumber); } public boolean equals(Object target) { if (!super.equals(target)) return false; return ((SVNRevision.Number)target).revNumber == revNumber; } public int hashCode() { return (int) revNumber; } public int compareTo(Object target) { SVNRevision.Number compare = (SVNRevision.Number)target; if (revNumber > compare.getNumber()) return 1; if (compare.getNumber() > revNumber) return -1; return 0; } } public static class DateSpec extends SVNRevision { protected Date revDate; public DateSpec(Date date) { super(Kind.date); revDate = date; } public Date getDate() { return revDate; } /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { return '{' + dateFormat.format(revDate)+ '}'; } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object target) { if (!super.equals(target)) return false; return ((SVNRevision.DateSpec)target).revDate.equals(revDate); } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { return revDate.hashCode(); } } /** Various ways of specifying revisions. * * Various ways of specifying revisions. * * Note: * In contexts where local mods are relevant, the `working' kind * refers to the uncommitted "working" revision, which may be modified * with respect to its base revision. In other contexts, `working' * should behave the same as `committed' or `current'. */ public static final class Kind { /** No revision information given. */ public static final int unspecified = 0; /** revision given as number */ public static final int number = 1; /** revision given as date */ public static final int date = 2; /** rev of most recent change */ public static final int committed = 3; /** (rev of most recent change) - 1 */ public static final int previous = 4; /** .svn/entries current revision */ public static final int base = 5; /** current, plus local mods */ public static final int working = 6; /** repository youngest */ public static final int head = 7; } /** * get a revision from a string * revision can be : * - a date with the format according to dateFormat * - a revision number * - HEAD, BASE, COMMITED or PREV * * @param revision * @param aDateFormat * @return Revision * @throws ParseException when the revision string cannot be parsed */ public static SVNRevision getRevision(String revision, SimpleDateFormat aDateFormat) throws ParseException { if ((revision == null) || (revision.equals(""))) return null; // try special KEYWORDS if (revision.compareToIgnoreCase("HEAD") == 0) return SVNRevision.HEAD; // latest in repository else if (revision.compareToIgnoreCase("BASE") == 0) return new SVNRevision(SVNRevision.Kind.base); // base revision of item's working copy else if (revision.compareToIgnoreCase("COMMITED") == 0) return new SVNRevision(SVNRevision.Kind.committed); // revision of item's last commit else if (revision.compareToIgnoreCase("PREV") == 0) // revision before item's last commit return new SVNRevision(SVNRevision.Kind.previous); // try revision number try { int revisionNumber = Integer.parseInt(revision); if (revisionNumber >= 0) return new SVNRevision.Number(revisionNumber); } catch (NumberFormatException e) { } // try date SimpleDateFormat df = (aDateFormat != null) ? aDateFormat : new SimpleDateFormat("MM/dd/yyyy hh:mm a", Locale.US); try { Date revisionDate = df.parse(revision); return new SVNRevision.DateSpec(revisionDate); } catch (ParseException e) { } throw new ParseException("Invalid revision. Revision should be a number, a date in " + df.toPattern() + " format or HEAD, BASE, COMMITED or PREV",0); } /** * get a revision from a string * revision can be : * - a date with the following format : MM/DD/YYYY HH:MM AM_PM * - a revision number * - HEAD, BASE, COMMITED or PREV * * @param revision * @return Revision * @throws ParseException when the revision string cannot be parsed */ public static SVNRevision getRevision(String revision) throws ParseException { return getRevision(revision, new SimpleDateFormat("MM/dd/yyyy hh:mm a", Locale.US)); } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNRevisionRange.java000066400000000000000000000175451203563747500325620ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2007 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.util.ArrayList; import java.util.Arrays; /** * Object that describes a revision range * * copied from JavaHL implementation * */ public class SVNRevisionRange implements Comparable, java.io.Serializable { // Update the serialVersionUID when there is a incompatible change // made to this class. See any of the following, depending upon // the Java release. // http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/version.doc7.html // http://java.sun.com/j2se/1.4/pdf/serial-spec.pdf // http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/version.html#6678 // http://java.sun.com/javase/6/docs/platform/serialization/spec/version.html#6678 private static final long serialVersionUID = 1L; private SVNRevision from; private SVNRevision to; public SVNRevisionRange(SVNRevision from, SVNRevision to) { this.from = from; this.to = to; } public SVNRevisionRange(SVNRevision.Number from, SVNRevision.Number to, boolean convertToNMinusOne) { if (convertToNMinusOne) { this.from = new SVNRevision.Number(from.getNumber() - 1); } else this.from = from; this.to = to; } /** * Accepts a string in one of these forms: n m-n Parses the results into a * from and to revision * @param revisionElement revision range or single revision */ public SVNRevisionRange(String revisionElement) { super(); if (revisionElement == null) { return; } int hyphen = revisionElement.indexOf('-'); if (hyphen > 0) { try { long fromRev = Long .parseLong(revisionElement.substring(0, hyphen)); long toRev = Long.parseLong(revisionElement .substring(hyphen + 1)); this.from = new SVNRevision.Number(fromRev); this.to = new SVNRevision.Number(toRev); } catch (NumberFormatException e) { return; } } else { try { long revNum = Long.parseLong(revisionElement.trim()); this.from = new SVNRevision.Number(revNum); this.to = this.from; } catch (NumberFormatException e) { return; } } } public SVNRevision getFromRevision() { return from; } public SVNRevision getToRevision() { return to; } public String toString() { if (from != null && to != null) { if (from.equals(to)) return from.toString(); else return from.toString() + '-' + to.toString(); } return super.toString(); } public static Long getRevisionAsLong(SVNRevision rev) { long val = 0; if (rev != null && rev instanceof SVNRevision.Number) { val = ((SVNRevision.Number) rev).getNumber(); } return new Long(val); } public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((from == null) ? 0 : from.hashCode()); result = prime * result + ((to == null) ? 0 : to.hashCode()); return result; } /** * @param range The RevisionRange to compare this object to. */ public boolean equals(Object range) { if (this == range) return true; if (!super.equals(range)) return false; if (getClass() != range.getClass()) return false; final SVNRevisionRange other = (SVNRevisionRange) range; if (from == null) { if (other.from != null) return false; } else if (!from.equals(other.from)) { return false; } if (to == null) { if (other.to != null) return false; } else if (!to.equals(other.to)) { return false; } return true; } /** * @param range The RevisionRange to compare this object to. */ public int compareTo(Object range) { if (this == range) return 0; SVNRevision other = ((SVNRevisionRange) range).getFromRevision(); return SVNRevisionRange.getRevisionAsLong(this.getFromRevision()) .compareTo(SVNRevisionRange.getRevisionAsLong(other)); } public static SVNRevisionRange[] getRevisions(SVNRevision.Number[] selectedRevisions, SVNRevision.Number[] allRevisions) { Arrays.sort(selectedRevisions); Arrays.sort(allRevisions); ArrayList svnRevisionRanges = new ArrayList(); SVNRevision.Number fromRevision = null; SVNRevision.Number toRevision = null; int j = 0; for (int i = 0; i < selectedRevisions.length; i++) { if (fromRevision == null) { fromRevision = selectedRevisions[i]; while (allRevisions[j++].getNumber() != selectedRevisions[i].getNumber()) {} } else { if (selectedRevisions[i].getNumber() != allRevisions[j++].getNumber()) { SVNRevisionRange revisionRange = new SVNRevisionRange(fromRevision, toRevision, true); svnRevisionRanges.add(revisionRange); fromRevision = selectedRevisions[i]; while (allRevisions[j++].getNumber() != selectedRevisions[i].getNumber()) {} } } toRevision = selectedRevisions[i]; } if (toRevision != null) { SVNRevisionRange revisionRange = new SVNRevisionRange(fromRevision, toRevision, true); svnRevisionRanges.add(revisionRange); } SVNRevisionRange[] revisionRangeArray = new SVNRevisionRange[svnRevisionRanges.size()]; svnRevisionRanges.toArray(revisionRangeArray); return revisionRangeArray; } /** * Returns boolean whether revision is contained in the range * @param revision * @param inclusiveFromRev - include an exact match of from revision * @return */ public boolean contains(SVNRevision revision, boolean inclusiveFromRev) { long fromRev = SVNRevisionRange.getRevisionAsLong(from).longValue(); long toRev = SVNRevisionRange.getRevisionAsLong(to).longValue(); long rev = SVNRevisionRange.getRevisionAsLong(revision).longValue(); if (inclusiveFromRev) { if (rev >= fromRev && (to.equals(SVNRevision.HEAD) || rev <= toRev)) return true; else return false; } else { if (rev > fromRev && (to.equals(SVNRevision.HEAD) || rev <= toRev)) return true; else return false; } } public String toMergeString() { long fromRev = SVNRevisionRange.getRevisionAsLong(from).longValue(); long toRev = SVNRevisionRange.getRevisionAsLong(to).longValue(); if ((fromRev + 1) == toRev) { return "-c " + toRev; } return "-r " + fromRev + ":" + toRev; } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNScheduleKind.java000066400000000000000000000077271203563747500323520ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; /** * Schedule kind an entry can be in. * @see ISVNInfo#getSchedule() */ public class SVNScheduleKind { private int kind; private static final int normal = 0; private static final int add = 1; private static final int delete = 2; private static final int replace = 3; /** exists, but uninteresting */ public static final SVNScheduleKind NORMAL = new SVNScheduleKind(normal); /** Slated for addition */ public static final SVNScheduleKind ADD = new SVNScheduleKind(add); /** Slated for deletion */ public static final SVNScheduleKind DELETE = new SVNScheduleKind(delete); /** Slated for replacement (delete + add) */ public static final SVNScheduleKind REPLACE = new SVNScheduleKind(replace); private SVNScheduleKind(int kind) { this.kind = kind; } /** * @return an integer value representation of the scheduleKind */ public int toInt() { return kind; } /** * Returns the SVNScheduleKind corresponding to the given int representation. * (As returned by {@link SVNScheduleKind#toInt()} method) * @param scheduleKind * @return SVNScheduleKind representing the int value */ public SVNScheduleKind fromInt(int scheduleKind) { switch(scheduleKind) { case normal: return NORMAL; case add: return ADD; case delete: return DELETE; case replace: return REPLACE; default: return null; } } /** * returns the ScheduleKind corresponding to the given string or null * @param scheduleKind * @return SVNScheduleKind representing the supplied string value */ public static SVNScheduleKind fromString(String scheduleKind) { if (NORMAL.toString().equals(scheduleKind)) { return NORMAL; } else if (ADD.toString().equals(scheduleKind)) { return ADD; } else if (DELETE.toString().equals(scheduleKind)) { return DELETE; } else if (REPLACE.toString().equals(scheduleKind)) { return REPLACE; } else return null; } /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { switch(kind) { case normal: return "normal"; case add: return "add"; case delete: return "delete"; case replace: return "replace"; default: return ""; } } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (!(obj instanceof SVNScheduleKind)) { return false; } return ((SVNScheduleKind)obj).kind == kind; } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { return new Integer(kind).hashCode(); } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNStatusCallback.java000066400000000000000000000007661203563747500327040ustar00rootroot00000000000000package org.tigris.subversion.svnclientadapter; import java.util.ArrayList; import java.util.List; public class SVNStatusCallback implements ISVNStatusCallback { private List statuses = new ArrayList(); public void doStatus(String path, ISVNStatus status) { if (status != null) { statuses.add(status); } } public ISVNStatus[] getStatuses() { ISVNStatus[] statusArray = new ISVNStatus[statuses.size()]; statuses.toArray(statusArray); return statusArray; } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNStatusKind.java000066400000000000000000000174571203563747500321020ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; /** * Base class for enumerating the possible types for a Status. * */ public class SVNStatusKind { private final int kind; private boolean treeConflicted; private static final int none = 0; private static final int normal = 1; private static final int modified = 2; private static final int added = 3; private static final int deleted = 4; private static final int unversioned = 5; private static final int missing = 6; private static final int replaced = 7; private static final int merged = 8; private static final int conflicted = 9; private static final int obstructed = 10; private static final int ignored = 11; private static final int incomplete = 12; private static final int external = 13; /** does not exist */ public static final SVNStatusKind NONE = new SVNStatusKind(none); /** exists, but uninteresting. */ public static final SVNStatusKind NORMAL = new SVNStatusKind(normal); /** is scheduled for addition */ public static final SVNStatusKind ADDED = new SVNStatusKind(added); /** under v.c., but is missing */ public static final SVNStatusKind MISSING = new SVNStatusKind(missing); /** a directory doesn't contain a complete entries list */ public static final SVNStatusKind INCOMPLETE = new SVNStatusKind(incomplete); /** scheduled for deletion */ public static final SVNStatusKind DELETED = new SVNStatusKind(deleted); /** was deleted and then re-added */ public static final SVNStatusKind REPLACED = new SVNStatusKind(replaced); /** text or props have been modified */ public static final SVNStatusKind MODIFIED = new SVNStatusKind(modified); /** local mods received repos mods */ public static final SVNStatusKind MERGED = new SVNStatusKind(merged); /** local mods received conflicting repos mods */ public static final SVNStatusKind CONFLICTED = new SVNStatusKind(conflicted); /** an unversioned resource is in the way of the versioned resource */ public static final SVNStatusKind OBSTRUCTED = new SVNStatusKind(obstructed); /** a resource marked as ignored */ public static final SVNStatusKind IGNORED = new SVNStatusKind(ignored); /** an unversioned path populated by an svn:external property */ public static final SVNStatusKind EXTERNAL = new SVNStatusKind(external); /** is not a versioned thing in this wc */ public static final SVNStatusKind UNVERSIONED = new SVNStatusKind(unversioned); //Constructors /** *

* Constructs a Type for the given a type name.

* * * @param type Name of the type. * @throws IllegalArgumentException If the parameter is invalid. */ private SVNStatusKind(int kind) throws IllegalArgumentException { this.kind = kind; } /** * @return an integer value representation of the statusKind */ public int toInt() { return kind; } public void setTreeConflicted(boolean treeConflicted) { this.treeConflicted = treeConflicted; } public boolean hasTreeConflict() { return treeConflicted; } /** * Returns the SVNStatusKind corresponding to the given int representation. * (As returned by {@link SVNStatusKind#toInt()} method) * @param kind * @return SVNStatusKind representing the int value */ public static SVNStatusKind fromInt(int kind) { switch (kind) { case none: return NONE; case normal: return NORMAL; case added: return ADDED; case missing: return MISSING; case deleted: return DELETED; case replaced: return REPLACED; case modified: return MODIFIED; case merged: return MERGED; case conflicted: return CONFLICTED; case ignored: return IGNORED; case incomplete: return INCOMPLETE; case external: return EXTERNAL; case unversioned: return UNVERSIONED; case obstructed: return OBSTRUCTED; default: return null; } } /** * returns the SVNStatusKind corresponding to the given string or null * @param kind * @return SVNStatusKind representing the supplied string value */ public static SVNStatusKind fromString(String kind) { if ("none".equals(kind) || "non-svn".equals(kind)) { return NONE; } else if ("normal".equals(kind)) { return NORMAL; } else if ("added".equals(kind)) { return ADDED; } else if ("missing".equals(kind)) { return MISSING; } else if ("deleted".equals(kind)) { return DELETED; } else if ("replaced".equals(kind)) { return REPLACED; } else if ("modified".equals(kind)) { return MODIFIED; } else if ("merged".equals(kind)) { return MERGED; } else if ("conflicted".equals(kind)) { return CONFLICTED; } else if ("ignored".equals(kind)) { return IGNORED; } else if ("incomplete".equals(kind)) { return INCOMPLETE; } else if ("external".equals(kind)) { return EXTERNAL; } else if ("unversioned".equals(kind)) { return UNVERSIONED; } else if ("obstructed".equals(kind)) { return OBSTRUCTED; } else { throw new IllegalArgumentException("Unknown status " + kind); } } /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { switch (kind) { case none: return "non-svn"; case normal: return "normal"; case added: return "added"; case missing: return "missing"; case deleted: return "deleted"; case replaced: return "replaced"; case modified: return "modified"; case merged: return "merged"; case conflicted: return "conflicted"; case ignored: return "ignored"; case incomplete: return "incomplete"; case external: return "external"; case obstructed: return "obstructed"; case unversioned: default: return "unversioned"; } } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object obj) { if (!(obj instanceof SVNStatusKind)) { return false; } return ((SVNStatusKind)obj).kind == kind; } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { return new Integer(kind).hashCode(); } }svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNStatusUnversioned.java000066400000000000000000000146071203563747500335100ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.io.File; import java.util.Date; /** * A special {@link ISVNStatus} implementation that is used if a File/Folder is not versioned or is ignored. * * @author Philip Schatz (schatz at tigris) * @author Cédric Chabanois (cchabanois at no-log.org) */ public class SVNStatusUnversioned implements ISVNStatus { private File file; private boolean isIgnored = false; /** * Constructor. * @param file * @param isIgnored true when creating {@link SVNStatusKind#IGNORED}, otherwise {@link SVNStatusKind#UNVERSIONED} */ public SVNStatusUnversioned(File file, boolean isIgnored) { this.file = file; // A file can be both unversioned and ignored. this.isIgnored = isIgnored; } /** * Constructor. * Creates an unversioned status (i.e. not ignored) * @param file */ public SVNStatusUnversioned(File file) { this.file = file; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getPath() */ public String getPath() { return file.getPath(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getFile() */ public File getFile() { return file.getAbsoluteFile(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getUrl() */ public SVNUrl getUrl() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getUrlString() */ public String getUrlString() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLastChangedRevision() */ public SVNRevision.Number getLastChangedRevision() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLastChangedDate() */ public Date getLastChangedDate() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLastCommitAuthor() */ public String getLastCommitAuthor() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getTextStatus() */ public SVNStatusKind getTextStatus() { if (isIgnored) { return SVNStatusKind.IGNORED; } return SVNStatusKind.UNVERSIONED; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getPropStatus() */ public SVNStatusKind getPropStatus() { //As this status does not describe a managed resource, we //cannot pretend that there is property status, and thus always //{@link SVNStatusKind#NONE}. return SVNStatusKind.NONE; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getRepositoryTextStatus() */ public SVNStatusKind getRepositoryTextStatus() { return SVNStatusKind.UNVERSIONED; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getRepositoryPropStatus() */ public SVNStatusKind getRepositoryPropStatus() { return SVNStatusKind.UNVERSIONED; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getRevision() */ public SVNRevision.Number getRevision() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#isCopied() */ public boolean isCopied() { return false; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#isWcLocked() */ public boolean isWcLocked() { return false; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#isSwitched() */ public boolean isSwitched() { return false; } /* (non-Javadoc) * @see * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getNodeKind() */ public SVNNodeKind getNodeKind() { //As this status does not describe a managed resource, we //cannot pretend to know the node kind, and thus always return //{@link SVNNodeKind#UNKNOWN}. return SVNNodeKind.UNKNOWN; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getConflictNew() */ public File getConflictNew() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getConflictOld() */ public File getConflictOld() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getConflictWorking() */ public File getConflictWorking() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLockComment() */ public String getLockComment() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLockCreationDate() */ public Date getLockCreationDate() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getLockOwner() */ public String getLockOwner() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#getConflictDescriptor() */ public SVNConflictDescriptor getConflictDescriptor() { return null; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#hasTreeConflict() */ public boolean hasTreeConflict() { // TODO Auto-generated method stub return false; } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.ISVNStatus#isFileExternal() */ public boolean isFileExternal() { return false; } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/SVNUrl.java000066400000000000000000000237641203563747500305510ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import org.tigris.subversion.svnclientadapter.utils.StringUtils; /** * We could have used URL, using custom protocols (svn, svn+ssl) * (@see http://developer.java.sun.com/developer/onlineTraining/protocolhandlers/) * but this is not really necessary as we don't want to open a connection * directly with this class. * We just want a string which represent a SVN url which can be used with our JNI * methods. * * An SVNUrl is immutable. * * @author C�dric Chabanois * cchabanois@ifrance.com * */ public class SVNUrl { private static final String SVN_PROTOCOL = "svn"; private static final String SVNSSH_PROTOCOL = "svn+"; private static final String HTTP_PROTOCOL = "http"; private static final String HTTPS_PROTOCOL = "https"; private static final String FILE_PROTOCOL = "file"; protected static final char SEGMENT_SEPARATOR = '/'; private String protocol; // http, file, svn or svn+ssh private String[] segments; private String host; private int port; /** * Constructor * @param svnUrl a string to parse url from * @throws MalformedURLException when parsing failed */ public SVNUrl(String svnUrl) throws MalformedURLException { if(svnUrl == null) throw new MalformedURLException("Svn url cannot be null. Is this a versioned resource?"); parseUrl(svnUrl.trim()); } private SVNUrl(String protocol, String host, int port, String[] segments) { super(); this.protocol = protocol; this.host = host; this.port = port; this.segments = segments; } /** * Asnwer a new SVNUrl with added segments * @param path a String of path segment(s) to ba appended to receiver * @return new SVNUrl */ public SVNUrl appendPath(String path) { String[] segmentsToAdd = StringUtils.split(path, SEGMENT_SEPARATOR); //Skip the starting slash if ((segmentsToAdd.length > 0) && (segmentsToAdd[0].equals(""))) { String[] newSegmentsToAdd = new String[segmentsToAdd.length - 1]; System.arraycopy(segmentsToAdd, 1, newSegmentsToAdd, 0, segmentsToAdd.length - 1); segmentsToAdd = newSegmentsToAdd; } String[] newSegments = new String[segments.length + segmentsToAdd.length]; System.arraycopy(segments, 0, newSegments, 0, segments.length); System.arraycopy(segmentsToAdd, 0, newSegments, segments.length, segmentsToAdd.length); return new SVNUrl(this.protocol, this.host, this.port, newSegments); } /** * verifies that the url is correct * @throws MalformedURLException */ private void parseUrl(String svnUrl) throws MalformedURLException{ String parsed = svnUrl; // SVNUrl have this format : // scheme://host[:port]/path // parse protocol int i = parsed.indexOf("://"); if (i == -1) throw new MalformedURLException("Invalid svn url: "+svnUrl); protocol = parsed.substring(0,i).toLowerCase(); if ((!protocol.equalsIgnoreCase(HTTP_PROTOCOL)) && (!protocol.equalsIgnoreCase(HTTPS_PROTOCOL)) && (!protocol.equalsIgnoreCase(FILE_PROTOCOL)) && (!protocol.equalsIgnoreCase(SVN_PROTOCOL)) && (!protocol.startsWith(SVNSSH_PROTOCOL)) ) { throw new MalformedURLException("Invalid svn url: "+svnUrl); } parsed = parsed.substring(i+3); if (parsed.length() == 0) { throw new MalformedURLException("Invalid svn url: "+svnUrl); } // parse host & port i = parsed.indexOf("/"); if (i == -1) { i = parsed.length(); } if (!protocol.equalsIgnoreCase(FILE_PROTOCOL)) { String hostPort = parsed.substring(0,i).toLowerCase(); String[] hostportArray = StringUtils.split(hostPort,':'); if (hostportArray.length == 0) { throw new MalformedURLException("Invalid svn url: "+svnUrl); } else if (hostportArray.length == 2) { this.host = hostportArray[0]; try { this.port = Integer.parseInt(hostportArray[1]); } catch (NumberFormatException e) { throw new MalformedURLException("Invalid svn url: "+svnUrl); } } else { this.host = hostportArray[0]; this.port = getDefaultPort(protocol); } } else { this.port = -1; // parse path if (i == 0) { this.host = ""; } else { this.host = parsed.substring(0,i); } } // parse path if (i < parsed.length()) { parsed = parsed.substring(i+1); } else { parsed = ""; } segments = StringUtils.split(parsed,'/'); } /** * get the default port for given protocol * @param protocol * @return port number or -1 if protocol is unknown */ public static int getDefaultPort(String protocol) { int port = -1; if (SVN_PROTOCOL.equals(protocol)) { port = 3690; } else if (HTTP_PROTOCOL.equals(protocol)) { port = 80; } else if (HTTPS_PROTOCOL.equals(protocol)) { port = 443; } else if (protocol != null && protocol.startsWith(SVNSSH_PROTOCOL)) { port = 22; } return port; } /** * Get the url as String. The url returned never ends with "/" * @return String representation of this url instance */ private String get() { //Be sofisticated and compute the StringBuffer size up-front. StringBuffer buffer = new StringBuffer(calculateUrlLength()); buffer.append(getProtocol()); buffer.append("://"); buffer.append(getHost()); if (getPort() != getDefaultPort(getProtocol())) { buffer.append(":"); buffer.append(getPort()); } for (int i = 0; i < segments.length;i++) { buffer.append(SEGMENT_SEPARATOR); buffer.append(segments[i]); } return buffer.toString(); } private int calculateUrlLength() { int result = 3; // Size of "://" if (getProtocol() != null) result += getProtocol().length(); if (getHost() != null) result += getHost().length(); if (getPort() != getDefaultPort(getProtocol())) { result++; //Add one for ":" result += String.valueOf(getPort()).length(); } for (int i = 0; i < segments.length;i++) { result++; // Add 1 for separator result += segments[i].length(); } return result; } /** * get the protocol * @return either http, https, file, svn or svn+ssh */ public String getProtocol() { return protocol; } /** * @return Returns the host. */ public String getHost() { return host; } /** * @return Returns the port. */ public int getPort() { return port; } /** * get the path of the url. * @return an arrray of url path segments */ public String[] getPathSegments() { return segments; } /** * @return the "file" name, i.e. the element after last / */ public String getLastPathSegment() { if (segments.length == 0) return ""; return segments[segments.length-1]; } /** * Return new SVNUrl which represents parent of the receiver * @return the parent url or null if no parent */ public SVNUrl getParent() { if ((segments.length == 0) || ((segments.length == 1) && ((host == null) || (host.length() == 0)))) { return null; } String[] parentSegments = new String[segments.length - 1]; System.arraycopy(segments, 0, parentSegments, 0, segments.length - 1); return new SVNUrl(this.protocol, this.host, this.port, parentSegments); } /* (non-Javadoc) * @see java.lang.Object#equals(java.lang.Object) */ public boolean equals(Object target) { // this method is not very accurate because : // url before repository is not always case sensitive if (this == target) return true; if (!(target instanceof SVNUrl)) return false; SVNUrl url = (SVNUrl) target; return get().equals(url.get()); } /* (non-Javadoc) * @see java.lang.Object#hashCode() */ public int hashCode() { return get().hashCode(); } /* (non-Javadoc) * @see java.lang.Object#toString() */ public String toString() { // The URI class will throw Exception if there are spaces in the URL, but it seems // to handle other classes OK. I tested with @ + and Unicode characters. It leaves // the @ and + alone and converts Unicode to %nn. It is possible there are other // characters we need to replace here besides space. String s = get().replaceAll(" ", "%20"); try { URI u = new URI(s); return u.toASCIIString(); } catch (URISyntaxException e) { return s; } } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/messages.properties000066400000000000000000000103721203563747500324710ustar00rootroot00000000000000#****************************************************************************** # Copyright (c) 2005, 2006 svnClientAdapter project and others. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Contributors: # svnClientAdapter project committers - initial API and implementation #******************************************************************************/ notify.skipped=Skipped {0} notify.update.skip.obstruction=Skipped {0} because of working copy obstruction. notify.update.skip.working.only=Skipped {0} because it is working only. notify.update.skip.access.denied=Skipped {0} because access could not be obtained. notify.out.of.date=Operation failed because {0} is out of date -- try updating. notify.conflict=Operation failed because {0} remains in conflict. notify.external=Operation failed because {0} is a subdirectory referenced in an externals definition which is unable to be operated on. notify.locked=Operation failed because {0} is locked. notify.path.nonexistent=Operation failed because {0} does not exist. notify.lock.failed=Failed to lock {0} notify.missing=Operation failed because {0} is missing. notify.no.parent=Operation failed because an added parent is not selected. notify.forbidden.by.server=Operation failed because it was forbidden by server. notify.copy=Copying {0} notify.changelist.set=Changelist set for {0} notify.changelist.clear=Changelist cleared for {0} notify.changelist.moved=Changelist moved for {0} notify.unlock.failed=Failed to unlock {0} notify.lock.other={0} locked by user {1} notify.lock={0} locked notify.unlock={0} unlocked notify.restored=Restored {0} notify.reverted=Reverted {0} notify.upgraded.path=Upgraded {0} notify.exclude={0} excluded notify.revert.failed=Failed to revert {0} -- try updating instead. notify.resolved=Resolved conflicted state of {0} notify.update.external=Updating external location at: {0} notify.update.external.removed=Removed external location {0} notify.patch=A file in the working copy was patched. notify.patch.applied.hunk=Hunk from patch applied to {0} notify.patch.rejected.hunk=Hunk from patch to {0} rejected. notify.patch.hunk.already.applied=Hunk from patch has already been applied to {0} notify.export=Exported revision {0}. notify.checkout=Checked out revision {0}. notify.update=Updated to revision {0}. notify.at=At revision {0}. notify.export.complete=Export complete. notify.checkout.complete=Checkout complete. notify.update.complete=Update complete. notify.import.complete=Import complete. notify.status.external=Performing status on external item at {0} notify.status.revision=Status against revision: {0} notify.commit.modified=Sending {0} notify.commit.add=Adding {0} notify.commit.delete=Deleting {0} notify.commit.replace=Replacing {0} notify.commit.transmit=Transmitting file data ... notify.commit=Committed revision {0}. notify.stats.file.head====== File Statistics: ===== notify.stats.prop.head===== Property Statistics: ===== notify.stats.conflict.head===== Conflict Statistics: ===== notify.stats.conflict= File conflicts: {0} notify.stats.merge= Merged: {0} notify.stats.delete= Deleted: {0} notify.stats.add= Added: {0} notify.stats.update= Updated: {0} notify.stats.exists= Existing: {0} notify.stats.prop.conflicts= Property conflicts: {0} notify.stats.tree.conflicts= Tree conflicts: {0} notify.commit.abnormal=svn: Commit failed (details follow): notify.end.abnormal=Command completed abnormally. notify.property.set=Property set on {0} notify.property.deleted=Property deleted from {0} notify.property.deleted.nonexistent=Attempting to delete nonexistent property notify.revision.property.set=Property set on repository revision notify.revision.property.deleted=Property deleted from repository revision notify.merge.record.info=Merge info recorded for {0}svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/utils/000077500000000000000000000000001203563747500277015ustar00rootroot00000000000000svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/utils/Command.java000066400000000000000000000053031203563747500321230ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.utils; import java.io.IOException; import java.io.OutputStream; /** * execute a command. Some parts of this class come from SVNKit */ public class Command { private Process process = null; private String command; private String[] parameters = new String[] {}; private OutputStream out = System.out; private OutputStream err = System.err; public Command(String command) { this.command = command; } /** * @param err * The err to set. */ public void setErr(OutputStream err) { this.err = err; } /** * @param out * The out to set. */ public void setOut(OutputStream out) { this.out = out; } /** * @param parameters The parameters to set. */ public void setParameters(String[] parameters) { this.parameters = parameters; } /** * @return Returns the process. */ public Process getProcess() { return process; } public void kill() { if (process != null) { process.destroy(); process = null; } } public void exec() throws IOException { String[] cmdArray= new String[parameters.length+1]; cmdArray[0] = command; System.arraycopy(parameters,0,cmdArray,1,parameters.length); process = Runtime.getRuntime().exec(cmdArray); if (process != null) { new ReaderThread(process.getInputStream(), out).start(); new ReaderThread(process.getErrorStream(), err).start(); process.getOutputStream().close(); } } /** * * causes the current thread to wait, if necessary, until the process * represented by this Command object has terminated * * @return the exit value of the process. By convention, 0 * indicates normal termination. * @throws InterruptedException */ public int waitFor() throws InterruptedException { return process.waitFor(); } }svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/utils/Depth.java000066400000000000000000000032311203563747500316070ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2007 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.utils; public class Depth { /** Depth undetermined or ignored. */ public static final int unknown = 0; /** Exclude (remove, whatever) directory D. */ public static final int exclude = 1; /** Just the named directory D, no entries. */ public static final int empty = 2; /** D + its file children, but not subdirs. */ public static final int files = 3; /** D + immediate children (D and its entries). */ public static final int immediates = 4; /** D + all descendants (full recursion from D). */ public static final int infinity = 5; public static final int fromRecurse(boolean recurse) { if (recurse) return infinity; else return files; } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/utils/Messages.java000066400000000000000000000061151203563747500323160ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.utils; import java.text.MessageFormat; import java.util.MissingResourceException; import java.util.ResourceBundle; /** * A helper class used for binding NLS supported message strings * */ public class Messages { private static final String BUNDLE_NAME = "org.tigris.subversion.svnclientadapter.messages"; //$NON-NLS-1$ protected static ResourceBundle bundle = null; private static ResourceBundle getResourceBundle() { if (bundle == null) { bundle = ResourceBundle.getBundle(BUNDLE_NAME); } return bundle; } /** * Lookup the message with the given ID in this catalog and bind its * substitution locations with the given string. * @param id * @param binding * @return the message with substitutions applied */ public static String bind(String id, String binding) { return bind(id, new String[] { binding }); } /** * Lookup the message with the given ID in this catalog and bind its * substitution locations with the given strings. * @param id * @param binding1 * @param binding2 * @return the message with substitutions applied */ public static String bind(String id, String binding1, String binding2) { return bind(id, new String[] { binding1, binding2 }); } /** * Gets a string from the resource bundle. We don't want to crash because of a missing String. * @param key * @return string from the resource bundle or the key if not found. */ public static String bind(String key) { try { return getResourceBundle().getString(key); } catch (MissingResourceException e) { return key; } catch (NullPointerException e) { return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ } } /** * Gets a string from the resource bundle and binds it with the given arguments. If the key is * not found, return the key. * @param key * @param args * @return string with substitutions from the resource bundle or the key if not found. */ public static String bind(String key, Object[] args) { try { return MessageFormat.format(bind(key), args); } catch (MissingResourceException e) { return key; } catch (NullPointerException e) { return "!" + key + "!"; //$NON-NLS-1$ //$NON-NLS-2$ } } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/utils/ReaderThread.java000066400000000000000000000035341203563747500331030ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.utils; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; /** * This class has been taken from SVNKit */ public class ReaderThread extends Thread { private final InputStream myInputStream; private final OutputStream myOutputStream; public ReaderThread(InputStream is, OutputStream os) { myInputStream = is; myOutputStream = os; setDaemon(true); } public void run() { try { while(true) { int read = myInputStream.read(); if (read < 0) { return; } myOutputStream.write(read); } } catch (IOException e) { } finally { try { myInputStream.close(); myOutputStream.flush(); } catch (IOException e) { //Just ignore. Stream closing. } } } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/utils/SVNStatusUtils.java000066400000000000000000000111031203563747500334330ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.utils; import org.tigris.subversion.svnclientadapter.ISVNStatus; import org.tigris.subversion.svnclientadapter.SVNStatusKind; /** * Some static methods to deal with svn status * * @author cedric chabanois (cchab at tigris.org) */ public class SVNStatusUtils { /** * @param textStatus The status information to examine * (non-null). * @return Whether textStatus denotes a versioned * resource. */ public static boolean isManaged(SVNStatusKind textStatus) { return (!textStatus.equals(SVNStatusKind.UNVERSIONED) && !textStatus.equals(SVNStatusKind.NONE) && !textStatus.equals(SVNStatusKind.IGNORED)); } /** * Returns if is managed by svn (added, normal, modified ...) * @param status * * @return if managed by svn */ public static boolean isManaged(ISVNStatus status) { return isManaged(status.getTextStatus()); } /** * Returns if the resource has a remote counter-part * @param status * * @return has version in repository */ public static boolean hasRemote(ISVNStatus status) { SVNStatusKind textStatus = status.getTextStatus(); return ((isManaged(textStatus)) && (!textStatus.equals(SVNStatusKind.ADDED) || status.isCopied())); } public static boolean isAdded(ISVNStatus status) { return status.getTextStatus().equals(SVNStatusKind.ADDED); } public static boolean isDeleted(ISVNStatus status) { return status.getTextStatus().equals(SVNStatusKind.DELETED); } public static boolean isReplaced(ISVNStatus status) { return status.getTextStatus().equals(SVNStatusKind.REPLACED); } public static boolean isMissing(ISVNStatus status) { return status.getTextStatus().equals(SVNStatusKind.MISSING); } public static boolean isIgnored(ISVNStatus status) { return status.getTextStatus().equals(SVNStatusKind.IGNORED); } public static boolean isTextMerged(ISVNStatus status) { return status.getTextStatus().equals(SVNStatusKind.MERGED); } public static boolean isTextModified(ISVNStatus status) { return status.getTextStatus().equals(SVNStatusKind.MODIFIED); } public static boolean isTextConflicted(ISVNStatus status) { return status.getTextStatus().equals(SVNStatusKind.CONFLICTED); } public static boolean isPropModified(ISVNStatus status) { return status.getPropStatus().equals(SVNStatusKind.MODIFIED); } public static boolean isPropConflicted(ISVNStatus status) { return status.getPropStatus().equals(SVNStatusKind.CONFLICTED); } /** * Answer whether the status is "outgoing", i.e. whether resource with such status could/should be commited * @param status * @return true when the status represents "outgoing" state */ public static boolean isReadyForCommit(ISVNStatus status) { return isTextModified(status) || isAdded(status) || isDeleted(status) || isReplaced(status) || isPropModified(status) || isTextConflicted(status) || isPropConflicted(status) || (!isManaged(status) && !isIgnored(status)); } /** * Answer whether the status was "changed", i.e. whether resource with such status could/should be reverted * @param status * @return true when the status represents "changed" state */ public static boolean isReadyForRevert(ISVNStatus status) { return isTextModified(status) || isAdded(status) || isDeleted(status) || isMissing(status) || isReplaced(status) || isPropModified(status) || isTextConflicted(status) || isPropConflicted(status); } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/utils/SVNUrlUtils.java000066400000000000000000000155221203563747500327230ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.utils; import java.net.MalformedURLException; import org.tigris.subversion.svnclientadapter.SVNUrl; /** * Utility class */ public class SVNUrlUtils { /** * get the common root url for given urls * @param url1 * @param url2 * @return the common root url for given urls */ public static SVNUrl getCommonRootUrl(SVNUrl url1, SVNUrl url2) { if ( (!url1.getProtocol().equals(url2.getProtocol())) || (!url1.getHost().equals(url2.getHost())) || (url1.getPort() != url2.getPort()) ) { return null; } String url = url1.getProtocol()+"://"+url1.getHost()+":"+url1.getPort(); String[] segs1 = url1.getPathSegments(); String[] segs2 = url2.getPathSegments(); int minLength = segs1.length >= segs2.length ? segs2.length : segs1.length; for (int i = 0; i < minLength; i++) { if (!segs1[i].equals(segs2[i])) { break; } url+="/"+segs1[i]; } try { return new SVNUrl(url); } catch (MalformedURLException e) { return null; } } /** * get the common root url for given urls * @param urls * @return the common root url for given urls */ public static SVNUrl getCommonRootUrl(SVNUrl urls[]) { SVNUrl commonRoot = urls[0]; for (int i = 0; i < urls.length; i++) { commonRoot = getCommonRootUrl(commonRoot, urls[i]); if (commonRoot == null) { return null; } } return commonRoot; } /** * Get path of url relative to rootUrl * @param rootUrl * @param url * @return relative path or null if rootUrl is not a parent of url */ public static String getRelativePath(SVNUrl rootUrl, SVNUrl url) { return getRelativePath(rootUrl, url, false); } /** * Get path of url relative to rootUrl * @param rootUrl * @param url * @param includeStartingSlash whether the realtive url should start with / or not * @return relative path or null if rootUrl is not a parent of url */ public static String getRelativePath(SVNUrl rootUrl, SVNUrl url, boolean includeStartingSlash ) { //TODO Isn't there a more efficient way than to convert those urls to Strings ? String rootUrlStr = rootUrl.toString(); String urlStr = url.toString(); if (urlStr.indexOf(rootUrlStr) == -1) { return null; } if (urlStr.length() == rootUrlStr.length()) { return ""; } return urlStr.substring(rootUrlStr.length() + (includeStartingSlash ? 0 : 1)); } /** * Get url representing the fileName of working copy. * Use the parent's (not necesarily direct parent) WC fileName and SVNUrl to calculate it. * E.g. * * SVNUrl rootUrl = new SVNUrl("http://svn.collab.net:81/repos/mydir"); * String rootPath = "C:\\Documents and Settings\\User\\My Documents\\Eclipse\\mydir"; * String filePath = "C:\\Documents and Settings\\User\\My Documents\\Eclipse\\mydir\\mydir2\\myFile.txt"; * SVNUrl expected = new SVNUrl("http://svn.collab.net:81/repos/mydir/mydir2/myFile.txt"); * assertEquals(expected,SVNUrlUtils.getUrlFromLocalFileName(filePath, rootUrl, rootPath)); * * * @param localFileName name of the file representing working copy of resource * @param parentUrl svnUrl of a resource preceeding the localFileName in hierarchy * @param parentPathName WC fileName of a resource preceeding the localFileName in hierarchy * @return url representing the fileName of working copy. */ public static SVNUrl getUrlFromLocalFileName(String localFileName, SVNUrl parentUrl, String parentPathName) { return getUrlFromLocalFileName(localFileName, parentUrl.toString(), parentPathName); } /** * Get url representing the fileName of working copy. * Use the parent's (not necesarily direct parent) WC fileName and SVNUrl to calculate it. * E.g. * * SVNUrl rootUrl = new SVNUrl("http://svn.collab.net:81/repos/mydir"); * String rootPath = "C:\\Documents and Settings\\User\\My Documents\\Eclipse\\mydir"; * String filePath = "C:\\Documents and Settings\\User\\My Documents\\Eclipse\\mydir\\mydir2\\myFile.txt"; * SVNUrl expected = new SVNUrl("http://svn.collab.net:81/repos/mydir/mydir2/myFile.txt"); * assertEquals(expected,SVNUrlUtils.getUrlFromLocalFileName(filePath, rootUrl, rootPath)); * * * @param localFileName name of the file representing working copy of resource * @param parentUrl url string of a resource preceeding the localFileName in hierarchy * @param parentPathName WC fileName of a resource preceeding the localFileName in hierarchy * @return url representing the fileName of working copy. */ public static SVNUrl getUrlFromLocalFileName(String localFileName, String parentUrl, String parentPathName) { String parentPath = (parentPathName.indexOf('\\') > 0) ? parentPathName.replaceAll("\\\\","/") : parentPathName; String localFile = (localFileName.indexOf('\\') > 0) ? localFileName.replaceAll("\\\\","/") : localFileName; try { if (localFile.indexOf(parentPath) != 0) return null; if (localFile.length() == parentPath.length()) return new SVNUrl(parentUrl); char lastChar = parentPath.charAt(parentPath.length() - 1); String relativeFileName = localFile.substring(parentPath.length() + (((lastChar != '\\') && (lastChar != '/')) ? 1 : 0)); if (parentUrl.charAt(parentUrl.length()-1) == '/') { return new SVNUrl(parentUrl + relativeFileName); } else { return new SVNUrl(parentUrl + "/" + relativeFileName); } } catch (MalformedURLException e) { return null; } } } svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/utils/StringUtils.java000066400000000000000000000076651203563747500330510ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.utils; import java.util.ArrayList; import java.util.List; /** * A helper class for various string operations * */ public class StringUtils { /** * we can't use String.split as it is a JDK 1.4 method. * //TODO Java 1.4 is not aproblem anymore. Isn't it ? * @param str * @param separator * @return an array of string segments */ static public String[] split(String str, char separator) { int pos = 0; List list = new ArrayList(); int length = str.length(); for (int i = 0; i < length;i++) { char ch = str.charAt(i); if (ch == separator) { list.add(str.substring(pos,i)); pos = i+1; } } if (pos != length) { list.add(str.substring(pos,length)); } return (String[])list.toArray(new String[list.size()]); } /** * split using a string separator * @param str * @param separator * @return an array of string segments */ static public String[] split(String str, String separator) { List list = new ArrayList(); StringBuffer sb = new StringBuffer(str); int pos; while ((pos = sb.indexOf(separator)) != -1) { list.add(sb.substring(0,pos)); sb.delete(0,pos+separator.length()); } if (sb.length() > 0) { list.add(sb.toString()); } return (String[])list.toArray(new String[list.size()]); } // the following method has been taken from commons-lang StringUtils class /** *

Strips any of a set of characters from the start of a String.

* *

A null input String returns null. * An empty string ("") input returns the empty string.

* *

If the stripChars String is null, whitespace is * stripped as defined by {@link Character#isWhitespace(char)}.

* *
     * StringUtils.stripStart(null, *)          = null
     * StringUtils.stripStart("", *)            = ""
     * StringUtils.stripStart("abc", "")        = "abc"
     * StringUtils.stripStart("abc", null)      = "abc"
     * StringUtils.stripStart("  abc", null)    = "abc"
     * StringUtils.stripStart("abc  ", null)    = "abc  "
     * StringUtils.stripStart(" abc ", null)    = "abc "
     * StringUtils.stripStart("yxabc  ", "xyz") = "abc  "
     * 
* * @param str the String to remove characters from, may be null * @param stripChars the characters to remove, null treated as whitespace * @return the stripped String, null if null String input */ public static String stripStart(String str, String stripChars) { int strLen; if (str == null || (strLen = str.length()) == 0) { return str; } int start = 0; if (stripChars == null) { while ((start != strLen) && Character.isWhitespace(str.charAt(start))) { start++; } } else if (stripChars.length() == 0) { return str; } else { while ((start != strLen) && (stripChars.indexOf(str.charAt(start)) != -1)) { start++; } } return str.substring(start); } } svnclientadapter-1.8.16/src/samples/000077500000000000000000000000001203563747500174245ustar00rootroot00000000000000svnclientadapter-1.8.16/src/samples/org/000077500000000000000000000000001203563747500202135ustar00rootroot00000000000000svnclientadapter-1.8.16/src/samples/org/tigris/000077500000000000000000000000001203563747500215145ustar00rootroot00000000000000svnclientadapter-1.8.16/src/samples/org/tigris/subversion/000077500000000000000000000000001203563747500237135ustar00rootroot00000000000000svnclientadapter-1.8.16/src/samples/org/tigris/subversion/svnclientadapter/000077500000000000000000000000001203563747500272615ustar00rootroot00000000000000svnclientadapter-1.8.16/src/samples/org/tigris/subversion/svnclientadapter/samples/000077500000000000000000000000001203563747500307255ustar00rootroot00000000000000svnclientadapter-1.8.16/src/samples/org/tigris/subversion/svnclientadapter/samples/Sample.java000066400000000000000000000115571203563747500330220ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.samples; import java.io.File; import java.io.IOException; import java.io.InputStream; import org.tigris.subversion.svnclientadapter.ISVNClientAdapter; import org.tigris.subversion.svnclientadapter.ISVNNotifyListener; import org.tigris.subversion.svnclientadapter.SVNClientAdapterFactory; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.commandline.CmdLineClientAdapterFactory; import org.tigris.subversion.svnclientadapter.javahl.JhlClientAdapterFactory; /** * A very simple sample * see svnant task for more samples and unit tests * * @author Cédric Chabanois (cchabanois at no-log.org) */ public class Sample { public static class NotifyListener implements ISVNNotifyListener { public void setCommand(int cmd) { // the command that is being executed. See ISVNNotifyListener.Command // ISVNNotifyListener.Command.ADD for example } public void logMessage(String message) { System.out.println(message); } public void logCommandLine(String message) { // the command line used System.out.println(message); } public void logError(String message) { // when an error occurs System.out.println("error :" +message); } public void logRevision(long revision, String path) { // when command completes against revision System.out.println("revision :" +revision); } public void logCompleted(String message) { // when command completed System.out.println(message); } public void onNotify(File path, SVNNodeKind nodeKind) { // each time the status of a file or directory changes (file added, reverted ...) // nodeKind is SVNNodeKind.FILE or SVNNodeKind.DIR // this is the function we use in subclipse to know which files need to be refreshed System.out.println("Status of "+path.toString()+" has changed"); } } public void setup() { try { JhlClientAdapterFactory.setup(); } catch (SVNClientException e) { // can't register this factory } try { CmdLineClientAdapterFactory.setup(); } catch (SVNClientException e1) { // can't register this factory } } public void run() { // register the factories setup(); // first create the SVNClient from factory // SVNClientAdapterFactory.JAVAHL_CLIENT to use JNI client (recommanded) // SVNClientAdapterFactory.COMMANDLINE_CLIENT to use command line client // You can also get the best client type interface using getBestSVNClientType ISVNClientAdapter svnClient; try { String bestClientType = SVNClientAdapterFactory.getPreferredSVNClientType(); System.out.println("Using "+bestClientType+" factory"); svnClient = SVNClientAdapterFactory.createSVNClient(bestClientType); } catch (SVNClientException e) { System.out.println(e.getMessage()); return; } // set username and password if necessary svnClient.setUsername("guest"); svnClient.setPassword(" "); // add a listener if you wish NotifyListener listener = new Sample.NotifyListener(); svnClient.addNotifyListener(listener); try { // use the svn commands InputStream is = svnClient.getContent(new SVNUrl("http://subclipse.tigris.org/svn/subclipse/trunk/svnClientAdapter/readme.txt"),SVNRevision.HEAD); System.out.println("The beginning of the file is :"); byte[] bytes = new byte[100]; is.read(bytes); System.out.println(new String(bytes)); } catch (IOException e) { System.out.println("An exception occured while getting remote file :"+e.getMessage()); } catch (SVNClientException e) { System.out.println("An exception occured while getting remote file :"+e.getMessage()); } } public static void main(String[] args) { Sample sample = new Sample(); sample.run(); } } svnclientadapter-1.8.16/src/svnkit/000077500000000000000000000000001203563747500172765ustar00rootroot00000000000000svnclientadapter-1.8.16/src/svnkit/org/000077500000000000000000000000001203563747500200655ustar00rootroot00000000000000svnclientadapter-1.8.16/src/svnkit/org/tigris/000077500000000000000000000000001203563747500213665ustar00rootroot00000000000000svnclientadapter-1.8.16/src/svnkit/org/tigris/subversion/000077500000000000000000000000001203563747500235655ustar00rootroot00000000000000svnclientadapter-1.8.16/src/svnkit/org/tigris/subversion/svnclientadapter/000077500000000000000000000000001203563747500271335ustar00rootroot00000000000000svnclientadapter-1.8.16/src/svnkit/org/tigris/subversion/svnclientadapter/svnkit/000077500000000000000000000000001203563747500304515ustar00rootroot00000000000000SvnKitClientAdapter.java000066400000000000000000000124241203563747500351160ustar00rootroot00000000000000svnclientadapter-1.8.16/src/svnkit/org/tigris/subversion/svnclientadapter/svnkit/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.svnkit; import java.io.File; import org.tigris.subversion.svnclientadapter.ISVNPromptUserPassword; import org.tigris.subversion.svnclientadapter.ISVNStatus; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNStatusUnversioned; import org.tigris.subversion.svnclientadapter.javahl.AbstractJhlClientAdapter; import org.tigris.subversion.svnclientadapter.javahl.JhlNotificationHandler; import org.tigris.subversion.svnclientadapter.javahl.JhlProgressListener; import org.tmatesoft.svn.core.SVNException; import org.tmatesoft.svn.core.io.SVNRepositoryFactory; import org.tmatesoft.svn.core.javahl17.SVNClientImpl; /** * The SVNKit Adapter works by providing an implementation of the * JavaHL SVNClientInterface. This allows to provide a common * JavaHL implementation (AbstractJhlClientAdapter) where the specific * adapters just need to initialize the correct underlying classes. * */ public class SvnKitClientAdapter extends AbstractJhlClientAdapter { public SvnKitClientAdapter() { svnClient = SVNClientImpl.newInstance(); notificationHandler = new JhlNotificationHandler(); progressListener = new JhlProgressListener(); svnClient.notification2(notificationHandler); svnClient.setPrompt(new DefaultPromptUserPassword()); svnClient.setProgressCallback(progressListener); } public boolean isThreadsafe() { return false; } public void createRepository(File path, String repositoryType) throws SVNClientException { if (REPOSITORY_FSTYPE_BDB.equalsIgnoreCase(repositoryType)) throw new SVNClientException("SVNKit only supports fsfs repository type."); try { boolean force = false; boolean enableRevisionProperties = false; SVNRepositoryFactory.createLocalRepository(path, enableRevisionProperties, force); } catch (SVNException e) { notificationHandler.logException(e); throw new SVNClientException(e); } } public void addPasswordCallback(ISVNPromptUserPassword callback) { if (callback != null) { SvnKitPromptUserPassword prompt = new SvnKitPromptUserPassword(callback); this.setPromptUserPassword(prompt); } } public boolean statusReturnsRemoteInfo() { return true; } public boolean canCommitAcrossWC() { // Native SVN now supports this with normal commit method, so support for // the special method has been removed. return false; } /** * Returns the status of files and directory recursively. * Overrides method from parent class to work around SVNKit bug when status on resource within ignored folder * does not yield any status. * * @param path File to gather status. * @param descend get recursive status information * @param getAll get status information for all files * @param contactServer contact server to get remote changes * @param ignoreExternals * * @return a Status * @throws SVNClientException */ public ISVNStatus[] getStatus(File path, boolean descend, boolean getAll, boolean contactServer, boolean ignoreExternals) throws SVNClientException { //Call the standard status first. ISVNStatus[] statuses = super.getStatus(path, descend, getAll, contactServer, ignoreExternals); //If status call return empty array it is either correct - the getAll was not specified and there's not //interesting status in WC, or it is the bug on getting status on unversioned with ignored. if (statuses.length == 0) { if (getAll) { //If the getAll was called and it returned nothing, it is probably the bug case return new ISVNStatus[] { new SVNStatusUnversioned(path) }; } else { //If the getAll was not called, we have to find out, so let's call it again with getAll set. ISVNStatus[] reCheckStatuses = super.getStatus(path, false, true, false, true); if (reCheckStatuses.length == 0) { //If event after getAll the result is empty, we assume it's the bug. return new ISVNStatus[] { new SVNStatusUnversioned(path) }; } else { //The result after getAll was not empty, so the very first empty result was OK, there's nothing interesting in WC. return new ISVNStatus[0]; } } } else { return statuses; } } } SvnKitClientAdapterFactory.java000066400000000000000000000054531203563747500364520ustar00rootroot00000000000000svnclientadapter-1.8.16/src/svnkit/org/tigris/subversion/svnclientadapter/svnkit/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.svnkit; import org.tigris.subversion.svnclientadapter.ISVNClientAdapter; import org.tigris.subversion.svnclientadapter.SVNClientAdapterFactory; import org.tigris.subversion.svnclientadapter.SVNClientException; /** * Concrete implementation of SVNClientAdapterFactory for SVNKit interface. * To register this factory, just call {@link SvnKitClientAdapterFactory#setup()} */ public class SvnKitClientAdapterFactory extends SVNClientAdapterFactory { /** Client adapter implementation identifier */ public static final String SVNKIT_CLIENT = "svnkit"; /** * Private constructor. * Clients are expected the use {@link #createSVNClientImpl()}, res. * ask the {@link SVNClientAdapterFactory} */ private SvnKitClientAdapterFactory() { super(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.SVNClientAdapterFactory#createSVNClientImpl() */ protected ISVNClientAdapter createSVNClientImpl() { return new SvnKitClientAdapter(); } /* (non-Javadoc) * @see org.tigris.subversion.svnclientadapter.SVNClientAdapterFactory#getClientType() */ protected String getClientType() { return SVNKIT_CLIENT; } public static boolean isAvailable() { try { Class c = Class.forName("org.tmatesoft.svn.core.javahl17.SVNClientImpl"); if (c != null) return true; else return false; } catch (Throwable t) { return false; } } /** * Setup the client adapter implementation and register it in the adapters factory * @throws SVNClientException */ public static void setup() throws SVNClientException { if (!isAvailable()) { throw new SVNClientException("SVNKit client adapter is not available"); } SVNClientAdapterFactory.registerAdapterFactory(new SvnKitClientAdapterFactory()); } } SvnKitPromptUserPassword.java000066400000000000000000000112721203563747500362420ustar00rootroot00000000000000svnclientadapter-1.8.16/src/svnkit/org/tigris/subversion/svnclientadapter/svnkit/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.svnkit; import org.tigris.subversion.svnclientadapter.ISVNPromptUserPassword; import org.tmatesoft.svn.core.javahl17.UserPasswordSSHCallback; import org.tmatesoft.svn.core.javahl17.UserPasswordSSLCallback; /** * A SVNKit's PromptUserPassword3 implementation. */ public class SvnKitPromptUserPassword implements UserPasswordSSHCallback, UserPasswordSSLCallback { private ISVNPromptUserPassword worker; /** * Constructor * @param arg0 */ public SvnKitPromptUserPassword(ISVNPromptUserPassword arg0) { super(); this.worker = arg0; } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword3#prompt(java.lang.String, java.lang.String, boolean) */ public boolean prompt(String realm, String username, boolean maySave) { return this.worker.prompt(realm, username, maySave); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword3#askQuestion(java.lang.String, java.lang.String, boolean, boolean) */ public String askQuestion(String realm, String question, boolean showAnswer, boolean maySave) { return this.worker.askQuestion(realm, question, showAnswer, maySave); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword3#userAllowedSave() */ public boolean userAllowedSave() { return this.worker.userAllowedSave(); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword2#askTrustSSLServer(java.lang.String, boolean) */ public int askTrustSSLServer(String info, boolean allowPermanently) { return this.worker.askTrustSSLServer(info, allowPermanently); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword#prompt(java.lang.String, java.lang.String) */ public boolean prompt(String realm, String username) { return this.prompt(realm, username, true); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword#askYesNo(java.lang.String, java.lang.String, boolean) */ public boolean askYesNo(String realm, String question, boolean yesIsDefault) { return this.worker.askYesNo(realm, question, yesIsDefault); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword#askQuestion(java.lang.String, java.lang.String, boolean) */ public String askQuestion(String realm, String question, boolean showAnswer) { return this.askQuestion(realm, question, showAnswer, true); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword#getUsername() */ public String getUsername() { return this.worker.getUsername(); } /* (non-Javadoc) * @see org.tigris.subversion.javahl.PromptUserPassword#getPassword() */ public String getPassword() { return this.worker.getPassword(); } public int getSSHPort() { return this.worker.getSSHPort(); } public String getSSHPrivateKeyPassphrase() { return this.worker.getSSHPrivateKeyPassphrase(); } public String getSSHPrivateKeyPath() { return this.worker.getSSHPrivateKeyPath(); } public boolean promptSSH(String realm, String username, int sshPort, boolean maySave) { return this.worker.promptSSH(realm, username, sshPort, maySave); } public String getSSLClientCertPassword() { return this.worker.getSSLClientCertPassword(); } public String getSSLClientCertPath() { return this.worker.getSSLClientCertPath(); } public boolean promptSSL(String realm, boolean maySave) { return this.worker.promptSSL(realm, maySave); } public boolean promptUser(String realm, String user, boolean maySave) { return this.worker.promptUser(realm, user, maySave); } } svnclientadapter-1.8.16/src/testcases/000077500000000000000000000000001203563747500177565ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/000077500000000000000000000000001203563747500205455ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/000077500000000000000000000000001203563747500220465ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/000077500000000000000000000000001203563747500242455ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/000077500000000000000000000000001203563747500276135ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/SVNBaseDirTest.java000066400000000000000000000035421203563747500332220ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.io.File; import junit.framework.TestCase; /** * This class tests SVNBaseDir */ public class SVNBaseDirTest extends TestCase { public void testBaseDir() throws Exception { File workingCopy = new File("/home/cedric/programmation/sources/test"); File currentDir = new File("/home/cedric/projects/subversion/subclipse"); File baseDir = SVNBaseDir.getCommonPart(workingCopy, currentDir); assertEquals(new File("/home/cedric/").getCanonicalFile(), baseDir); // there was a bug before : it returned /home/cedric/programmation/projets/subversion ... workingCopy = new File("/home/cedric/programmation/projets/subversion/svnant/test/svn/workingcopy/listenerTest"); currentDir = new File("/home/cedric/programmation/projets/subversion/svnant/"); baseDir = SVNBaseDir.getCommonPart(workingCopy, currentDir); assertEquals(new File("/home/cedric/programmation/projets/subversion/svnant/").getCanonicalFile(), baseDir); } } svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/SVNUrlTest.java000066400000000000000000000145151203563747500324550ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2003, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import java.net.MalformedURLException; import junit.framework.TestCase; import org.tigris.subversion.svnclientadapter.SVNUrl; /** * This class tests SVNUrl * Note that tests for SVNClientAdapter itself are in svnant */ public class SVNUrlTest extends TestCase { public void testNullURLThrowsInvalidURLException() throws Exception { try { new SVNUrl(null); fail("should have thrown malformed url exeption."); } catch (MalformedURLException e) { } } public void testNullSegmentsThrowsInvalidURLException() throws Exception { try { new SVNUrl("http:///"); fail("should have thrown malformed url exeption."); } catch (MalformedURLException e) { } } public void testHostPortUrl() throws Exception { SVNUrl svnurl= new SVNUrl("https://svn.collab.net"); assertEquals("https://svn.collab.net",svnurl.toString()); svnurl= new SVNUrl("https://svn.collab.net/"); assertEquals("https://svn.collab.net",svnurl.toString()); } public void testHttpsURL() throws Exception { SVNUrl https = new SVNUrl("https://svn.collab.net/repos/subclipse/"); assertEquals("https://svn.collab.net/repos/subclipse",https.toString()); } public void testCaseInsensitiveHttpProtocols() throws Exception { SVNUrl https = new SVNUrl("HTTPS://svn.collab.net/repos/subclipse/"); assertEquals("https://svn.collab.net/repos/subclipse",https.toString()); SVNUrl http = new SVNUrl("HTTP://svn.collab.net/repos/subclipse/"); assertEquals("http://svn.collab.net/repos/subclipse",http.toString()); } public void testGetParent() throws Exception { SVNUrl url1 = new SVNUrl("http://svn.collab.net/repos/subclipse/myfile.txt"); assertEquals("http://svn.collab.net/repos/subclipse",url1.getParent().toString()); assertEquals("http://svn.collab.net/repos",url1.getParent().getParent().toString()); assertEquals("http://svn.collab.net",url1.getParent().getParent().getParent().toString()); assertEquals(null,url1.getParent().getParent().getParent().getParent()); } public void testSegments() throws Exception { SVNUrl url1 = new SVNUrl("http://svn.collab.net/repos/subclipse/myfile.txt"); assertEquals(3, url1.getPathSegments().length); assertEquals("repos", url1.getPathSegments()[0]); assertEquals("subclipse", url1.getPathSegments()[1]); assertEquals("myfile.txt", url1.getPathSegments()[2]); assertEquals(2, url1.getParent().getPathSegments().length); } public void testHostPort() throws Exception { SVNUrl url1 = new SVNUrl("http://svn.collab.net:8080/repos/subclipse/myfile.txt"); assertEquals("svn.collab.net",url1.getHost()); assertEquals(8080,url1.getPort()); url1 = new SVNUrl("svn+ssh://svn.collab.net/repos/subclipse/myfile.txt"); assertEquals(22,url1.getPort()); } public void testEquals() throws Exception { SVNUrl http1 = new SVNUrl("HTTP://SVN.collab.net/repos/subclipse/"); SVNUrl http2 = new SVNUrl("http://svn.collab.net:80/repos/subclipse"); assertEquals(http1,http2); } public void testNonStandardPort() throws Exception { SVNUrl svnurl= new SVNUrl("http://svn.collab.net:8080/repos/subclipse/myfile.txt"); assertEquals("http://svn.collab.net:8080/repos/subclipse/myfile.txt",svnurl.toString()); } public void testFileURL() throws Exception { SVNUrl svnurl= new SVNUrl("file:///repos/subclipse/myfile.txt"); assertEquals("file:///repos/subclipse/myfile.txt",svnurl.toString()); SVNUrl svnurl2= new SVNUrl("file://d/repos/subclipse/myfile.txt"); assertEquals("file://d/repos/subclipse/myfile.txt",svnurl2.toString()); SVNUrl svnurl3= new SVNUrl("file://repos/subclipse/myfile.txt"); assertEquals("file://repos/subclipse/myfile.txt",svnurl3.toString()); SVNUrl svnurl4= new SVNUrl("file:///f:/svn/trunk"); assertEquals("file:///f:/svn/trunk",svnurl4.toString()); SVNUrl url1 = new SVNUrl("file:///repos/subclipse/myfile.txt"); assertEquals("file:///repos/subclipse",url1.getParent().toString()); assertEquals("file:///repos",url1.getParent().getParent().toString()); assertEquals(null,url1.getParent().getParent().getParent()); } public void testUtilGetLastSegment() throws Exception { SVNUrl http1 = new SVNUrl("HTTP://SVN.collab.net/repos/subclipse/"); SVNUrl http2 = new SVNUrl("http://svn.collab.net:80/repos/subclipse"); SVNUrl http3 = new SVNUrl("http://svn.collab.net/"); SVNUrl svn1 = new SVNUrl("svn://svn.collab.net/repos/subclipse"); SVNUrl svn2 = new SVNUrl("svn://svn.collab.net/"); assertEquals("subclipse", http1.getLastPathSegment()); assertEquals("subclipse", http2.getLastPathSegment()); assertEquals("", http3.getLastPathSegment()); assertEquals("subclipse", svn1.getLastPathSegment()); assertEquals("", svn2.getLastPathSegment()); } public void testAppendPath() throws Exception { SVNUrl http1 = new SVNUrl("HTTP://SVN.collab.net/repos/subclipse/"); SVNUrl http2 = new SVNUrl("HTTP://SVN.collab.net/repos/subclipse/mydirectory/myfile.txt"); assertEquals(http2, http1.appendPath("/mydirectory/myfile.txt")); assertEquals(http2, http1.appendPath("mydirectory/myfile.txt")); assertEquals(http1, http1.appendPath("")); } } svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/SVNUrlUtilsTest.java000066400000000000000000000113151203563747500334710ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import org.tigris.subversion.svnclientadapter.utils.SVNUrlUtils; import junit.framework.TestCase; /** */ public class SVNUrlUtilsTest extends TestCase { public void testGetCommonRootUrl() throws Exception { SVNUrl[] urls = new SVNUrl[] { new SVNUrl("http://svn.collab.net/repos/subclipse/myfile.txt"), new SVNUrl("http://svn.collab.net:80/repos/subclipse/myfile2.txt"), new SVNUrl("HTTP://svn.collab.net/repos/subclipse/mydir/myfile.txt"), new SVNUrl("http://svn.collab.net/repos/subclipse/mydir/mydir2/myfile.txt") }; assertEquals("http://svn.collab.net/repos/subclipse", SVNUrlUtils.getCommonRootUrl(urls).toString()); } public void testGetCommonRootUrlNoRoot() throws Exception { SVNUrl[] urls = new SVNUrl[] { new SVNUrl("http://svn.collab.net:81/repos/subclipse/myfile.txt"), new SVNUrl("http://svn.collab.net:80/repos/subclipse/myfile2.txt"), new SVNUrl("HTTP://svn.collab.net/repos/subclipse/mydir/myfile.txt"), new SVNUrl("http://svn.collab.net/repos/subclipse/mydir/mydir2/myfile.txt") }; assertEquals(null, SVNUrlUtils.getCommonRootUrl(urls)); } public void testRelativePath() throws Exception { SVNUrl url = new SVNUrl("http://svn.collab.net:81/repos/subclipse/myfile.txt"); SVNUrl rootUrl = new SVNUrl("http://svn.collab.net:81/repos"); assertEquals("subclipse/myfile.txt",SVNUrlUtils.getRelativePath(rootUrl,url)); assertEquals("/subclipse/myfile.txt", SVNUrlUtils.getRelativePath(rootUrl, url, true)); assertEquals("/subclipse/myfile.txt", url.toString().substring(rootUrl.toString().length())); } public void testGetUrlFromLocalFileName() throws Exception { SVNUrl rootUrl = new SVNUrl("http://svn.collab.net:81/repos/mydir"); String rootPath = "C:\\Documents and Settings\\User\\My Documents\\Eclipse\\mydir"; String filePath = "C:\\Documents and Settings\\User\\My Documents\\Eclipse\\mydir\\mydir2\\myFile.txt"; SVNUrl expected = new SVNUrl("http://svn.collab.net:81/repos/mydir/mydir2/myFile.txt"); assertEquals(expected,SVNUrlUtils.getUrlFromLocalFileName(filePath, rootUrl, rootPath)); rootUrl = new SVNUrl("http://svn.collab.net:81/repos/mydir/"); assertEquals(expected,SVNUrlUtils.getUrlFromLocalFileName(filePath, rootUrl, rootPath)); rootPath = "C:\\Documents and Settings\\User\\My Documents\\Eclipse\\mydir\\"; assertEquals(expected,SVNUrlUtils.getUrlFromLocalFileName(filePath, rootUrl, rootPath)); rootUrl = new SVNUrl("http://svn.collab.net:81/repos/mydir"); rootPath = "C:/Documents and Settings/User/My Documents/Eclipse/mydir"; filePath = "C:\\Documents and Settings\\User\\My Documents\\Eclipse\\mydir\\mydir2\\myFile.txt"; assertEquals(expected,SVNUrlUtils.getUrlFromLocalFileName(filePath, rootUrl, rootPath)); rootPath = "C:\\Documents and Settings\\User\\My Documents\\Eclipse\\mydir"; filePath = "C:/Documents and Settings/User/My Documents/Eclipse/mydir/mydir2/myFile.txt"; assertEquals(expected,SVNUrlUtils.getUrlFromLocalFileName(filePath, rootUrl, rootPath)); rootPath = "C:/Documents and Settings/User/My Documents/Eclipse/mydir/"; assertEquals(expected,SVNUrlUtils.getUrlFromLocalFileName(filePath, rootUrl, rootPath)); expected = new SVNUrl("http://svn.collab.net:81/repos/mydir"); rootUrl = new SVNUrl("http://svn.collab.net:81/repos/mydir"); rootPath = "C:\\Documents and Settings\\User\\My Documents\\Eclipse\\mydir"; filePath = "C:\\Documents and Settings\\User\\My Documents\\Eclipse\\mydir"; assertEquals(expected,SVNUrlUtils.getUrlFromLocalFileName(filePath, rootUrl, rootPath)); } } svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/StringUtilsTest.java000066400000000000000000000042741203563747500336140ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter; import junit.framework.TestCase; import org.tigris.subversion.svnclientadapter.utils.StringUtils; /** * tests StringUtils */ public class StringUtilsTest extends TestCase { public void testSplitWithChar() throws Exception { String[] segments = StringUtils.split("org.tigris.subversion.svnclientadapter",'.'); assertEquals(4,segments.length); assertEquals("org",segments[0]); assertEquals("tigris",segments[1]); assertEquals("subversion",segments[2]); assertEquals("svnclientadapter",segments[3]); // make sure we have the same result than String.split when the string ends with the separator String path = "first/second/"; segments = StringUtils.split(path,'/'); assertEquals(2,segments.length); } public void testSplitWithString() throws Exception { String[] segments = StringUtils.split("org\n\rtigris\n\rsubversion\n\rsvnclientadapter","\n\r"); assertEquals(4,segments.length); assertEquals("org",segments[0]); assertEquals("tigris",segments[1]); assertEquals("subversion",segments[2]); assertEquals("svnclientadapter",segments[3]); // make sure we have the same result than String.split when the string ends with the separator String path = "first\n\rsecond\n\r"; segments = StringUtils.split(path,"\n\r"); assertEquals(2,segments.length); } } svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/000077500000000000000000000000001203563747500317575ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/AddTest.java000066400000000000000000000047571203563747500341670ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.io.FileOutputStream; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class AddTest extends SVNTest { /** * test the basis SVNClient.add functionality with files that should be * ignored * @throws Throwable */ public void testBasicAddIgnores() throws Throwable { // create working copy OneTest thisTest = new OneTest("basicAddIgnores",getGreekTestConfig()); // create dir File dir = new File(thisTest.getWorkingCopy(), "dir"); dir.mkdir(); // create dir/foo.c File fileC = new File(dir, "foo.c"); new FileOutputStream(fileC).close(); // create dir/foo.o (should be ignored) File fileO = new File(dir, "foo.o"); new FileOutputStream(fileO).close(); // add dir client.addDirectory(dir, true); thisTest.getExpectedWC().addItem("dir", null); thisTest.getExpectedWC().setItemTextStatus("dir",SVNStatusKind.ADDED); thisTest.getExpectedWC().addItem("dir/foo.c", ""); thisTest.getExpectedWC().setItemTextStatus("dir/foo.c",SVNStatusKind.ADDED); thisTest.getExpectedWC().addItem("dir/foo.o", ""); thisTest.getExpectedWC().setItemTextStatus("dir/foo.o",SVNStatusKind.IGNORED); thisTest.getExpectedWC().setItemNodeKind("dir/foo.o", SVNNodeKind.UNKNOWN); // test the working copy status thisTest.checkStatusesExpectedWC(); } } BlameTest.java000066400000000000000000000156331203563747500344330ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintWriter; import org.tigris.subversion.svnclientadapter.ISVNAnnotations; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class BlameTest extends SVNTest { private void prepareTestFile(File mu, OneTest thisTest) throws FileNotFoundException, SVNClientException { PrintWriter pw = new PrintWriter(new FileOutputStream(mu, true)); pw.println("some text in line1"); pw.println("some text in line2"); pw.println("some text in line3"); pw.close(); client.commit(new File[] {mu}, "log msg2", true); pw = new PrintWriter(new FileOutputStream(mu, false)); pw.println("some new text in line1"); pw.println("some text in line2"); pw.println("some new text in line3"); pw.close(); client.commit(new File[] {mu}, "log msg3", true); client.setUsername(ANOTHER_TEST_USER); pw = new PrintWriter(new FileOutputStream(mu, true)); pw.println("some new line4"); pw.close(); client.commit(new File[] {mu}, "log msg4", true); client.setUsername(TEST_USER); } public void testBlameHead() throws Throwable { // create the working copy OneTest thisTest = new OneTest("testBlameHead", getGreekTestConfig()); File mu = new File(thisTest.getWorkingCopy(), "A/mu"); prepareTestFile(mu, thisTest); //blame from 1->HEAD ISVNAnnotations annotations = client.annotate(mu, null, null); // the size should match assertEquals("invalid number of annotation lines", 4, annotations.numberOfLines()); //check revisions assertEquals("blamed revision does not match", 3 ,annotations.getRevision(0)); assertEquals("blamed revision does not match", 2 ,annotations.getRevision(1)); assertEquals("blamed revision does not match", 3 ,annotations.getRevision(2)); assertEquals("blamed revision does not match", 4 ,annotations.getRevision(3)); //check authors assertEquals("blamed author does not match", TEST_USER ,annotations.getAuthor(0)); assertEquals("blamed author does not match", TEST_USER ,annotations.getAuthor(1)); assertEquals("blamed author does not match", TEST_USER ,annotations.getAuthor(2)); assertEquals("blamed author does not match", ANOTHER_TEST_USER ,annotations.getAuthor(3)); //check text assertEquals("blamed text does not match", "some new text in line1" ,annotations.getLine(0).trim()); assertEquals("blamed text does not match", "some text in line2" ,annotations.getLine(1).trim()); } public void testBlameHeadUnUncommittedRename() throws Throwable { // create the working copy OneTest thisTest = new OneTest("testBlameHead", getGreekTestConfig()); File mu = new File(thisTest.getWorkingCopy(), "A/mu"); prepareTestFile(mu, thisTest); File mu2 = new File(thisTest.getWorkingCopy(), "A/mu2"); client.move(mu, mu2, true); //blame from 1->HEAD ISVNAnnotations annotations = client.annotate(mu2, null, null); // the size should match assertEquals("invalid number of annotation lines", 4, annotations.numberOfLines()); //check revisions assertEquals("blamed revision does not match", 3 ,annotations.getRevision(0)); assertEquals("blamed revision does not match", 2 ,annotations.getRevision(1)); assertEquals("blamed revision does not match", 3 ,annotations.getRevision(2)); assertEquals("blamed revision does not match", 4 ,annotations.getRevision(3)); //check authors assertEquals("blamed author does not match", TEST_USER ,annotations.getAuthor(0)); assertEquals("blamed author does not match", TEST_USER ,annotations.getAuthor(1)); assertEquals("blamed author does not match", TEST_USER ,annotations.getAuthor(2)); assertEquals("blamed author does not match", ANOTHER_TEST_USER ,annotations.getAuthor(3)); //check text assertEquals("blamed text does not match", "some new text in line1" ,annotations.getLine(0).trim()); assertEquals("blamed text does not match", "some text in line2" ,annotations.getLine(1).trim()); } public void testBlameLastRev() throws Throwable { // create the working copy OneTest thisTest = new OneTest("testBlameLastRev", getGreekTestConfig()); File mu = new File(thisTest.getWorkingCopy(), "iota"); prepareTestFile(mu, thisTest); //blame from 3->HEAD ISVNAnnotations annotations = client.annotate(mu, SVNRevision.getRevision("3"), null); // the size should match assertEquals("invalid number of annotation lines", 4, annotations.numberOfLines()); //check revisions assertEquals("blamed revision does not match", 3 ,annotations.getRevision(0)); assertEquals("blamed revision does not match", -1 ,annotations.getRevision(1)); assertEquals("blamed revision does not match", 3 ,annotations.getRevision(2)); assertEquals("blamed revision does not match", 4 ,annotations.getRevision(3)); //check authors assertEquals("blamed author does not match", TEST_USER ,annotations.getAuthor(0)); assertEquals("blamed author does not match", null ,annotations.getAuthor(1)); assertEquals("blamed author does not match", TEST_USER ,annotations.getAuthor(2)); assertEquals("blamed author does not match", ANOTHER_TEST_USER ,annotations.getAuthor(3)); //check text assertEquals("blamed text does not match", "some new text in line1" ,annotations.getLine(0).trim()); assertEquals("blamed text does not match", "some text in line2" ,annotations.getLine(1).trim()); } } svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/CatTest.java000066400000000000000000000122651203563747500341770ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStream; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.Locale; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class CatTest extends SVNTest { private void modifyAMu(OneTest thisTest) throws FileNotFoundException { File mu = new File(thisTest.getWorkingCopy(), "A/mu"); PrintWriter pw = new PrintWriter(new FileOutputStream(mu, true)); pw.print("some text"); pw.close(); } /** * test the basic SVNClient.fileContent functionality * * @throws Throwable */ public void testHeadCat() throws Throwable { // create the working copy OneTest thisTest = new OneTest("testHeadCat", getGreekTestConfig()); // modify A/mu modifyAMu(thisTest); // get the content from the repository InputStream is = client.getContent(new File(thisTest.getWCPath() + "/A/mu"), SVNRevision.HEAD); byte[] content = new byte[is.available()]; is.read(content); byte[] testContent = thisTest.getExpectedWC().getItemContent("A/mu").getBytes(); // the content should be the same assertTrue("content changed", Arrays.equals(content, testContent)); } public void testBaseCat() throws Throwable { // create the working copy OneTest thisTest = new OneTest("testBaseCat", getGreekTestConfig()); // modify A/mu modifyAMu(thisTest); // get the content from BASE InputStream is = client.getContent(new File(thisTest.getWCPath() + "/A/mu"), SVNRevision.BASE); byte[] content = new byte[is.available()]; is.read(content); byte[] testContent = thisTest.getExpectedWC().getItemContent("A/mu").getBytes(); // the content should be the same assertTrue("content changed", Arrays.equals(content, testContent)); } public void testDateCat() throws Throwable { // create the working copy OneTest thisTest = new OneTest("testDateCat", getGreekTestConfig()); // modify A/mu modifyAMu(thisTest); // get the content using date InputStream is = client.getContent(new File(thisTest.getWCPath() + "/A/mu"), new SVNRevision.DateSpec(new Date())); byte[] content = new byte[is.available()]; is.read(content); byte[] testContent = thisTest.getExpectedWC().getItemContent("A/mu").getBytes(); // the content should be the same assertTrue("content changed", Arrays.equals(content, testContent)); } public void testDateStringCat() throws Throwable { // create the working copy OneTest thisTest = new OneTest("testDateCat", getGreekTestConfig()); // modify A/mu modifyAMu(thisTest); SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm a", Locale.US); // get the content using date InputStream is = client.getContent(new File(thisTest.getWCPath() + "/A/mu"), SVNRevision.getRevision(df.format(new Date()))); byte[] content = new byte[is.available()]; is.read(content); byte[] testContent = thisTest.getExpectedWC().getItemContent("A/mu").getBytes(); // the content should be the same assertTrue("content changed", Arrays.equals(content, testContent)); } public void testUrlCat() throws Throwable { // create the working copy OneTest thisTest = new OneTest("testUrlCat", getGreekTestConfig()); InputStream is = client.getContent(new SVNUrl(thisTest.getUrl() + "/A/mu"), SVNRevision.HEAD); byte[] content = new byte[is.available()]; is.read(content); byte[] testContent = thisTest.getExpectedWC().getItemContent("A/mu").getBytes(); // the content should be the same assertTrue("content is not the same", Arrays.equals(content, testContent)); } }CheckOutTest.java000066400000000000000000000122771203563747500351210ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.io.FileOutputStream; import java.io.PrintWriter; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class CheckOutTest extends SVNTest { /** * test the basic SVNCLient.checkout functionality * @throws Throwable */ public void testBasicCheckout() throws Throwable { // build the test setup OneTest thisTest = new OneTest("basicCheckout",getGreekTestConfig()); try { // obstructed checkout must fail client.checkout(new SVNUrl(thisTest.getUrl() + "/A"), thisTest.getWCPath(), SVNRevision.HEAD, true); fail("missing exception"); } catch (SVNClientException e) { } // modify file A/mu File mu = new File(thisTest.getWorkingCopy(), "A/mu"); PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true)); muPW.print("appended mu text"); muPW.close(); thisTest.getExpectedWC().setItemTextStatus("A/mu", SVNStatusKind.MODIFIED); // delete A/B/lambda without svn File lambda = new File(thisTest.getWorkingCopy(), "A/B/lambda"); lambda.delete(); thisTest.getExpectedWC().setItemTextStatus("A/B/lambda", SVNStatusKind.MISSING); // remove A/D/G client.remove(new File[]{new File(thisTest.getWCPath() + "/A/D/G")}, false); thisTest.getExpectedWC().setItemTextStatus("A/D/G", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/G/pi", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/G/rho", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/G/tau", SVNStatusKind.DELETED); // check the status of the working copy thisTest.checkStatusesExpectedWC(); } public void testBasicCheckoutDeleted() throws Throwable { // create working copy OneTest thisTest = new OneTest("basicCheckout",getGreekTestConfig()); // delete A/D and its content client.remove(new File[] {new File(thisTest.getWCPath()+"/A/D")}, true); thisTest.getExpectedWC().setItemTextStatus("A/D", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/G", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/G/rho", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/G/pi", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/G/tau", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/H", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/H/chi", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/H/psi", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/H/omega", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/gamma", SVNStatusKind.DELETED); // check the working copy status thisTest.checkStatusesExpectedWC(); // commit the change assertEquals("wrong revision from commit",2, client.commit(new File[]{thisTest.getWCPath()}, "log message", true)); thisTest.getExpectedWC().removeItem("A/D"); thisTest.getExpectedWC().removeItem("A/D/G"); thisTest.getExpectedWC().removeItem("A/D/G/rho"); thisTest.getExpectedWC().removeItem("A/D/G/pi"); thisTest.getExpectedWC().removeItem("A/D/G/tau"); thisTest.getExpectedWC().removeItem("A/D/H"); thisTest.getExpectedWC().removeItem("A/D/H/chi"); thisTest.getExpectedWC().removeItem("A/D/H/psi"); thisTest.getExpectedWC().removeItem("A/D/H/omega"); thisTest.getExpectedWC().removeItem("A/D/gamma"); // check the working copy status thisTest.checkStatusesExpectedWC(); // check out the previous revision client.checkout(new SVNUrl(thisTest.getUrl()+"/A/D"), new File(thisTest.getWCPath()+"/new_D"), new SVNRevision.Number(1), true); } } CleanupTest.java000066400000000000000000000056201203563747500347750ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.io.FileOutputStream; import java.io.PrintWriter; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; /** * @author Brock Janiczak */ public class CleanupTest extends SVNTest { /** * test the basic SVNClient.cleanup functionality * @throws Throwable */ public void testBasicCleanup() throws Throwable { // create a test working copy OneTest thisTest = new OneTest("basicCleanup", getGreekTestConfig()); // create a lock file in A/B File adminLock = new File(thisTest.getWorkingCopy(),"A/B/" + client.getAdminDirectoryName() + "/lock"); PrintWriter pw = new PrintWriter(new FileOutputStream(adminLock)); pw.print("stop looking!"); pw.close(); thisTest.getExpectedWC().setItemIsLocked("A/B", true); // create a lock file in A/D/G adminLock = new File(thisTest.getWorkingCopy(),"A/D/G/" + client.getAdminDirectoryName() + "/lock"); pw = new PrintWriter(new FileOutputStream(adminLock)); pw.print("stop looking!"); pw.close(); thisTest.getExpectedWC().setItemIsLocked("A/D/G", true); // create a lock file in A/C adminLock = new File(thisTest.getWorkingCopy(),"A/C/" + client.getAdminDirectoryName() + "/lock"); pw = new PrintWriter(new FileOutputStream(adminLock)); pw.print("stop looking!"); pw.close(); thisTest.getExpectedWC().setItemIsLocked("A/C", true); // test the status of the working copy thisTest.checkStatusesExpectedWC(); // run cleanup client.cleanup(thisTest.getWCPath()); thisTest.getExpectedWC().setItemIsLocked("A/B", false); thisTest.getExpectedWC().setItemIsLocked("A/D/G", false); thisTest.getExpectedWC().setItemIsLocked("A/C", false); // test the status of the working copy thisTest.checkStatusesExpectedWC(); } } CommitTest.java000066400000000000000000000052351203563747500346400ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.io.FileOutputStream; import java.io.PrintWriter; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class CommitTest extends SVNTest { /** * test the basic SVNClient.commit functionality * @throws Throwable */ public void testBasicCommit() throws Throwable { // build the test setup OneTest thisTest = new OneTest("basicCommit",getGreekTestConfig()); // modify file A/mu File mu = new File(thisTest.getWorkingCopy(), "A/mu"); PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true)); muPW.print("appended mu text"); muPW.close(); thisTest.getExpectedWC().setItemWorkingCopyRevision("A/mu", 2); thisTest.getExpectedWC().setItemContent("A/mu", thisTest.getExpectedWC().getItemContent("A/mu") + "appended mu text"); // modify file A/D/G/rho File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho"); PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true)); rhoPW.print("new appended text for rho"); rhoPW.close(); thisTest.getExpectedWC().setItemWorkingCopyRevision("A/D/G/rho", 2); thisTest.getExpectedWC().setItemContent("A/D/G/rho", thisTest.getExpectedWC().getItemContent("A/D/G/rho") + "new appended text for rho"); // commit the changes assertEquals("wrong revision number from commit",2, client.commit(new File[]{thisTest.getWCPath()}, "log msg", true)); // check the status of the working copy thisTest.checkStatusesExpectedWC(); } } CopyTest.java000066400000000000000000000122551203563747500343220ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class CopyTest extends SVNTest { public void testCopyFile2File() throws Throwable { // create working copy OneTest thisTest = new OneTest("basicCopyFile2File", getGreekTestConfig()); File src = new File(thisTest.getWorkingCopy() + "/A/mu"); File dst = new File(thisTest.getWorkingCopy() + "/A/C/mu"); client.copy(src, dst); thisTest.getExpectedWC().addItem("A/C/mu", null); thisTest.getExpectedWC().setItemTextStatus("A/C/mu", SVNStatusKind.ADDED); thisTest.getExpectedWC().setItemIsCopied("A/C/mu", true); // test the working copy status thisTest.checkStatusesExpectedWC(); // try to copy an entire directory src = new File(thisTest.getWorkingCopy() + "/A/D"); dst = new File(thisTest.getWorkingCopy() + "/A/E"); client.copy(src, dst); thisTest.getExpectedWC().addItem("A/E", null); thisTest.getExpectedWC().setItemTextStatus("A/E", SVNStatusKind.ADDED); thisTest.getExpectedWC().setItemIsCopied("A/E", true); thisTest.getExpectedWC().addItem("A/E/gamma", null); thisTest.getExpectedWC().setItemTextStatus("A/E/gamma", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/gamma", true); thisTest.getExpectedWC().addItem("A/E/H", null); thisTest.getExpectedWC().setItemTextStatus("A/E/H", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/H", true); thisTest.getExpectedWC().addItem("A/E/H/chi", null); thisTest.getExpectedWC().setItemTextStatus("A/E/H/chi", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/H/chi", true); thisTest.getExpectedWC().addItem("A/E/H/psi", null); thisTest.getExpectedWC().setItemTextStatus("A/E/H/psi", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/H/psi", true); thisTest.getExpectedWC().addItem("A/E/H/omega", null); thisTest.getExpectedWC().setItemTextStatus("A/E/H/omega", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/H/omega", true); thisTest.getExpectedWC().addItem("A/E/G", null); thisTest.getExpectedWC().setItemTextStatus("A/E/G", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/G", true); thisTest.getExpectedWC().addItem("A/E/G/pi", null); thisTest.getExpectedWC().setItemTextStatus("A/E/G/pi", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/G/pi", true); thisTest.getExpectedWC().addItem("A/E/G/rho", null); thisTest.getExpectedWC().setItemTextStatus("A/E/G/rho", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/G/rho", true); thisTest.getExpectedWC().addItem("A/E/G/tau", null); thisTest.getExpectedWC().setItemTextStatus("A/E/G/tau", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/G/tau", true); thisTest.checkStatusesExpectedWC(); } public void testCopyUrl2UrlWithoutMsg() throws Throwable { // create working copy OneTest thisTest = new OneTest("basicCopyUrl2Url", getGreekTestConfig()); client.copy(new SVNUrl(thisTest.getUrl() + "/A/B"), new SVNUrl(thisTest .getUrl() + "/B"), null, SVNRevision.HEAD); // update the working copy client.update(thisTest.getWCPath(), SVNRevision.HEAD, true); thisTest.getExpectedWC().addItem("B", null); thisTest.getExpectedWC().addItem("B/lambda", "This is the file 'lambda'."); thisTest.getExpectedWC().addItem("B/E", null); thisTest.getExpectedWC().addItem("B/E/alpha", "This is the file 'alpha'."); thisTest.getExpectedWC().addItem("B/E/beta", "This is the file 'beta'."); thisTest.getExpectedWC().addItem("B/F", null); thisTest.checkStatusesExpectedWC(); } }DeleteTest.java000066400000000000000000000276221203563747500346160ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.io.FileOutputStream; import java.io.PrintWriter; import org.tigris.subversion.svnclientadapter.ISVNDirEntry; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class DeleteTest extends SVNTest { /** * test the basic SVNClient.remove functionality * @throws Throwable */ public void testBasicDelete() throws Throwable { // create the test working copy OneTest thisTest = new OneTest("basicDelete",getGreekTestConfig()); // modify A/D/H/chi File file = new File(thisTest.getWorkingCopy(), "A/D/H/chi"); PrintWriter pw = new PrintWriter(new FileOutputStream(file, true)); pw.print("added to chi"); pw.close(); thisTest.getExpectedWC().setItemTextStatus("A/D/H/chi", SVNStatusKind.MODIFIED); // set a property on A/D/G/rho file client.propertySet(new File(thisTest.getWCPath()+"/A/D/G/rho"), "abc", "def", true); thisTest.getExpectedWC().setItemPropStatus("A/D/G/rho", SVNStatusKind.MODIFIED); // set a property on A/B/F directory client.propertySet(new File(thisTest.getWCPath()+"/A/B/F"), "abc", "def", false); thisTest.getExpectedWC().setItemPropStatus("A/B/F", SVNStatusKind.MODIFIED); // create a unversioned A/C/sigma file file = new File(thisTest.getWCPath(),"A/C/sigma"); pw = new PrintWriter(new FileOutputStream(file)); pw.print("unversioned sigma"); pw.close(); thisTest.getExpectedWC().addItem("A/C/sigma", "unversioned sigma"); thisTest.getExpectedWC().setItemTextStatus("A/C/sigma", SVNStatusKind.UNVERSIONED); thisTest.getExpectedWC().setItemNodeKind("A/C/sigma", SVNNodeKind.UNKNOWN); // create unversioned directory A/C/Q file = new File(thisTest.getWCPath(), "A/C/Q"); file.mkdir(); thisTest.getExpectedWC().addItem("A/C/Q", null); thisTest.getExpectedWC().setItemNodeKind("A/C/Q", SVNNodeKind.UNKNOWN); thisTest.getExpectedWC().setItemTextStatus("A/C/Q", SVNStatusKind.UNVERSIONED); // create & add the directory A/B/X file = new File(thisTest.getWCPath(), "A/B/X"); client.mkdir(file); thisTest.getExpectedWC().addItem("A/B/X", null); thisTest.getExpectedWC().setItemTextStatus("A/B/X", SVNStatusKind.ADDED); // create & add the file A/B/X/xi file = new File(file, "xi"); pw = new PrintWriter(new FileOutputStream(file)); pw.print("added xi"); pw.close(); client.addFile(file); thisTest.getExpectedWC().addItem("A/B/X/xi", "added xi"); thisTest.getExpectedWC().setItemTextStatus("A/B/X/xi", SVNStatusKind.ADDED); // create & add the directory A/B/Y file = new File(thisTest.getWCPath(), "A/B/Y"); client.mkdir(file); thisTest.getExpectedWC().addItem("A/B/Y", null); thisTest.getExpectedWC().setItemTextStatus("A/B/Y", SVNStatusKind.ADDED); // test the status of the working copy thisTest.checkStatusesExpectedWC(); // the following removes should all fail without force try { // remove of A/D/H/chi without force should fail, because it is // modified client.remove(new File[] { new File(thisTest.getWCPath()+"/A/D/H/chi") }, false); fail("missing exception"); } catch(SVNClientException e) { } try { // remove of A/D/H without force should fail, because A/D/H/chi is // modified client.remove(new File[] {new File(thisTest.getWCPath()+"/A/D/H") }, false); fail("missing exception"); } catch(SVNClientException e) { } try { // remove of A/D/G/rho without force should fail, because it has // a new property client.remove(new File[] { new File(thisTest.getWCPath()+"/A/D/G/rho") }, false); fail("missing exception"); } catch(SVNClientException e) { } try { // remove of A/D/G without force should fail, because A/D/G/rho has // a new property client.remove(new File[] { new File(thisTest.getWCPath()+"/A/D/G") }, false); fail("missing exception"); } catch(SVNClientException e) { } try { // remove of A/B/F without force should fail, because it has // a new property client.remove(new File[] { new File(thisTest.getWCPath()+"/A/B/F") }, false); fail("missing exception"); } catch(SVNClientException e) { } try { // remove of A/B without force should fail, because A/B/F has // a new property client.remove(new File[] { new File(thisTest.getWCPath()+"/A/B") }, false); fail("missing exception"); } catch(SVNClientException e) { } try { // remove of A/C/sigma without force should fail, because it is // unversioned client.remove(new File[] { new File(thisTest.getWCPath()+"/A/C/sigma") }, false); fail("missing exception"); } catch(SVNClientException e) { } try { // remove of A/C without force should fail, because A/C/sigma is // unversioned client.remove(new File[] { new File(thisTest.getWCPath()+"/A/C") }, false); fail("missing exception"); } catch(SVNClientException e) { } try { // remove of A/B/X without force should fail, because it is new client.remove(new File[] { new File(thisTest.getWCPath()+"/A/B/X")}, false); fail("missing exception"); } catch(SVNClientException e) { } // check the status of the working copy thisTest.checkStatusesExpectedWC(); // the following removes should all work client.remove(new File[] { new File(thisTest.getWCPath()+"/A/B/E")}, false); thisTest.getExpectedWC().setItemTextStatus("A/B/E",SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/B/E/alpha",SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/B/E/beta",SVNStatusKind.DELETED); client.remove(new File[] { new File(thisTest.getWCPath()+"/A/D/H")}, true); thisTest.getExpectedWC().setItemTextStatus("A/D/H",SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/H/chi",SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/H/omega",SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/H/psi",SVNStatusKind.DELETED); client.remove(new File[] { new File(thisTest.getWCPath()+"/A/D/G")}, true); thisTest.getExpectedWC().setItemTextStatus("A/D/G",SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/G/rho",SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemPropStatus("A/D/G/rho", SVNStatusKind.NONE); thisTest.getExpectedWC().setItemTextStatus("A/D/G/pi",SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/G/tau",SVNStatusKind.DELETED); client.remove(new File[] { new File(thisTest.getWCPath()+"/A/B/F")}, true); thisTest.getExpectedWC().setItemTextStatus("A/B/F",SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemPropStatus("A/B/F", SVNStatusKind.NONE); client.remove(new File[] { new File(thisTest.getWCPath()+"/A/C")}, true); thisTest.getExpectedWC().setItemTextStatus("A/C",SVNStatusKind.DELETED); client.remove(new File[] { new File(thisTest.getWCPath()+"/A/B/X")}, true); file = new File(thisTest.getWorkingCopy(), "iota"); file.delete(); client.remove(new File[] {file}, true); thisTest.getExpectedWC().setItemTextStatus("iota",SVNStatusKind.DELETED); file = new File(thisTest.getWorkingCopy(), "A/D/gamma"); file.delete(); client.remove(new File[] {file}, false); thisTest.getExpectedWC().setItemTextStatus("A/D/gamma",SVNStatusKind.DELETED); client.remove(new File[] {file}, true); client.remove(new File[] { new File(thisTest.getWCPath()+"/A/B/E")}, false); thisTest.getExpectedWC().removeItem("A/B/X"); thisTest.getExpectedWC().removeItem("A/B/X/xi"); thisTest.getExpectedWC().removeItem("A/C/sigma"); thisTest.getExpectedWC().removeItem("A/C/Q"); thisTest.checkStatusesExpectedWC(); client.remove(new File[] { new File(thisTest.getWCPath()+"/A/D")},true); thisTest.getExpectedWC().setItemTextStatus("A/D", SVNStatusKind.DELETED); thisTest.getExpectedWC().removeItem("A/D/Y"); // check the status of the working copy thisTest.checkStatusesExpectedWC(); // confirm that the file are realy deleted assertFalse("failed to remove text modified file", new File(thisTest.getWorkingCopy(), "A/D/G/rho").exists()); assertFalse("failed to remove prop modified file", new File(thisTest.getWorkingCopy(), "A/D/H/chi").exists()); assertFalse("failed to remove unversioned file", new File(thisTest.getWorkingCopy(), "A/C/sigma").exists()); assertFalse("failed to remove unmodified file", new File(thisTest.getWorkingCopy(), "A/B/E/alpha").exists()); file = new File(thisTest.getWorkingCopy(),"A/B/F"); assertTrue("removed versioned dir", file.exists() && file.isDirectory()); assertFalse("failed to remove unversioned dir", new File(thisTest.getWorkingCopy(), "A/C/Q").exists()); assertFalse("failed to remove added dir", new File(thisTest.getWorkingCopy(), "A/B/X").exists()); // delete unversioned file foo file = new File(thisTest.getWCPath(),"foo"); pw = new PrintWriter(new FileOutputStream(file)); pw.print("unversioned foo"); pw.close(); client.remove(new File[] {file}, true); assertFalse("failed to remove unversioned file foo", file.exists()); // delete file iota in the repository client.remove(new SVNUrl[] { new SVNUrl(thisTest.getUrl()+"/iota")}, "delete iota URL"); } public void testRemoveUrls() throws Throwable { // create the working copy OneTest thisTest = new OneTest("basicRemoveUrls",getGreekTestConfig()); ISVNDirEntry[] entries = null; entries = client.getList(new SVNUrl(thisTest.getUrl()+"/A"), SVNRevision.HEAD, false); assertEquals(4, entries.length); // remove A/mi client.remove(new SVNUrl[] { new SVNUrl(thisTest.getUrl()+"/A/mu") },"A/mu removed"); // list directory A entries = client.getList(new SVNUrl(thisTest.getUrl()+"/A"), SVNRevision.HEAD, false); assertEquals(3, entries.length); } } ExportTest.java000066400000000000000000000035701203563747500346710ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class ExportTest extends SVNTest { public void testExport() throws Exception { // build the test setup OneTest thisTest = new OneTest("basicExport",getGreekTestConfig()); try { client.doExport(new SVNUrl(thisTest.getUrl() + "/A"), thisTest.getWCPath(), SVNRevision.HEAD, false); fail("missing exception"); } catch (SVNClientException e) { } client.doExport(new SVNUrl(thisTest.getUrl()+"/A"), new File(thisTest.getWCPath()+"/exported"), SVNRevision.HEAD, true); } } ImportTest.java000066400000000000000000000074721203563747500346670ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.io.FileOutputStream; import java.io.PrintWriter; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.testUtils.FileUtils; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class ImportTest extends SVNTest { /** * Test the basic SVNClient.import functionality * @throws Throwable */ public void testBasicImport() throws Throwable { // create the working copy OneTest thisTest = new OneTest("basicImport",getGreekTestConfig()); // create new_file File file = new File(thisTest.getWCPath(),"new_file"); PrintWriter pw = new PrintWriter(new FileOutputStream(file)); pw.print("some text"); pw.close(); // import new_file info dirA/dirB/newFile client.doImport(file.getAbsoluteFile(), new SVNUrl(thisTest.getUrl()+"/dirA/dirB/new_file"), "log message for new import", true); // delete new_file file.delete(); // update the working assertEquals("wrong revision from update",2, client.update(thisTest.getWCPath(), SVNRevision.HEAD, true)); thisTest.getExpectedWC().addItem("dirA", null); thisTest.getExpectedWC().setItemWorkingCopyRevision("dirA",2); thisTest.getExpectedWC().addItem("dirA/dirB", null); thisTest.getExpectedWC().setItemWorkingCopyRevision("dirA/dirB",2); thisTest.getExpectedWC().addItem("dirA/dirB/new_file", "some text"); thisTest.getExpectedWC().setItemWorkingCopyRevision("dirA/dirB/new_file",2); // test the working copy status thisTest.checkStatusesExpectedWC(); } /** * test the basis SVNClient.import functionality with files that should be * ignored * @throws Throwable */ public void testBasicImportIgnores() throws Throwable { // create working copy OneTest thisTest = new OneTest("basicImportIgnores",getGreekTestConfig()); // create dir File dir = new File(thisTest.getWorkingCopy(), "dir"); dir.mkdir(); // create dir/foo.c File fileC = new File(dir, "foo.c"); new FileOutputStream(fileC).close(); // create dir/foo.o (should be ignored) File fileO = new File(dir, "foo.o"); new FileOutputStream(fileO).close(); // import dir client.doImport(dir, new SVNUrl(thisTest.getUrl()+"/dir"), "log message for import", true); // remove dir FileUtils.removeDirectoryWithContent(dir); // udpate the working copy assertEquals("wrong revision from update", 2, client.update(thisTest.getWCPath(), SVNRevision.HEAD, true)); thisTest.getExpectedWC().addItem("dir", null); thisTest.getExpectedWC().addItem("dir/foo.c", ""); // test the working copy status thisTest.checkStatusesExpectedWC(); } } InfoTest.java000066400000000000000000000124451203563747500343040ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.io.FileOutputStream; import org.tigris.subversion.svnclientadapter.ISVNInfo; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNScheduleKind; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class InfoTest extends SVNTest { /** * test the basic SVNClient.info functionality * @throws Throwable */ public void testBasicInfo() throws Throwable { // create the working copy OneTest thisTest = new OneTest("basicInfo",getGreekTestConfig()); // get the item information and test it ISVNInfo info = client.getInfo(new File(thisTest.getWCPath()+"/A/mu")); assertEquals("wrong revision from info", new SVNRevision.Number(1), info.getLastChangedRevision()); assertEquals("wrong schedule kind from info", SVNScheduleKind.NORMAL, info.getSchedule()); assertEquals("wrong node kind from info", SVNNodeKind.FILE, info.getNodeKind()); //Test added file. File fileAdded = new File(thisTest.getWCPath()+"/A/added.txt"); new FileOutputStream(fileAdded).close(); client.addFile(fileAdded); // get the item information and test it info = client.getInfo(fileAdded); assertEquals(fileAdded, info.getFile()); assertNull("wrong revision from info", info.getLastChangedRevision()); assertEquals("wrong schedule kind from info", SVNScheduleKind.ADD, info.getSchedule()); assertEquals("wrong node kind from info", SVNNodeKind.FILE, info.getNodeKind()); File fileUnversioned = new File(thisTest.getWCPath()+"/A/unversioned.txt"); new FileOutputStream(fileUnversioned).close(); // get the item information and test it info = client.getInfo(fileUnversioned); assertEquals(fileUnversioned, info.getFile()); assertNull("wrong revision from info", info.getLastChangedRevision()); assertNull("wrong schedule kind from info", info.getSchedule()); assertNull("wrong node kind from info", info.getNodeKind()); } public void testInfoFromWorkingCopy() throws Throwable { // create the working copy OneTest thisTest = new OneTest("basicInfo",getGreekTestConfig()); // get the item information and test it ISVNInfo info = client.getInfoFromWorkingCopy(new File(thisTest.getWCPath()+"/A/mu")); assertEquals("wrong revision from info", new SVNRevision.Number(1), info.getLastChangedRevision()); assertEquals("wrong schedule kind from info", SVNScheduleKind.NORMAL, info.getSchedule()); assertEquals("wrong node kind from info", SVNNodeKind.FILE, info.getNodeKind()); //Test added file. File fileAdded = new File(thisTest.getWCPath()+"/A/added.txt"); new FileOutputStream(fileAdded).close(); client.addFile(fileAdded); // get the item information and test it info = client.getInfoFromWorkingCopy(fileAdded); assertEquals(fileAdded, info.getFile()); assertNull("wrong revision from info", info.getLastChangedRevision()); assertEquals("wrong schedule kind from info", SVNScheduleKind.ADD, info.getSchedule()); assertEquals("wrong node kind from info", SVNNodeKind.FILE, info.getNodeKind()); File fileUnversioned = new File(thisTest.getWCPath()+"/A/unversioned.txt"); new FileOutputStream(fileUnversioned).close(); // get the item information and test it info = client.getInfoFromWorkingCopy(fileUnversioned); assertEquals(fileUnversioned, info.getFile()); assertNull("wrong revision from info", info.getLastChangedRevision()); assertNull("wrong schedule kind from info", info.getSchedule()); assertNull("wrong node kind from info", info.getNodeKind()); //test the wc root directotry info info = client.getInfoFromWorkingCopy(thisTest.getWorkingCopy()); assertEquals(thisTest.getWorkingCopy(), info.getFile()); assertEquals("wrong revision from info", new SVNRevision.Number(1), info.getLastChangedRevision()); assertEquals("wrong schedule kind from info", SVNScheduleKind.NORMAL, info.getSchedule()); assertEquals("wrong node kind from info", SVNNodeKind.DIR, info.getNodeKind()); } } svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/LogTest.java000066400000000000000000000160171203563747500342100ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.io.FileOutputStream; import java.io.PrintWriter; import org.tigris.subversion.svnclientadapter.ISVNLogMessage; import org.tigris.subversion.svnclientadapter.ISVNLogMessageChangePath; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class LogTest extends SVNTest { /** * test the basic SVNClientInfo.logMessage functionality * * @throws Throwable */ public void testBasicLogMessage() throws Throwable { // create the working copy OneTest thisTest = new OneTest("basicLogMessages", getGreekTestConfig()); // get the commit message of the initial import and test it ISVNLogMessage lm[] = client.getLogMessages(thisTest.getWCPath(), new SVNRevision.Number(1), SVNRevision.HEAD); assertEquals("wrong number of objects", 1, lm.length); assertEquals("wrong message", "Log Message", lm[0].getMessage()); assertEquals("wrong revision", 1, lm[0].getRevision().getNumber()); assertEquals("wrong user", "cedric", lm[0].getAuthor()); assertNotNull("changed paths set", lm[0].getChangedPaths()); ISVNLogMessageChangePath cp[] = lm[0].getChangedPaths(); assertEquals("wrong number of chang pathes", 20, cp.length); ISVNLogMessageChangePath cpA = null; for (int i = 0; i < cp.length; i++) { if ("/A".equals(cp[i].getPath())) { cpA = cp[i]; break; } } assertNotNull("/A is not in the changed pathes", cpA); assertEquals("wrong path", "/A", cpA.getPath()); assertEquals("wrong copy source rev", null, cpA.getCopySrcRevision()); assertNull("wrong copy source path", cpA.getCopySrcPath()); assertEquals("wrong action", 'A', cpA.getAction()); } public void testBasicLogUrlMessage() throws Exception { // create the working copy OneTest thisTest = new OneTest("basicLogUrlMessages", getGreekTestConfig()); // modify file iota File iota = new File(thisTest.getWorkingCopy(), "iota"); PrintWriter iotaPW = new PrintWriter(new FileOutputStream(iota, true)); iotaPW.print("new appended text for rho"); iotaPW.close(); assertEquals("wrong revision number from commit", 2, client.commit( new File[] { thisTest.getWCPath() }, "iota modified", true)); ISVNLogMessage lm[] = client.getLogMessages(new SVNUrl(thisTest .getUrl() + "/iota"), new SVNRevision.Number(1), SVNRevision.HEAD, true); assertEquals("wrong number of objects", 2, lm.length); assertEquals("wrong message", "Log Message", lm[0].getMessage()); assertEquals("wrong message", "iota modified", lm[1].getMessage()); ISVNLogMessageChangePath cp[] = lm[1].getChangedPaths(); assertEquals("wrong number of chang pathes", 1, cp.length); } /** * test the SVNClientInfo.logMessage functionality on outgoing/uncommitted rename/move * * @throws Throwable */ public void testUncommitedRenameLogMessage() throws Throwable { // create the working copy OneTest thisTest = new OneTest("ucommitedRenameLogMessage", getGreekTestConfig()); // move file iota File iota = new File(thisTest.getWorkingCopy(), "iota"); File iota2 = new File(thisTest.getWorkingCopy(), "iota2"); client.move(iota, iota2, true); ISVNLogMessage lm[] = client.getLogMessages(iota2, new SVNRevision.Number(1), SVNRevision.HEAD, true); assertEquals("wrong number of objects", 1, lm.length); assertEquals("wrong message", "Log Message", lm[0].getMessage()); assertEquals("wrong revision", 1, lm[0].getRevision().getNumber()); assertEquals("wrong user", "cedric", lm[0].getAuthor()); assertNotNull("changed paths set", lm[0].getChangedPaths()); ISVNLogMessageChangePath cp[] = lm[0].getChangedPaths(); assertEquals("wrong number of chang pathes", 20, cp.length); } //TODO enable this test when ISVNClientAdapter#getLogMessages(SVNUrl, java.lang.String[], SVNRevision, SVNRevision, boolean, boolean) will be implemented // public void testBasicLogUrlMultiPathMessage() throws Exception { // // create the working copy // OneTest thisTest = new OneTest("basicLogUrlMultiPathMessages", // getGreekTestConfig()); // // // modify file iota // File iota = new File(thisTest.getWorkingCopy(), "iota"); // PrintWriter iotaPW = new PrintWriter(new FileOutputStream(iota, true)); // iotaPW.print("new appended text for iota"); // iotaPW.close(); // // assertEquals("wrong revision number from commit", 2, client.commit( // new File[] { thisTest.getWCPath() }, "iota modified", true)); // // // modify file mu // File mu = new File(thisTest.getWorkingCopy(), "A/mu"); // PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true)); // muPW.print("new appended text for mu"); // muPW.close(); // // assertEquals("wrong revision number from commit", 3, client.commit( // new File[] { thisTest.getWCPath() }, "mu modified", true)); // // ISVNLogMessage lm[] = client.getLogMessages(thisTest.getUrl(), // new String[] { "iota", "A/mu" }, new SVNRevision.Number(1), SVNRevision.HEAD, false, true); // assertEquals("wrong number of objects", 3, lm.length); // assertEquals("wrong message", "Log Message", lm[0].getMessage()); // assertEquals("wrong message", "iota modified", lm[1].getMessage()); // assertEquals("wrong message", "mu modified", lm[2].getMessage()); // ISVNLogMessageChangePath cp[] = lm[1].getChangedPaths(); // assertEquals("wrong number of chang pathes", 1, cp.length); // cp = lm[2].getChangedPaths(); // assertEquals("wrong number of chang pathes", 1, cp.length); // } }svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/LsTest.java000066400000000000000000000115621203563747500340450ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import org.tigris.subversion.svnclientadapter.ISVNDirEntry; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class LsTest extends SVNTest { /** * test the basic SVNClient.list functionality * @throws Throwable */ public void testBasicLs() throws Throwable { // create the working copy OneTest thisTest = new OneTest("basicLs",getGreekTestConfig()); // list the repository root dir ISVNDirEntry[] entries = client.getList(thisTest.getWCPath(), SVNRevision.HEAD, false); thisTest.getExpectedWC().check(entries,"", false); // list directory A entries = client.getList(new File(thisTest.getWCPath()+"/A"), SVNRevision.HEAD, false); thisTest.getExpectedWC().check(entries,"A", false); // list directory A in BASE revision entries = client.getList(new File(thisTest.getWCPath()+"/A"), SVNRevision.BASE, false); thisTest.getExpectedWC().check(entries,"A", false); // list file A/mu entries = client.getList(new File(thisTest.getWCPath()+"/A/mu"), SVNRevision.HEAD, false); thisTest.getExpectedWC().check(entries,"A/mu"); } public void testBasicLsUrl() throws Throwable { // create the working copy OneTest thisTest = new OneTest("basicLsUrl",getGreekTestConfig()); ISVNDirEntry[] entries = client.getList(thisTest.getUrl(), SVNRevision.HEAD, true); thisTest.getExpectedRepository().check(entries,"", true); // list directory A entries = client.getList(new SVNUrl(thisTest.getUrl()+"/A"), SVNRevision.HEAD, false); thisTest.getExpectedRepository().check(entries,"A", false); } public void testGetDirEntryUrl() throws Throwable { // create the working copy OneTest thisTest = new OneTest("basicGetDirEntryUrl",getGreekTestConfig()); // get the dirEntry of a directory first ISVNDirEntry entry = client.getDirEntry(new SVNUrl(thisTest.getUrl()+"/A"), SVNRevision.HEAD); assertNotNull(entry); assertEquals(SVNNodeKind.DIR, entry.getNodeKind()); assertEquals(0, entry.getSize()); assertEquals("A", entry.getPath()); assertEquals(TEST_USER, entry.getLastCommitAuthor()); assertNotNull(entry.getLastChangedDate()); // then of a file entry = client.getDirEntry(new SVNUrl(thisTest.getUrl()+"/A/mu"), SVNRevision.HEAD); assertNotNull(entry); assertEquals(SVNNodeKind.FILE, entry.getNodeKind()); assertEquals("mu", entry.getPath()); assertEquals(TEST_USER, entry.getLastCommitAuthor()); assertNotNull(entry.getLastChangedDate()); } public void testGetDirEntryFile() throws Throwable { // create the working copy OneTest thisTest = new OneTest("basicGetDirEntryFile",getGreekTestConfig()); ISVNDirEntry entry; // directory entry = client.getDirEntry(new File(thisTest.getWCPath()+"/A"), SVNRevision.HEAD); assertNotNull(entry); assertEquals(SVNNodeKind.DIR, entry.getNodeKind()); assertEquals(0, entry.getSize()); assertEquals("A", entry.getPath()); assertEquals(TEST_USER, entry.getLastCommitAuthor()); assertNotNull(entry.getLastChangedDate()); // file entry = client.getDirEntry(new File(thisTest.getWCPath()+"/A/mu"), SVNRevision.HEAD); assertNotNull(entry); assertEquals(SVNNodeKind.FILE, entry.getNodeKind()); assertEquals(new File(thisTest.getWCPath()+"/A/mu").length(), entry.getSize()); assertEquals("mu", entry.getPath()); assertEquals(TEST_USER, entry.getLastCommitAuthor()); assertNotNull(entry.getLastChangedDate()); } } MkdirTest.java000066400000000000000000000113241203563747500344520ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.util.logging.Level; import java.util.logging.Logger; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class MkdirTest extends SVNTest { private static final Logger log = Logger.getLogger(MkdirTest.class.getName()); /** * test basic SVNClient.mkdir with url parameter functionality * @throws Throwable */ public void testBasicMkdirUrl() throws Throwable { // build the test setup. OneTest thisTest = new OneTest("basicMkdirUrl",getGreekTestConfig()); // create Y and Y/Z directories in the repository client.mkdir(new SVNUrl(thisTest.getUrl() + "/Y"),"log_msg"); client.mkdir(new SVNUrl(thisTest.getUrl() + "/Y/Z"),"log_msg"); // add the new directories the expected working copy layout thisTest.getExpectedWC().addItem("Y", null); thisTest.getExpectedWC().setItemWorkingCopyRevision("Y", 3); // should be 2 ... ? thisTest.getExpectedWC().addItem("Y/Z", null); thisTest.getExpectedWC().setItemWorkingCopyRevision("Y/Z", 3); // update the working copy assertEquals("wrong revision from update",3, client.update(thisTest.getWCPath(), SVNRevision.HEAD, true)); // check the status of the working copy thisTest.checkStatusesExpectedWC(); } /** * Test if Subversion will detect the change of a file to a direcory * @throws Throwable */ public void testBasicNodeKindChange() throws Throwable { // create working copy OneTest thisTest = new OneTest("basicNodeKindChange",getGreekTestConfig()); // remove A/D/gamma client.remove(new File[] {new File(thisTest.getWCPath()+"/A/D/gamma")}, false); thisTest.getExpectedWC().setItemTextStatus("A/D/gamma", SVNStatusKind.DELETED); // check the working copy status thisTest.checkStatusesExpectedWC(); try { // creating a directory in the place of the deleted file should // fail client.mkdir(new File(thisTest.getWCPath()+"/A/D/gamma")); fail("can change node kind"); } catch(SVNClientException e) { log.log(Level.FINE, e.getMessage(), e); } // check the working copy status thisTest.checkStatusesExpectedWC(); // commit the deletion assertEquals("wrong revision number from commit",2, client.commit(new File[]{thisTest.getWCPath()},"log message", true)); thisTest.getExpectedWC().removeItem("A/D/gamma"); // check the working copy status thisTest.checkStatusesExpectedWC(); try { // creating a directory in the place of the deleted file should // still fail client.mkdir(new File(thisTest.getWCPath()+"/A/D/gamma")); fail("can change node kind"); } catch(SVNClientException e) { log.log(Level.FINE, e.getMessage(), e); } // check the working copy status thisTest.checkStatusesExpectedWC(); // update the working copy client.update(thisTest.getWCPath(), SVNRevision.HEAD, true); // check the working copy status thisTest.checkStatusesExpectedWC(); // now creating the directory should succeed client.mkdir(new File(thisTest.getWCPath()+"/A/D/gamma")); thisTest.getExpectedWC().addItem("A/D/gamma", null); thisTest.getExpectedWC().setItemTextStatus("A/D/gamma", SVNStatusKind.ADDED); // check the working copy status thisTest.checkStatusesExpectedWC(); } } MoveTest.java000066400000000000000000000147601203563747500343210ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class MoveTest extends SVNTest { public void testBasicMoveFile() throws Throwable { // build the test setup. OneTest thisTest = new OneTest("basicMoveFile",getGreekTestConfig()); File src = new File(thisTest.getWorkingCopy() + "/A/mu"); File dst = new File(thisTest.getWorkingCopy() + "/A/C/mu"); client.move(src, dst, true); thisTest.getExpectedWC().setItemTextStatus("A/mu", SVNStatusKind.DELETED); thisTest.getExpectedWC().addItem("A/C/mu", null); thisTest.getExpectedWC().setItemTextStatus("A/C/mu", SVNStatusKind.ADDED); thisTest.getExpectedWC().setItemIsCopied("A/C/mu", true); // test the working copy status thisTest.checkStatusesExpectedWC(); // try to move an entire directory src = new File(thisTest.getWorkingCopy() + "/A/D"); dst = new File(thisTest.getWorkingCopy() + "/A/E"); client.move(src, dst, true); thisTest.getExpectedWC().setItemTextStatus("A/D", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/gamma", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/H", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/H/chi", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/H/psi", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/H/omega", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/G", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/G/pi", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/G/rho", SVNStatusKind.DELETED); thisTest.getExpectedWC().setItemTextStatus("A/D/G/tau", SVNStatusKind.DELETED); thisTest.getExpectedWC().addItem("A/E", null); thisTest.getExpectedWC().setItemTextStatus("A/E", SVNStatusKind.ADDED); thisTest.getExpectedWC().setItemIsCopied("A/E", true); thisTest.getExpectedWC().addItem("A/E/gamma", null); thisTest.getExpectedWC().setItemTextStatus("A/E/gamma", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/gamma", true); thisTest.getExpectedWC().addItem("A/E/H", null); thisTest.getExpectedWC().setItemTextStatus("A/E/H", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/H", true); thisTest.getExpectedWC().addItem("A/E/H/chi", null); thisTest.getExpectedWC().setItemTextStatus("A/E/H/chi", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/H/chi", true); thisTest.getExpectedWC().addItem("A/E/H/psi", null); thisTest.getExpectedWC().setItemTextStatus("A/E/H/psi", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/H/psi", true); thisTest.getExpectedWC().addItem("A/E/H/omega", null); thisTest.getExpectedWC().setItemTextStatus("A/E/H/omega", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/H/omega", true); thisTest.getExpectedWC().addItem("A/E/G", null); thisTest.getExpectedWC().setItemTextStatus("A/E/G", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/G", true); thisTest.getExpectedWC().addItem("A/E/G/pi", null); thisTest.getExpectedWC().setItemTextStatus("A/E/G/pi", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/G/pi", true); thisTest.getExpectedWC().addItem("A/E/G/rho", null); thisTest.getExpectedWC().setItemTextStatus("A/E/G/rho", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/G/rho", true); thisTest.getExpectedWC().addItem("A/E/G/tau", null); thisTest.getExpectedWC().setItemTextStatus("A/E/G/tau", SVNStatusKind.NORMAL); thisTest.getExpectedWC().setItemIsCopied("A/E/G/tau", true); thisTest.checkStatusesExpectedWC(); } public void testMoveUrl2Url() throws Throwable { // create working copy OneTest thisTest = new OneTest("basicMoveUrl2Url", getGreekTestConfig()); client.move(new SVNUrl(thisTest.getUrl() + "/A/B"), new SVNUrl(thisTest .getUrl() + "/B"), "log msg", SVNRevision.HEAD); // update the working copy client.update(thisTest.getWCPath(), SVNRevision.HEAD, true); thisTest.getExpectedWC().removeItem("A/B"); thisTest.getExpectedWC().removeItem("A/B/lambda"); thisTest.getExpectedWC().removeItem("A/B/E"); thisTest.getExpectedWC().removeItem("A/B/E/alpha"); thisTest.getExpectedWC().removeItem("A/B/E/beta"); thisTest.getExpectedWC().removeItem("A/B/F"); thisTest.getExpectedWC().addItem("B", null); thisTest.getExpectedWC().addItem("B/lambda", "This is the file 'lambda'."); thisTest.getExpectedWC().addItem("B/E", null); thisTest.getExpectedWC().addItem("B/E/alpha", "This is the file 'alpha'."); thisTest.getExpectedWC().addItem("B/E/beta", "This is the file 'beta'."); thisTest.getExpectedWC().addItem("B/F", null); thisTest.checkStatusesExpectedWC(); } } PropertiesTest.java000066400000000000000000000120371203563747500355420ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.util.HashMap; import java.util.Map; import org.tigris.subversion.svnclientadapter.ISVNProperty; import org.tigris.subversion.svnclientadapter.SVNKeywords; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class PropertiesTest extends SVNTest { public void testBasicProperties() throws Throwable { // build the test setup. OneTest thisTest = new OneTest("basicProperties", getGreekTestConfig()); File dir = new File(thisTest.getWorkingCopy() + "/A"); File file = new File(thisTest.getWorkingCopy() + "/A/mu"); SVNUrl fileUrl = new SVNUrl(thisTest.getUrl()+ "/A/mu"); client.propertySet(file, "myProp", "my value", false); client.propertySet(dir, "myProp2", "my value 2", true); // get properties using getProperties ISVNProperty[] properties = client.getProperties(file); assertEquals(2, properties.length); Map map = new HashMap(); for (int i = 0; i < properties.length; i++) { map.put(properties[i].getName(), properties[i]); } ISVNProperty prop = (ISVNProperty) map.get("myProp"); assertNotNull(prop); assertEquals("my value", prop.getValue()); prop = (ISVNProperty) map.get("myProp2"); assertNotNull(prop); assertEquals("my value 2", prop.getValue()); // get property using propertyGet on file prop = client.propertyGet(file, "myProp"); assertNotNull(prop); assertEquals("myProp", prop.getName()); assertEquals("my value", prop.getValue()); assertEquals(file, prop.getFile()); assertNull(prop.getUrl()); //commit the wc so we can test the properties on URL client.commit(new File[] {dir}, "Commited properties", true); // get property using propertyGet on url prop = client.propertyGet(fileUrl, "myProp"); assertNotNull(prop); assertEquals("myProp", prop.getName()); assertEquals("my value", prop.getValue()); assertEquals(fileUrl, prop.getUrl()); assertNull(prop.getFile()); // delete properties client.propertyDel(dir,"myProp2",true); prop = client.propertyGet(file, "myProp2"); assertNull(prop); //commit with deleteted property so we can test the properties on URL and revisions client.commit(new File[] {dir}, "Commited properties", true); long lastChangedRevision = client.getInfo(file).getLastChangedRevision().getNumber(); //the last changed revision of the file does not have the property prop = client.propertyGet(fileUrl, SVNRevision.getRevision("" +lastChangedRevision), SVNRevision.HEAD, "myProp2"); assertNull(prop); //the revision before has the property prop = client.propertyGet(fileUrl, SVNRevision.getRevision("" + --lastChangedRevision), SVNRevision.HEAD, "myProp2"); assertNotNull(prop); } public void testBasicKeywords() throws Throwable { OneTest thisTest = new OneTest("basicGetProperties", getGreekTestConfig()); File dir = new File(thisTest.getWorkingCopy() + "/A"); SVNKeywords keywords = new SVNKeywords(); keywords.setLastChangedDate(true); keywords.setLastChangedRevision(true); client.setKeywords(dir, keywords,true); keywords = client.getKeywords(dir); assertFalse(keywords.isLastChangedDate()); assertFalse(keywords.isLastChangedRevision()); File fileMu = new File(thisTest.getWorkingCopy() + "/A/mu"); keywords = new SVNKeywords(); keywords.setLastChangedDate(true); keywords.setLastChangedRevision(true); client.setKeywords(dir, keywords,true); keywords = client.getKeywords(fileMu); assertTrue(keywords.isLastChangedDate()); assertTrue(keywords.isLastChangedRevision()); } }ResolveTest.java000066400000000000000000000177141203563747500350340ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.io.FileOutputStream; import java.io.PrintWriter; import org.tigris.subversion.svnclientadapter.ISVNStatus; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class ResolveTest extends SVNTest { /** * test the basic SVNClient.update functionality with concurrent changes * in the repository and the working copy that generate conflicts * @throws Throwable */ public void testBasicConflict() throws Throwable { // build the first working copy OneTest thisTest = new OneTest("basicConflict",getGreekTestConfig()); // copy the first working copy to the backup working copy OneTest backupTest = thisTest.copy(".backup"); // append a line to A/mu in the first working copy File mu = new File(thisTest.getWorkingCopy(), "A/mu"); PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true)); String muContent = thisTest.getExpectedWC().getItemContent("A/mu"); muPW.print("\nOriginal appended text for mu"); muContent = muContent + "\nOriginal appended text for mu"; muPW.close(); thisTest.getExpectedWC().setItemWorkingCopyRevision("A/mu", 2); thisTest.getExpectedWC().setItemContent("A/mu", muContent); // append a line to A/D/G/rho in the first working copy File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho"); PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true)); String rhoContent = thisTest.getExpectedWC().getItemContent("A/D/G/rho"); rhoPW.print("\nOriginal appended text for rho"); rhoContent = rhoContent + "\nOriginal appended text for rho"; rhoPW.close(); thisTest.getExpectedWC().setItemWorkingCopyRevision("A/D/G/rho", 2); thisTest.getExpectedWC().setItemContent("A/D/G/rho", rhoContent); // commit the changes in the first working copy assertEquals("wrong revision number from commit",2, client.commit(new File[]{thisTest.getWCPath()}, "log msg", true)); // test the status of the working copy after the commit thisTest.checkStatusesExpectedWC(); // append a different line to A/mu in the backup working copy mu = new File(backupTest.getWorkingCopy(), "A/mu"); muPW = new PrintWriter(new FileOutputStream(mu, true)); muPW.print("\nConflicting appended text for mu"); muContent = "<<<<<<< .mine\nThis is the file 'mu'.\n"+ "Conflicting appended text for mu=======\n"+ "This is the file 'mu'.\n"+ "Original appended text for mu>>>>>>> .r2"; muPW.close(); backupTest.getExpectedWC().setItemWorkingCopyRevision("A/mu", 2); backupTest.getExpectedWC().setItemContent("A/mu", muContent); backupTest.getExpectedWC().setItemTextStatus("A/mu", SVNStatusKind.CONFLICTED); backupTest.getExpectedWC().addItem("A/mu.r1", ""); backupTest.getExpectedWC().setItemNodeKind("A/mu.r1", SVNNodeKind.UNKNOWN); backupTest.getExpectedWC().setItemTextStatus("A/mu.r1", SVNStatusKind.UNVERSIONED); backupTest.getExpectedWC().addItem("A/mu.r2", ""); backupTest.getExpectedWC().setItemNodeKind("A/mu.r2", SVNNodeKind.UNKNOWN); backupTest.getExpectedWC().setItemTextStatus("A/mu.r2", SVNStatusKind.UNVERSIONED); backupTest.getExpectedWC().addItem("A/mu.mine", ""); backupTest.getExpectedWC().setItemNodeKind("A/mu.mine", SVNNodeKind.UNKNOWN); backupTest.getExpectedWC().setItemTextStatus("A/mu.mine", SVNStatusKind.UNVERSIONED); // append a different line to A/D/G/rho in the backup working copy rho = new File(backupTest.getWorkingCopy(), "A/D/G/rho"); rhoPW = new PrintWriter(new FileOutputStream(rho, true)); rhoPW.print("\nConflicting appended text for rho"); rhoContent = "<<<<<<< .mine\nThis is the file 'rho'.\n"+ "Conflicting appended text for rho=======\n"+ "his is the file 'rho'.\n"+ "Original appended text for rho>>>>>>> .r2"; rhoPW.close(); backupTest.getExpectedWC().setItemWorkingCopyRevision("A/D/G/rho", 2); backupTest.getExpectedWC().setItemContent("A/D/G/rho", rhoContent); backupTest.getExpectedWC().setItemTextStatus("A/D/G/rho", SVNStatusKind.CONFLICTED); backupTest.getExpectedWC().addItem("A/D/G/rho.r1", ""); backupTest.getExpectedWC().setItemNodeKind("A/D/G/rho.r1", SVNNodeKind.UNKNOWN); backupTest.getExpectedWC().setItemTextStatus("A/D/G/rho.r1", SVNStatusKind.UNVERSIONED); backupTest.getExpectedWC().addItem("A/D/G/rho.r2", ""); backupTest.getExpectedWC().setItemNodeKind("A/D/G/rho.r2", SVNNodeKind.UNKNOWN); backupTest.getExpectedWC().setItemTextStatus("A/D/G/rho.r2", SVNStatusKind.UNVERSIONED); backupTest.getExpectedWC().addItem("A/D/G/rho.mine", ""); backupTest.getExpectedWC().setItemNodeKind("A/D/G/rho.mine", SVNNodeKind.UNKNOWN); backupTest.getExpectedWC().setItemTextStatus("A/D/G/rho.mine", SVNStatusKind.UNVERSIONED); // update the backup working copy from the repository assertEquals("wrong revision number from update",2, client.update(backupTest.getWCPath(), SVNRevision.HEAD, true)); // check the status of the backup working copy backupTest.checkStatusesExpectedWC(); //check the conflicting* fields of status ISVNStatus rhoStatus = client.getSingleStatus(rho); assertEquals(new File(backupTest.getWorkingCopy() + "/A/D/G/rho.mine"), rhoStatus.getConflictWorking()); assertEquals(new File(backupTest.getWorkingCopy() + "/A/D/G/rho.r1"), rhoStatus.getConflictOld()); assertEquals(new File(backupTest.getWorkingCopy() + "/A/D/G/rho.r2"), rhoStatus.getConflictNew()); // flag A/mu as resolved client.resolved(new File(backupTest.getWCPath()+"/A/mu")); backupTest.getExpectedWC().setItemTextStatus("A/mu", SVNStatusKind.MODIFIED); backupTest.getExpectedWC().removeItem("A/mu.r1"); backupTest.getExpectedWC().removeItem("A/mu.r2"); backupTest.getExpectedWC().removeItem("A/mu.mine"); // flag A/D/G/rho as resolved client.resolved(new File(backupTest.getWCPath()+"/A/D/G/rho")); backupTest.getExpectedWC().setItemTextStatus("A/D/G/rho", SVNStatusKind.MODIFIED); backupTest.getExpectedWC().removeItem("A/D/G/rho.r1"); backupTest.getExpectedWC().removeItem("A/D/G/rho.r2"); backupTest.getExpectedWC().removeItem("A/D/G/rho.mine"); // check the status after the conflicts are flaged as resolved backupTest.checkStatusesExpectedWC(); } } RevertTest.java000066400000000000000000000127551203563747500346640ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.io.FileOutputStream; import java.io.PrintWriter; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.testUtils.FileUtils; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class RevertTest extends SVNTest { /** * Test the basic SVNClient.revert functionality * @throws Throwable */ public void testBasicRevert() throws Throwable { // create a test working copy OneTest thisTest = new OneTest("basicRevert",getGreekTestConfig()); // modify A/B/E/beta File file = new File(thisTest.getWorkingCopy(), "A/B/E/beta"); PrintWriter pw = new PrintWriter(new FileOutputStream(file, true)); pw.print("Added some text to 'beta'."); pw.close(); thisTest.getExpectedWC().setItemTextStatus("A/B/E/beta", SVNStatusKind.MODIFIED); // modify iota file = new File(thisTest.getWorkingCopy(), "iota"); pw = new PrintWriter(new FileOutputStream(file, true)); pw.print("Added some text to 'iota'."); pw.close(); thisTest.getExpectedWC().setItemTextStatus("iota", SVNStatusKind.MODIFIED); // modify A/D/G/rho file = new File(thisTest.getWorkingCopy(), "A/D/G/rho"); pw = new PrintWriter(new FileOutputStream(file, true)); pw.print("Added some text to 'rho'."); pw.close(); thisTest.getExpectedWC().setItemTextStatus("A/D/G/rho", SVNStatusKind.MODIFIED); // create new file A/D/H/zeta and add it to subversion file = new File(thisTest.getWorkingCopy(), "A/D/H/zeta"); pw = new PrintWriter(new FileOutputStream(file, true)); pw.print("Added some text to 'zeta'."); pw.close(); thisTest.getExpectedWC().addItem("A/D/H/zeta", "Added some text to 'zeta'."); thisTest.getExpectedWC().setItemTextStatus("A/D/H/zeta", SVNStatusKind.ADDED); client.addFile(file); // test the status of the working copy thisTest.checkStatusesExpectedWC(); // revert the changes client.revert(new File(thisTest.getWCPath()+"/A/B/E/beta"), false); thisTest.getExpectedWC().setItemTextStatus("A/B/E/beta", SVNStatusKind.NORMAL); client.revert(new File(thisTest.getWCPath()+"/iota"), false); thisTest.getExpectedWC().setItemTextStatus("iota", SVNStatusKind.NORMAL); client.revert(new File(thisTest.getWCPath()+"/A/D/G/rho"), false); thisTest.getExpectedWC().setItemTextStatus("A/D/G/rho", SVNStatusKind.NORMAL); client.revert(new File(thisTest.getWCPath()+"/A/D/H/zeta"), false); thisTest.getExpectedWC().setItemTextStatus("A/D/H/zeta", SVNStatusKind.UNVERSIONED); thisTest.getExpectedWC().setItemNodeKind("A/D/H/zeta", SVNNodeKind.UNKNOWN); // test the status of the working copy thisTest.checkStatusesExpectedWC(); // delete A/B/E/beta and revert the change file = new File(thisTest.getWorkingCopy(), "A/B/E/beta"); file.delete(); client.revert(file,false); // resurected file should not be readonly assertTrue("reverted file is not readonly", file.canWrite()&& file.canRead()); // test the status of the working copy thisTest.checkStatusesExpectedWC(); // create & add the directory X client.mkdir(new File(thisTest.getWCPath()+"/X")); thisTest.getExpectedWC().addItem("X", null); thisTest.getExpectedWC().setItemTextStatus("X", SVNStatusKind.ADDED); // test the status of the working copy thisTest.checkStatusesExpectedWC(); // remove & revert X FileUtils.removeDirectoryWithContent(new File(thisTest.getWorkingCopy(), "X")); client.revert(new File(thisTest.getWCPath()+"/X"), false); thisTest.getExpectedWC().removeItem("X"); // test the status of the working copy thisTest.checkStatusesExpectedWC(); // delete the directory A/B/E client.remove(new File[] {new File(thisTest.getWCPath()+"/A/B/E")}, true); FileUtils.removeDirectoryWithContent(new File(thisTest.getWorkingCopy(), "A/B/E")); thisTest.getExpectedWC().setItemTextStatus("A/B/E", SVNStatusKind.DELETED); thisTest.getExpectedWC().removeItem("A/B/E/alpha"); thisTest.getExpectedWC().removeItem("A/B/E/beta"); // test the status of the working copy thisTest.checkStatusesExpectedWC(); // revert A/B/E -> this will not resurect it client.revert(new File(thisTest.getWCPath()+"/A/B/E"), true); // test the status of the working copy thisTest.checkStatusesExpectedWC(); } } SVNBasicTestsSuite.java000066400000000000000000000061141203563747500362120ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.IOException; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.testUtils.SvnServer; import org.tigris.subversion.svnclientadapter.testUtils.TestsConfig; import junit.framework.TestResult; import junit.framework.TestSuite; public abstract class SVNBasicTestsSuite extends TestSuite { public SVNBasicTestsSuite(String name) { super(name); } public void run(TestResult result) { TestsConfig testsConfig = null; try { testsConfig = TestsConfig.getTestsConfig(); } catch (SVNClientException e) { throw new RuntimeException(e); } SvnServer svnServer; try { System.out.print("Staring test suite's svnServer: "); svnServer = SvnServer.startSvnServer(testsConfig.serverHostname, testsConfig.serverPort, testsConfig.rootDir); System.out.println("done."); } catch (IOException e) { throw new RuntimeException(e); } super.run(result); System.out.print("Stopping test suite's svnServer: "); SvnServer.stopSvnServer(svnServer); System.out.println("done."); } protected static void addTestsToSuite(TestSuite testSuite) { testSuite.addTestSuite(AddTest.class); testSuite.addTestSuite(BlameTest.class); testSuite.addTestSuite(CatTest.class); testSuite.addTestSuite(CheckOutTest.class); testSuite.addTestSuite(CleanupTest.class); testSuite.addTestSuite(CommitTest.class); testSuite.addTestSuite(CopyTest.class); // testSuite.addTestSuite(DeleteTest.class); testSuite.addTestSuite(ExportTest.class); // testSuite.addTestSuite(ImportTest.class); testSuite.addTestSuite(InfoTest.class); testSuite.addTestSuite(LogTest.class); testSuite.addTestSuite(LsTest.class); testSuite.addTestSuite(MkdirTest.class); testSuite.addTestSuite(MoveTest.class); // testSuite.addTestSuite(PropertiesTest.class); testSuite.addTestSuite(ResolveTest.class); testSuite.addTestSuite(RevertTest.class); testSuite.addTestSuite(StatusTest.class); testSuite.addTestSuite(SwitchTest.class); testSuite.addTestSuite(UpdateTest.class); } } SVNCmdLineTests.java000066400000000000000000000025261203563747500354750ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import junit.framework.TestSuite; public class SVNCmdLineTests extends SVNBasicTestsSuite { public SVNCmdLineTests(String name) { super(name); } public static TestSuite suite() { System.setProperty("test.clientType","commandline"); TestSuite testSuite = new SVNCmdLineTests("Test group"); addTestsToSuite(testSuite); return testSuite; } } SVNJavahlTests.java000066400000000000000000000026011203563747500353610ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import junit.framework.TestSuite; public class SVNJavahlTests extends SVNBasicTestsSuite { public SVNJavahlTests(String name) { super(name); } public static TestSuite suite() { System.setProperty("test.clientType","javahl"); System.setProperty("test.protocol","svn"); TestSuite testSuite = new SVNJavahlTests("Test group"); addTestsToSuite(testSuite); return testSuite; } } SVNSvnKitTests.java000066400000000000000000000027711203563747500354020ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import junit.framework.TestSuite; public class SVNSvnKitTests extends SVNBasicTestsSuite { public SVNSvnKitTests(String name) { super(name); } public static TestSuite suite() { System.setProperty("test.clientType","svnkit"); System.setProperty("test.protocol","svn"); // System.setProperty("test.serverHostname","127.0.0.1"); // System.setProperty("test.serverPort","svn"); TestSuite testSuite = new SVNSvnKitTests("Test group"); addTestsToSuite(testSuite); return testSuite; } } StatusTest.java000066400000000000000000000334261203563747500346760ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.io.FileOutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import org.tigris.subversion.svnclientadapter.ISVNStatus; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class StatusTest extends SVNTest { /** * test the basic SVNClient.status functionality * @throws Throwable */ public void testBasicStatus() throws Throwable { // build the test setup OneTest thisTest = new OneTest("basicStatus",getGreekTestConfig()); // check the status of the working copy thisTest.checkStatusesExpectedWC(); } public void testStatusUpdate() throws Throwable { // build the test setup OneTest thisTest = new OneTest("statusUpdate",getGreekTestConfig()); // modify file A/mu File mu = new File(thisTest.getWorkingCopy(), "A/mu"); PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true)); muPW.print("appended mu text"); muPW.close(); // commit the changes client.commit(new File[]{thisTest.getWCPath()}, "log msg", true); // modify file A/D/G/rho File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho"); PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true)); rhoPW.print("new appended text for rho"); rhoPW.close(); // commit the changes client.commit(new File[]{thisTest.getWCPath()}, "log msg", true); ISVNStatus[] statuses; statuses = client.getStatus(rho, false, true, false); assertEquals("WC in wrong revision", SVNRevision.getRevision("3"), statuses[0].getRevision()); //switch back so we can see incoming changes client.switchToUrl(thisTest.getWCPath(), thisTest.getUrl(), SVNRevision.getRevision("1"), true); statuses = client.getStatus(rho, false, true, false); assertEquals("WC in wrong revision after switch", SVNRevision.getRevision("1"), statuses[0].getRevision()); //Check the WC status - no outgoing change expected statuses = client.getStatus(thisTest.getWCPath(), true, false, false); assertEquals("Wrong nuber of statuses returned", 0, statuses.length); //Check the repo status - 2 incoming changes expected. statuses = client.getStatus(thisTest.getWCPath(), true, false, true); assertEquals("Wrong nuber of statuses returned", 2, statuses.length); assertEquals("Wrong wc text status", SVNStatusKind.NORMAL, statuses[0].getTextStatus()); assertEquals("Wrong repository text status", SVNStatusKind.MODIFIED, statuses[0].getRepositoryTextStatus()); assertEquals("Wrong wc text status", SVNStatusKind.NORMAL, statuses[1].getTextStatus()); assertEquals("Wrong repository text status", SVNStatusKind.MODIFIED, statuses[1].getRepositoryTextStatus()); // check the status of the working copy thisTest.checkStatusesExpectedWC(); } public void testStatusOnIgnored() throws Throwable { // build the test setup OneTest thisTest = new OneTest("statusOnIgnored",getGreekTestConfig()); // create dir File dir = new File(thisTest.getWorkingCopy(), "dir"); dir.mkdir(); // add dir client.addDirectory(dir, true); List ignoredPatterns = new ArrayList(); ignoredPatterns.add("ignored"); client.setIgnoredPatterns(dir, ignoredPatterns); client.commit(new File[]{thisTest.getWCPath()}, "log msg", true); // create dir/ignored (should be ignored) File dirIgn = new File(dir, "ignored"); dirIgn.mkdir(); File fileIgn = new File(dirIgn, "ignoredFile"); new FileOutputStream(fileIgn).close(); File subdirIgn = new File(dirIgn, "subIgnored"); subdirIgn.mkdir(); File fileIgn2 = new File(subdirIgn, "ignoredFile2"); new FileOutputStream(fileIgn2).close(); ISVNStatus[] statuses; ISVNStatus status; //Check status of the ignored resource statuses = client.getStatus(dirIgn, true, true, false); assertEquals("Wrong nuber of statuses returned", 1, statuses.length); assertEquals("Wrong text status", SVNStatusKind.IGNORED, statuses[0].getTextStatus()); status = client.getSingleStatus(dirIgn); assertEquals("Wrong text status", SVNStatusKind.IGNORED, status.getTextStatus()); //Check status withing the ignored resource statuses = client.getStatus(fileIgn, true, true, false); assertEquals("Wrong nuber of statuses returned", 1, statuses.length); assertEquals("Wrong text status", SVNStatusKind.UNVERSIONED, statuses[0].getTextStatus()); status = client.getSingleStatus(fileIgn); assertEquals("Wrong text status", SVNStatusKind.UNVERSIONED, status.getTextStatus()); statuses = client.getStatus(subdirIgn, true, true, false); assertEquals("Wrong nuber of statuses returned", 1, statuses.length); assertEquals("Wrong text status", SVNStatusKind.UNVERSIONED, statuses[0].getTextStatus()); status = client.getSingleStatus(subdirIgn); assertEquals("Wrong text status", SVNStatusKind.UNVERSIONED, status.getTextStatus()); statuses = client.getStatus(fileIgn2, true, true, false); assertEquals("Wrong nuber of statuses returned", 1, statuses.length); assertEquals("Wrong text status", SVNStatusKind.UNVERSIONED, statuses[0].getTextStatus()); status = client.getSingleStatus(fileIgn2); assertEquals("Wrong text status", SVNStatusKind.UNVERSIONED, status.getTextStatus()); } public void testSingleStatus() throws Throwable { // build the test setup OneTest thisTest = new OneTest("singleStatus",getGreekTestConfig()); File mu = new File(thisTest.getWorkingCopy(), "A/mu"); File g = new File(thisTest.getWorkingCopy(), "A/D/G"); File unversionedDir = new File(thisTest.getWorkingCopy(), "unversionedDir"); unversionedDir.mkdir(); File unversionedFile = new File(unversionedDir, "unversionedFile"); new FileOutputStream(unversionedFile).close(); File unversionedSubDir = new File(unversionedDir, "unversionedSubDir"); unversionedSubDir.mkdir(); File nonExistentFile = new File(thisTest.getWorkingCopy(), "nonExistentFile"); ISVNStatus status; status = client.getSingleStatus(mu); assertEquals("Wrong text status", SVNStatusKind.NORMAL, status.getTextStatus()); assertEquals("Wrong prop status", SVNStatusKind.NONE, status.getPropStatus()); assertEquals("Wrong revision", SVNRevision.getRevision("1"), status.getRevision()); assertEquals("Wrong last changed revision", SVNRevision.getRevision("1"), status.getLastChangedRevision()); assertEquals("Wrong nodeKind", SVNNodeKind.FILE, status.getNodeKind()); assertEquals("Wrong path", mu, status.getFile()); status = client.getSingleStatus(g); assertEquals("Wrong text status", SVNStatusKind.NORMAL, status.getTextStatus()); assertEquals("Wrong prop status", SVNStatusKind.NONE, status.getPropStatus()); assertEquals("Wrong revision", SVNRevision.getRevision("1"), status.getRevision()); assertEquals("Wrong last changed revision", SVNRevision.getRevision("1"), status.getLastChangedRevision()); assertEquals("Wrong nodeKind", SVNNodeKind.DIR, status.getNodeKind()); assertEquals("Wrong path", g, status.getFile()); status = client.getSingleStatus(unversionedDir); assertEquals("Wrong text status", SVNStatusKind.UNVERSIONED, status.getTextStatus()); assertEquals("Wrong prop status", SVNStatusKind.NONE, status.getPropStatus()); assertEquals("Wrong revision", null, status.getRevision()); assertEquals("Wrong path", unversionedDir, status.getFile()); status = client.getSingleStatus(unversionedFile); assertEquals("Wrong text status", SVNStatusKind.UNVERSIONED, status.getTextStatus()); assertEquals("Wrong prop status", SVNStatusKind.NONE, status.getPropStatus()); assertEquals("Wrong revision", null, status.getRevision()); assertEquals("Wrong path", unversionedFile, status.getFile()); status = client.getSingleStatus(unversionedSubDir); assertEquals("Wrong text status", SVNStatusKind.UNVERSIONED, status.getTextStatus()); assertEquals("Wrong prop status", SVNStatusKind.NONE, status.getPropStatus()); assertEquals("Wrong revision", null, status.getRevision()); assertEquals("Wrong path", unversionedSubDir, status.getFile()); status = client.getSingleStatus(nonExistentFile); assertEquals("Wrong text status", SVNStatusKind.UNVERSIONED, status.getTextStatus()); assertEquals("Wrong prop status", SVNStatusKind.NONE, status.getPropStatus()); assertEquals("Wrong revision", null, status.getRevision()); assertEquals("Wrong path", nonExistentFile, status.getFile()); status = client.getSingleStatus(thisTest.getWorkingCopy()); assertEquals("Wrong text status", SVNStatusKind.NORMAL, status.getTextStatus()); assertEquals("Wrong prop status", SVNStatusKind.NONE, status.getPropStatus()); assertEquals("Wrong revision", SVNRevision.getRevision("1"), status.getRevision()); assertEquals("Wrong last changed revision", SVNRevision.getRevision("1"), status.getLastChangedRevision()); assertEquals("Wrong nodeKind", SVNNodeKind.DIR, status.getNodeKind()); assertEquals("Wrong path", thisTest.getWorkingCopy(), status.getFile()); } public void testMulitStatus() throws Throwable { // build the test setup OneTest thisTest = new OneTest("multiStatus",getGreekTestConfig()); File mu = new File(thisTest.getWorkingCopy(), "A/mu"); File g = new File(thisTest.getWorkingCopy(), "A/D/G"); File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho"); File[] files = new File[] {g ,mu, rho}; ISVNStatus[] statuses; statuses = client.getStatus(files); assertEquals("Wrong text status", SVNStatusKind.NORMAL, statuses[0].getTextStatus()); assertEquals("Wrong prop status", SVNStatusKind.NONE, statuses[0].getPropStatus()); assertEquals("Wrong revision", SVNRevision.getRevision("1"), statuses[0].getRevision()); assertEquals("Wrong last changed revision", SVNRevision.getRevision("1"), statuses[0].getLastChangedRevision()); assertEquals("Wrong nodeKind", SVNNodeKind.DIR, statuses[0].getNodeKind()); assertEquals("Wrong path", g, statuses[0].getFile()); assertEquals("Wrong text status", SVNStatusKind.NORMAL, statuses[1].getTextStatus()); assertEquals("Wrong prop status", SVNStatusKind.NONE, statuses[1].getPropStatus()); assertEquals("Wrong revision", SVNRevision.getRevision("1"), statuses[1].getRevision()); assertEquals("Wrong last changed revision", SVNRevision.getRevision("1"), statuses[1].getLastChangedRevision()); assertEquals("Wrong nodeKind", SVNNodeKind.FILE, statuses[1].getNodeKind()); assertEquals("Wrong path", mu, statuses[1].getFile()); assertEquals("Wrong text status", SVNStatusKind.NORMAL, statuses[2].getTextStatus()); assertEquals("Wrong prop status", SVNStatusKind.NONE, statuses[2].getPropStatus()); assertEquals("Wrong revision", SVNRevision.getRevision("1"), statuses[2].getRevision()); assertEquals("Wrong last changed revision", SVNRevision.getRevision("1"), statuses[2].getLastChangedRevision()); assertEquals("Wrong nodeKind", SVNNodeKind.FILE, statuses[2].getNodeKind()); assertEquals("Wrong path", rho, statuses[2].getFile()); } public void testStatusWithExternals() throws Throwable { // build the test setup OneTest thisTest = new OneTest("statusWithExternals",getGreekTestConfig(), getNumericTestConfig()); // check the status of the working copy thisTest.checkStatusesExpectedWCIgnoreExternals(); //Test with the ignoreExternals flag on first //Check that url is always present. Used to be missing on the external resource itself ISVNStatus[] states = client.getStatus(thisTest.getWorkingCopy(), true, true, false, true); for (int i = 0; i < states.length; i++) { assertNotNull(states[i].getUrlString()); } //Test with the ignoreExternals flag off now thisTest.getExpectedWC().addExternalPartWC(getNumericTestConfig().getExpectedWC(), "A/E"); thisTest.getExpectedWC().setItemTextStatus("A/E", SVNStatusKind.EXTERNAL); thisTest.checkStatusesExpectedWC(); } } SwitchTest.java000066400000000000000000000055271203563747500346550ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class SwitchTest extends SVNTest { /** * thest the basic SVNClient.switch functionality * @throws Throwable */ public void testBasicSwitch() throws Throwable { // create the test working copy OneTest thisTest = new OneTest("basicSwitch",getGreekTestConfig()); // switch iota to A/D/gamma File iotaPath = new File(thisTest.getWCPath() + "/iota"); SVNUrl gammaUrl = new SVNUrl(thisTest.getUrl() + "/A/D/gamma"); thisTest.getExpectedWC().setItemContent("iota", thisTest.getExpectedWC().getItemContent("A/D/gamma")); thisTest.getExpectedWC().setItemIsSwitched("iota", true); client.switchToUrl(iotaPath, gammaUrl, SVNRevision.HEAD, true); // check the status of the working copy thisTest.checkStatusesExpectedWC(); // switch A/D/H to /A/D/G File adhPath = new File(thisTest.getWCPath() + "/A/D/H"); SVNUrl adgURL = new SVNUrl(thisTest.getUrl() + "/A/D/G"); thisTest.getExpectedWC().setItemIsSwitched("A/D/H",true); thisTest.getExpectedWC().removeItem("A/D/H/chi"); thisTest.getExpectedWC().removeItem("A/D/H/omega"); thisTest.getExpectedWC().removeItem("A/D/H/psi"); thisTest.getExpectedWC().addItem("A/D/H/pi", thisTest.getExpectedWC().getItemContent("A/D/G/pi")); thisTest.getExpectedWC().addItem("A/D/H/rho", thisTest.getExpectedWC().getItemContent("A/D/G/rho")); thisTest.getExpectedWC().addItem("A/D/H/tau", thisTest.getExpectedWC().getItemContent("A/D/G/tau")); client.switchToUrl(adhPath, adgURL, SVNRevision.HEAD, true); // check the status of the working copy thisTest.checkStatusesExpectedWC(); } } UpdateTest.java000066400000000000000000000216101203563747500346250ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.basictests; import java.io.File; import java.io.FileOutputStream; import java.io.PrintWriter; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; public class UpdateTest extends SVNTest { /** * test the basic SVNClient.update functionality * @throws Throwable */ public void testBasicUpdate() throws Throwable { // build the test setup. Used for the changes OneTest thisTest = new OneTest("basicUpdate",getGreekTestConfig()); // build the backup test setup. That is the one that will be updated OneTest backupTest = thisTest.copy(".backup"); // modify A/mu File mu = new File(thisTest.getWorkingCopy(), "A/mu"); PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true)); muPW.print("appended mu text"); muPW.close(); thisTest.getExpectedWC().setItemWorkingCopyRevision("A/mu", 2); thisTest.getExpectedWC().setItemContent("A/mu", thisTest.getExpectedWC().getItemContent("A/mu") + "appended mu text"); // modify A/D/G/rho File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho"); PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true)); rhoPW.print("new appended text for rho"); rhoPW.close(); thisTest.getExpectedWC().setItemWorkingCopyRevision("A/D/G/rho", 2); thisTest.getExpectedWC().setItemContent("A/D/G/rho", thisTest.getExpectedWC().getItemContent("A/D/G/rho") + "new appended text for rho"); // commit the changes assertEquals("wrong revision number from commit",2, client.commit(new File[]{thisTest.getWCPath()}, "log msg", true)); // check the status of the working copy thisTest.checkStatusesExpectedWC(); // update the backup test assertEquals("wrong revision number from update",2, client.update(backupTest.getWCPath(), SVNRevision.HEAD, true)); // set the expected working copy layout for the backup test backupTest.getExpectedWC().setItemWorkingCopyRevision("A/mu", 2); backupTest.getExpectedWC().setItemContent("A/mu", backupTest.getExpectedWC().getItemContent("A/mu") + "appended mu text"); backupTest.getExpectedWC().setItemWorkingCopyRevision("A/D/G/rho", 2); backupTest.getExpectedWC().setItemContent("A/D/G/rho", backupTest.getExpectedWC().getItemContent("A/D/G/rho") + "new appended text for rho"); // check the status of the working copy of the backup test backupTest.checkStatusesExpectedWC(); } /** * test the basic SVNClient.update functionality with concurrent changes * in the repository and the working copy * @throws Throwable */ public void testBasicMergingUpdate() throws Throwable { // build the first working copy OneTest thisTest = new OneTest("BasicMergingUpdate",getGreekTestConfig()); // append 10 lines to A/mu File mu = new File(thisTest.getWorkingCopy(), "A/mu"); PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true)); String muContent = thisTest.getExpectedWC().getItemContent("A/mu"); for (int i = 2; i < 11; i++) { muPW.print("\nThis is line " + i + " in mu"); muContent = muContent + "\nThis is line " + i + " in mu"; } muPW.close(); thisTest.getExpectedWC().setItemWorkingCopyRevision("A/mu", 2); thisTest.getExpectedWC().setItemContent("A/mu", muContent); // append 10 line to A/D/G/rho File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho"); PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true)); String rhoContent = thisTest.getExpectedWC().getItemContent("A/D/G/rho"); for (int i = 2; i < 11; i++) { rhoPW.print("\nThis is line " + i + " in rho"); rhoContent = rhoContent + "\nThis is line " + i + " in rho"; } rhoPW.close(); thisTest.getExpectedWC().setItemWorkingCopyRevision("A/D/G/rho", 2); thisTest.getExpectedWC().setItemContent("A/D/G/rho", rhoContent); // commit the changes assertEquals("wrong revision number from commit",2, client.commit(new File[]{thisTest.getWCPath()}, "log msg", true)); // check the status of the first working copy thisTest.checkStatusesExpectedWC(); // create a backup copy of the working copy OneTest backupTest = thisTest.copy(".backup"); // change the last line of A/mu in the first working copy muPW = new PrintWriter(new FileOutputStream(mu, true)); muContent = thisTest.getExpectedWC().getItemContent("A/mu"); muPW.print(" Appended to line 10 of mu"); muContent = muContent + " Appended to line 10 of mu"; muPW.close(); thisTest.getExpectedWC().setItemWorkingCopyRevision("A/mu", 3); thisTest.getExpectedWC().setItemContent("A/mu", muContent); // change the last line of A/mu in the first working copy rhoPW = new PrintWriter(new FileOutputStream(rho, true)); rhoContent = thisTest.getExpectedWC().getItemContent("A/D/G/rho"); rhoPW.print(" Appended to line 10 of rho"); rhoContent = rhoContent + " Appended to line 10 of rho"; rhoPW.close(); thisTest.getExpectedWC().setItemWorkingCopyRevision("A/D/G/rho", 3); thisTest.getExpectedWC().setItemContent("A/D/G/rho", rhoContent); // commit these changes to the repository assertEquals("wrong revision number from commit",3, client.commit(new File[]{thisTest.getWCPath()}, "log msg", true)); // check the status of the first working copy thisTest.checkStatusesExpectedWC(); // modify the first line of A/mu in the backup working copy mu = new File(backupTest.getWorkingCopy(), "A/mu"); muPW = new PrintWriter(new FileOutputStream(mu)); muPW.print("This is the new line 1 in the backup copy of mu"); muContent = "This is the new line 1 in the backup copy of mu"; for (int i = 2; i < 11; i++) { muPW.print("\nThis is line " + i + " in mu"); muContent = muContent + "\nThis is line " + i + " in mu"; } muPW.close(); backupTest.getExpectedWC().setItemWorkingCopyRevision("A/mu", 3); muContent = muContent + " Appended to line 10 of mu"; backupTest.getExpectedWC().setItemContent("A/mu", muContent); backupTest.getExpectedWC().setItemTextStatus("A/mu", SVNStatusKind.MODIFIED); // modify the first line of A/D/G/rho in the backup working copy rho = new File(backupTest.getWorkingCopy(), "A/D/G/rho"); rhoPW = new PrintWriter(new FileOutputStream(rho)); rhoPW.print("This is the new line 1 in the backup copy of rho"); rhoContent = "This is the new line 1 in the backup copy of rho"; for (int i = 2; i < 11; i++) { rhoPW.print("\nThis is line " + i + " in rho"); rhoContent = rhoContent + "\nThis is line " + i + " in rho"; } rhoPW.close(); backupTest.getExpectedWC().setItemWorkingCopyRevision("A/D/G/rho", 3); rhoContent = rhoContent + " Appended to line 10 of rho"; backupTest.getExpectedWC().setItemContent("A/D/G/rho", rhoContent); backupTest.getExpectedWC().setItemTextStatus("A/D/G/rho", SVNStatusKind.MODIFIED); // update the backup working copy assertEquals("wrong revision number from update",3, client.update(backupTest.getWCPath(), SVNRevision.HEAD, true)); // check the status of the backup working copy backupTest.checkStatusesExpectedWC(); } } svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/readme.txt000066400000000000000000000003511203563747500337540ustar00rootroot00000000000000These tests have been adapted from http://svn.collab.net/viewcvs/svn/trunk/subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/tests/ Tests was inspired by the tests in subversion/tests/clients/cmdline/basic_tests.py svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/commandline/000077500000000000000000000000001203563747500321015ustar00rootroot00000000000000HelperTest.java000066400000000000000000000035331203563747500347500ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.util.Calendar; import java.util.TimeZone; import junit.framework.TestCase; public class HelperTest extends TestCase { public void testConvertXMLDate() throws Exception { // before patch from Jennifer Bevan, svnClientAdapter was incorrectly // setting dates at 12:xx PM to 12:xx AM Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cal.set(2003, 0, 10,23,21,54); assertEquals(cal.getTime().toString(), Helper.convertXMLDate("2003-01-10T23:21:54.831325Z").toString()); cal.set(2003, 0, 11,12,01,06); assertEquals(cal.getTime().toString(), Helper.convertXMLDate("2003-01-11T12:01:06.649052Z").toString()); cal.set(2003, 0,11,0,4,33); assertEquals(cal.getTime().toString(), Helper.convertXMLDate("2003-01-11T00:04:33.633658Z").toString()); cal.set(2003,0,11,12,13,31); assertEquals(cal.getTime().toString(), Helper.convertXMLDate("2003-01-11T12:13:31.499504Z").toString()); } } SvnOutputParserTest.java000066400000000000000000000164101203563747500366730ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/commandline/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.commandline; import java.io.UnsupportedEncodingException; import java.text.ParseException; import junit.framework.TestCase; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.commandline.parser.SvnOutputParser; public class SvnOutputParserTest extends TestCase { private static class Notification { public String path; int action; int kind; String mimeType; int contentState; int propState; long revision; public Notification(String path,int action,int kind,String mimeType,int contentState,int propState,long revision) { this.path = path; this.action = action; this.kind = kind; this.mimeType = mimeType; this.contentState = contentState; this.propState = propState; this.revision = revision; } } public void testParser() { SvnOutputParser parser = new SvnOutputParser(); final Notification[] notification = new Notification[1]; parser.addListener(new CmdLineNotify() { public void onNotify( String path, int action, int kind, String mimeType, int contentState, int propState, long revision) { notification[0] = new Notification(path,action,kind,mimeType,contentState,propState,revision); } }); parser.parse("Skipped missing target: '/home/cedric/project/mytarget.txt'"); assertEquals("/home/cedric/project/mytarget.txt",notification[0].path); parser.parse(" U /home/cedric/project/mytarget.txt"); assertEquals("/home/cedric/project/mytarget.txt",notification[0].path); assertEquals(CmdLineNotify.Status.unchanged,notification[0].contentState); assertEquals(CmdLineNotify.Status.changed,notification[0].propState); parser.parse("C /home/cedric/project/mytarget.txt"); assertEquals("/home/cedric/project/mytarget.txt",notification[0].path); assertEquals(CmdLineNotify.Status.conflicted,notification[0].contentState); assertEquals(CmdLineNotify.Status.unchanged,notification[0].propState); parser.parse("At revision 53."); assertEquals(53, notification[0].revision); notification[0] = null; parser.parse("P /home/cedric/project/mytarget.txt"); assertEquals(null, notification[0]); } public void testXmlLogMessageParserVerbose() throws UnsupportedEncodingException, SVNClientException, ParseException { String xml ="\r\n" + "\r\n" + "\r\n" + " Jesper\r\n" + " 2005-06-18T10:42:52.338920Z\r\n" + " \r\n" + " /trunk/Subclipse-test/org\r\n" + " /èl\r\n" + " \r\n" + " This one is really really cool, too!\r\n" + "\r\n" + ""; CmdLineLogMessage[] entries = CmdLineLogMessage.createLogMessages(xml.getBytes("UTF-8")); // Expect one entry assertEquals(1, entries.length); assertEquals("This one is really really cool, too!", entries[0].getMessage()); assertEquals(2, entries[0].getChangedPaths().length); // First path assertEquals('A', entries[0].getChangedPaths()[0].getAction()); assertEquals("/trunk/Subclipse-test/org", entries[0].getChangedPaths()[0].getPath()); assertEquals("/trunk/org", entries[0].getChangedPaths()[0].getCopySrcPath()); assertEquals(SVNRevision.getRevision("1"), entries[0].getChangedPaths()[0].getCopySrcRevision()); // Second path assertEquals('M', entries[0].getChangedPaths()[1].getAction()); assertEquals("/\u00e8l", entries[0].getChangedPaths()[1].getPath()); assertEquals("/\u00e8l", entries[0].getChangedPaths()[1].getPath()); assertEquals(null, entries[0].getChangedPaths()[1].getCopySrcPath()); assertEquals(null, entries[0].getChangedPaths()[1].getCopySrcRevision()); } public void testXmlLogMessageParserSimple() throws UnsupportedEncodingException, SVNClientException { String xml="\r\n" + "\r\n" + "\r\n" + " Jesper\r\n" + " 2005-06-18T10:42:52.338920Z\r\n" + " This one is really really cool, too!\r\n" + "\r\n" + ""; CmdLineLogMessage[] entries = CmdLineLogMessage.createLogMessages(xml.getBytes("UTF-8")); assertEquals(1, entries.length); assertEquals("This one is really really cool, too!", entries[0].getMessage()); assertEquals(0, entries[0].getChangedPaths().length); } public void testXmlLogMessageParserNoMsg() throws UnsupportedEncodingException, SVNClientException { String xml="\r\n" + "\r\n" + "\r\n" + " Jesper\r\n" + " 2005-06-18T10:42:52.338920Z\r\n" + " \r\n" + "\r\n" + ""; CmdLineLogMessage[] entries = CmdLineLogMessage.createLogMessages(xml.getBytes("UTF-8")); assertEquals(1, entries.length); assertEquals("Jesper", entries[0].getAuthor()); assertEquals("", entries[0].getMessage()); assertEquals(0, entries[0].getChangedPaths().length); } public void testXmlLogMessageParserMultiple() throws UnsupportedEncodingException, SVNClientException, ParseException { String xml0="\r\n" + "\r\n"; assertEquals(0, CmdLineLogMessage.createLogMessages(xml0.getBytes("UTF-8")).length); String xml3="\r\n" + "\r\n" + "\r\n" + " j2005-06-18T09:45:52.826529Z\r\n" + "\r\n" + "\r\n" + " j2005-06-18T10:42:52.338920Z\r\n" + "\r\n" + "\r\n" + " j2005-06-18T10:59:21.187452Z\r\n" + "\r\n" + ""; CmdLineLogMessage[] entries = CmdLineLogMessage.createLogMessages(xml3.getBytes("UTF-8")); assertEquals(3, entries.length); assertEquals(SVNRevision.getRevision("5"), entries[0].getRevision()); assertEquals(SVNRevision.getRevision("6"), entries[1].getRevision()); assertEquals(SVNRevision.getRevision("7"), entries[2].getRevision()); } } svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/regression/000077500000000000000000000000001203563747500317735ustar00rootroot00000000000000CmdLineBugRegressionTest.java000066400000000000000000000141071203563747500374340ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/regression/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.regression; import java.io.File; import java.io.FileOutputStream; import java.io.PrintWriter; import org.tigris.subversion.svnclientadapter.ISVNLogMessage; import org.tigris.subversion.svnclientadapter.SVNClientAdapterFactory; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.commandline.CmdLineClientAdapterFactory; import org.tigris.subversion.svnclientadapter.testUtils.OneTest; import org.tigris.subversion.svnclientadapter.testUtils.SVNTest; import org.tigris.subversion.svnclientadapter.testUtils.TestsConfig; public class CmdLineBugRegressionTest extends SVNTest { protected void setUp() throws Exception { TestsConfig.getTestsConfig().clientType = "commandline"; TestsConfig.getTestsConfig().adminClientType = "commandline"; super.setUp(); } /** * Test the issue 135 * @throws Exception * @see Issue 135 */ public void testIssue135() throws Exception { final byte[] cedricInUTF8bytes = new byte[] {67, -61, -87, 100, 114, 105, 99}; final String userName = new String(cedricInUTF8bytes, "UTF-8"); final String passwd = "cedricPass"; //Just check that String(, charset) creates proper local string (windows only) //final String cedricIn8859_1 = "Cédric"; //ISO 8859-1 //assertEquals(cedricIn8859_1, userName); client = SVNClientAdapterFactory.createSVNClient(CmdLineClientAdapterFactory.COMMANDLINE_CLIENT); client.setUsername(userName); client.setPassword(passwd); //final byte[] utf8Message = new byte[] {65, 110, 32, 85, 84, 70, 45, 56, 32, 108, 111, 103, 32, 109, 101, 115, 115, 97, 103, 101, 58, 32, 39, -60, -66, 39, 32, 45, 32, 39, -48, -106, 39, 32, 45, 32, 39, -38, -80, 39, 32}; //String theLogMessage = new String(utf8Message, 0, utf8Message.length, "UTF-8"); String theLogMessage = "Log message"; // build the test setup OneTest thisTest = new OneTest("testUTF8", getGreekTestConfig()); // modify file A/mu File mu = new File(thisTest.getWorkingCopy(), "A/mu"); PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true)); muPW.print("appended mu text"); muPW.close(); thisTest.getExpectedWC().setItemWorkingCopyRevision("A/mu", 2); thisTest.getExpectedWC().setItemContent("A/mu", thisTest.getExpectedWC().getItemContent("A/mu") + "appended mu text"); // commit the changes assertEquals("wrong revision number from commit",2, client.commit(new File[]{thisTest.getWCPath()}, theLogMessage, true)); ISVNLogMessage logMmsg = client.getLogMessages(mu, SVNRevision.getRevision("HEAD"), SVNRevision.getRevision("HEAD"))[0]; assertEquals(userName, logMmsg.getAuthor()); assertEquals(theLogMessage, logMmsg.getMessage()); } /** * Test the issue 137 * @throws Exception * @see Issue 137 */ public void testIssue137() throws Exception { client = SVNClientAdapterFactory.createSVNClient(CmdLineClientAdapterFactory.COMMANDLINE_CLIENT); client.setUsername("cedric"); client.setPassword("cedricpass"); String theLogMessage = "A log message"; // build the test setup OneTest thisTest = new OneTest("basicCommit", getGreekTestConfig()); // modify file A/mu File mu = new File(thisTest.getWorkingCopy(), "A/mu"); PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true)); muPW.print("appended mu text"); muPW.close(); thisTest.getExpectedWC().setItemWorkingCopyRevision("A/mu", 2); thisTest.getExpectedWC().setItemContent("A/mu", thisTest.getExpectedWC().getItemContent("A/mu") + "appended mu text"); // commit the changes assertEquals("wrong revision number from commit",2, client.commit(new File[]{thisTest.getWCPath()}, theLogMessage, true)); // modify file A/D/G/rho File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho"); PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true)); rhoPW.print("new appended text for rho"); rhoPW.close(); thisTest.getExpectedWC().setItemWorkingCopyRevision("A/D/G/rho", 3); thisTest.getExpectedWC().setItemContent("A/D/G/rho", thisTest.getExpectedWC().getItemContent("A/D/G/rho") + "new appended text for rho"); // commit the changes assertEquals("wrong revision number from commit",3, client.commit(new File[]{thisTest.getWCPath()}, "", true)); // check the status of the working copy thisTest.checkStatusesExpectedWC(); ISVNLogMessage lm[] = client.getLogMessages(mu, SVNRevision.BASE, SVNRevision.HEAD); assertEquals("wrong message", theLogMessage, lm[0].getMessage()); lm = client.getLogMessages(rho, SVNRevision.HEAD, SVNRevision.HEAD); assertEquals("wrong message", "", lm[0].getMessage()); } } svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/testUtils/000077500000000000000000000000001203563747500316135ustar00rootroot00000000000000ExpectedGreekRepositoryFactory.java000066400000000000000000000066541203563747500405610ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/testUtils/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.testUtils; public class ExpectedGreekRepositoryFactory { public static ExpectedWC getGreekWC() { ExpectedWC greekWC = new ExpectedWC(); putGreekStructureInto(greekWC); return greekWC; } public static ExpectedRepository getGreekRepository() { ExpectedRepository greekRepository = new ExpectedRepository(); putGreekStructureInto(greekRepository); return greekRepository; } public static ExpectedRepository getNumericRepository() { ExpectedRepository numericRepository = new ExpectedRepository(); putNumericStructureInto(numericRepository); return numericRepository; } public static ExpectedWC getNumericWC() { ExpectedWC numericWC = new ExpectedWC(); putNumericStructureInto(numericWC); return numericWC; } private static void putGreekStructureInto(ExpectedStructure greek) { greek.addItem("", null); greek.addItem("iota", "This is the file 'iota'."); greek.addItem("A", null); greek.addItem("A/mu", "This is the file 'mu'."); greek.addItem("A/B", null); greek.addItem("A/B/lambda", "This is the file 'lambda'."); greek.addItem("A/B/E", null); greek.addItem("A/B/E/alpha", "This is the file 'alpha'."); greek.addItem("A/B/E/beta", "This is the file 'beta'."); greek.addItem("A/B/F", null); greek.addItem("A/C", null); greek.addItem("A/D", null); greek.addItem("A/D/gamma", "This is the file 'gamma'."); greek.addItem("A/D/H", null); greek.addItem("A/D/H/chi", "This is the file 'chi'."); greek.addItem("A/D/H/psi", "This is the file 'psi'."); greek.addItem("A/D/H/omega", "This is the file 'omega'."); greek.addItem("A/D/G", null); greek.addItem("A/D/G/pi", "This is the file 'pi'."); greek.addItem("A/D/G/rho", "This is the file 'rho'."); greek.addItem("A/D/G/tau", "This is the file 'tau'."); } private static void putNumericStructureInto(ExpectedStructure greek) { greek.addItem("", null); greek.addItem("zero", "This is the file 'zero'."); greek.addItem("1", null); greek.addItem("1/eleven", "This is the file 'eleven'."); greek.addItem("1/12", null); greek.addItem("1/12/twelve", "This is the file 'twelve'."); greek.addItem("1/12/123", null); greek.addItem("1/13", null); greek.addItem("1/14", null); greek.addItem("1/14/fourteen", "This is the file 'fourteen'."); } }ExpectedRepository.java000066400000000000000000000177501203563747500362520ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/testUtils/******************************************************************************* * Copyright (c) 2005, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.testUtils; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import junit.framework.Assert; import org.tigris.subversion.svnclientadapter.ISVNDirEntry; import org.tigris.subversion.svnclientadapter.SVNNodeKind; /** * This class describe the expected state of the repository */ public class ExpectedRepository implements ExpectedStructure { /** * the map of the items of the repository. The relative path is the key * for the map */ protected Map items = new HashMap(); /** * Copy an expected working copy state * @return the copy of the exiting object */ public ExpectedRepository copy() { ExpectedRepository c = new ExpectedRepository(); Iterator it = items.values().iterator(); while (it.hasNext()) { ((Item) it.next()).copy(c); } return c; } /** * Add a new item to the repository * @param path the path of the item * @param content the content of the item. A null content signifies a * directory */ public void addItem(String path, String content) { new Item(path, content); } /** * Returns the item at a path * @param path the path, where the item is searched * @return the found item */ public Item getItem(String path) { return (Item) items.get(path); } /** * @return the number of items in WC */ public int size() { return items.size(); } /** * Remove the item at a path * @param path the path, where the item is removed */ public void removeItem(String path) { items.remove(path); } /** * Set the expected node kind at a path * @param path the path, where the node kind is set * @param nodeKind the expected node kind */ public void setItemNodeKind(String path, SVNNodeKind nodeKind) { Item i = (Item) items.get(path); i.nodeKind = nodeKind; } /** * Check the result of a single file SVNClient.list call * @param tested the result array * @param singleFilePath the path to be checked * @throws Exception */ public void check(ISVNDirEntry[] tested, String singleFilePath) throws Exception { Assert.assertEquals("not a single dir entry", 1, tested.length); Item item = (Item)items.get(singleFilePath); Assert.assertNotNull("not found in working copy", item); Assert.assertNotNull("not a file", item.myContent); Assert.assertEquals("state says file, working copy not", tested[0].getNodeKind(), item.nodeKind == SVNNodeKind.NONE ? SVNNodeKind.FILE : item.nodeKind); } /** * Check the result of a directory SVNClient.list call * @param tested the result array * @param basePath the path of the directory * @param recursive the recursive flag of the call * @throws Exception */ public void check(ISVNDirEntry[] tested, String basePath, boolean recursive) throws Exception { // clear the touched flag of all items Iterator it = items.values().iterator(); while (it.hasNext()) { Item item = (Item) it.next(); item.touched = false; } // normalize directory path if (basePath != null && basePath.length() > 0) { basePath = basePath + "/"; } else { basePath = ""; } // check all returned DirEntry's for (int i = 0; i < tested.length; i++) { String name = basePath + tested[i].getPath(); Item item = (Item) items.get(name); Assert.assertNotNull("not found in repository", item); if (item.myContent != null) { Assert.assertEquals("state says file, repository not", tested[i].getNodeKind(), item.nodeKind == SVNNodeKind.NONE ? SVNNodeKind.FILE : item.nodeKind); } else { Assert.assertEquals("state says dir, repository not", tested[i].getNodeKind(), item.nodeKind == SVNNodeKind.NONE ? SVNNodeKind.DIR : item.nodeKind); } item.touched = true; } // all items should have been in items, should had their touched flag // set it = items.values().iterator(); while (it.hasNext()) { Item item = (Item) it.next(); if(!item.touched) { if(item.myPath.startsWith(basePath) && !item.myPath.equals(basePath)) { Assert.assertFalse("not found in dir entries", recursive); boolean found = false; for(int i = 0; i < tested.length; i++) { if(tested[i].getNodeKind() == SVNNodeKind.DIR) { if(item.myPath. startsWith(basePath+tested[i].getPath())) { found = true; break; } } } Assert.assertTrue("not found in dir entries", found); } } } } /** * internal class to discribe a single repository item */ public class Item { /** * the relative path of the item */ String myPath; /** * the content of a file. A directory has a null content */ String myContent; /** * expected node kind. SVNNodeKind.NONE means do not check. */ SVNNodeKind nodeKind = SVNNodeKind.NONE; /** * flag if item has been touched. To detect missing items. */ boolean touched; /** * create a new item * @param path the path of the item. * @param content the content of the item. A null signals a directory. */ protected Item(String path, String content) { myPath = path; myContent = content; items.put(path, this); } /** * copy constructor * @param source the copy source. * @param owner the repository of the copy */ private Item(Item source, ExpectedRepository owner) { myPath = source.myPath; myContent = source.myContent; owner.items.put(myPath, this); } /** * copy this item * @param owner the new WC * @return the copied item */ protected Item copy(ExpectedRepository owner) { return new Item(this, owner); } } } ExpectedStructure.java000066400000000000000000000024241203563747500360630ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/testUtils/******************************************************************************* * Copyright (c) 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.testUtils; public interface ExpectedStructure { /** * Add a new item to the structure (e.g. working copy or repository) * @param path the path of the item * @param content the content of the item. A null content signifies a * directory */ void addItem(String path, String content); } ExpectedWC.java000066400000000000000000000431661203563747500344040ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/testUtils/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.testUtils; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.Reader; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import junit.framework.Assert; import org.tigris.subversion.svnclientadapter.ISVNDirEntry; import org.tigris.subversion.svnclientadapter.ISVNStatus; import org.tigris.subversion.svnclientadapter.SVNNodeKind; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNStatusKind; /** * This class describe the expected state of the working copy */ public class ExpectedWC implements ExpectedStructure { /** * the map of the items of the working copy. The relative path is the key * for the map */ protected Map items = new HashMap(); /** * Generate from the expected state of the working copy a new working copy * @param root the working copy directory * @throws IOException */ public void materialize(File root) throws IOException { // generate all directories first Iterator it = items.values().iterator(); while (it.hasNext()) { Item item = (Item) it.next(); if (item.myContent == null) // is a directory { File dir = new File(root, item.myPath); if (!dir.exists()) dir.mkdirs(); } } // generate all files with the content in the second run it = items.values().iterator(); while (it.hasNext()) { Item item = (Item) it.next(); if (item.myContent != null) // is a file { File file = new File(root, item.myPath); PrintWriter pw = new PrintWriter(new FileOutputStream(file)); pw.print(item.myContent); pw.close(); } } } /** * Add a new item to the working copy * @param path the path of the item * @param content the content of the item. A null content signifies a * directory */ public void addItem(String path, String content) { new Item(path, content); } /** * Returns the item at a path * @param path the path, where the item is searched * @return the found item */ public Item getItem(String path) { return (Item) items.get(path); } /** * @return the number of items in WC */ public int size() { return items.size(); } /** * Remove the item at a path * @param path the path, where the item is removed */ public void removeItem(String path) { items.remove(path); } /** * Set text (content) status of the item at a path * @param path the path, where the status is set * @param status the new text status */ public void setItemTextStatus(String path, SVNStatusKind status) { ((Item) items.get(path)).textStatus = status; } /** * Set property status of the item at a path * @param path the path, where the status is set * @param status the new property status */ public void setItemPropStatus(String path, SVNStatusKind status) { ((Item) items.get(path)).propStatus = status; } /** * Set the revision number of the item at a path * @param path the path, where the revision number is set * @param revision the new revision number */ public void setItemWorkingCopyRevision(String path, long revision) { ((Item) items.get(path)).workingCopyRev = new SVNRevision.Number(revision); } /** * Returns the file content of the item at a path * @param path the path, where the content is retrieved * @return the content of the file */ public String getItemContent(String path) { return ((Item) items.get(path)).myContent; } /** * Set the file content of the item at a path * @param path the path, where the content is set * @param content the new content */ public void setItemContent(String path, String content) { // since having no content signals a directory, changes of removing the // content or setting a former not set content is not allowed. That // would change the type of the item. Assert.assertNotNull("cannot unset content", content); Item i = (Item) items.get(path); Assert.assertNotNull("cannot set content on directory", i.myContent); i.myContent = content; } /** * set the flag to check the content of item at a path during next check. * @param path the path, where the flag is set * @param check the flag */ public void setItemCheckContent(String path, boolean check) { Item i = (Item) items.get(path); i.checkContent = check; } /** * Set the expected node kind at a path * @param path the path, where the node kind is set * @param nodeKind the expected node kind */ public void setItemNodeKind(String path, SVNNodeKind nodeKind) { Item i = (Item) items.get(path); i.nodeKind = nodeKind; } /** * Set the expected lock state at a path * @param path the path, where the lock state is set * @param isLocked the flag */ public void setItemIsLocked(String path, boolean isLocked) { Item i = (Item) items.get(path); i.isLocked = isLocked; } public void setItemIsCopied(String path, boolean isCopied) { Item i = (Item) items.get(path); i.isCopied = isCopied; } /** * Set the expected switched flag at a path * @param path the path, where the switch flag is set * @param isSwitched the flag */ public void setItemIsSwitched(String path, boolean isSwitched) { Item i = (Item) items.get(path); i.isSwitched = isSwitched; } /** * Copy an expected working copy state * @return the copy of the exiting object */ public ExpectedWC copy() { ExpectedWC c = new ExpectedWC(); Iterator it = items.values().iterator(); while (it.hasNext()) { ((Item) it.next()).copy(c); } return c; } public ExpectedWC addExternalPartWC(ExpectedWC externalWC, String externalRootPath) { for (Iterator iter = externalWC.items.values().iterator(); iter.hasNext();) { Item item = (Item) iter.next(); if (!"".equals(item.myPath)) { addItem(externalRootPath + "/" + item.myPath, item.myContent); } } return this; } /** * Check the result of a single file SVNClient.list call * @param tested the result array * @param singleFilePath the path to be checked * @throws Exception */ public void check(ISVNDirEntry[] tested, String singleFilePath) throws Exception { Assert.assertEquals("not a single dir entry", 1, tested.length); Item item = (Item)items.get(singleFilePath); Assert.assertNotNull("not found in working copy", item); Assert.assertNotNull("not a file", item.myContent); Assert.assertEquals("state says file, working copy not", tested[0].getNodeKind(), item.nodeKind == SVNNodeKind.NONE ? SVNNodeKind.FILE : item.nodeKind); } /** * Check the result of a directory SVNClient.list call * @param tested the result array * @param basePath the path of the directory * @param recursive the recursive flag of the call * @throws Exception */ public void check(ISVNDirEntry[] tested, String basePath, boolean recursive) throws Exception { // clear the touched flag of all items Iterator it = items.values().iterator(); while (it.hasNext()) { Item item = (Item) it.next(); item.touched = false; } // normalize directory path if (basePath != null && basePath.length() > 0) { basePath = basePath + "/"; } else { basePath = ""; } // check all returned DirEntry's for (int i = 0; i < tested.length; i++) { String name = basePath + tested[i].getPath(); Item item = (Item) items.get(name); Assert.assertNotNull("not found in working copy", item); if (item.myContent != null) { Assert.assertEquals("state says file, working copy not", tested[i].getNodeKind(), item.nodeKind == SVNNodeKind.NONE ? SVNNodeKind.FILE : item.nodeKind); } else { Assert.assertEquals("state says dir, working copy not", tested[i].getNodeKind(), item.nodeKind == SVNNodeKind.NONE ? SVNNodeKind.DIR : item.nodeKind); } item.touched = true; } // all items should have been in items, should had their touched flag // set it = items.values().iterator(); while (it.hasNext()) { Item item = (Item) it.next(); if(!item.touched) { if(item.myPath.startsWith(basePath) && !item.myPath.equals(basePath)) { Assert.assertFalse("not found in dir entries", recursive); boolean found = false; for(int i = 0; i < tested.length; i++) { if(tested[i].getNodeKind() == SVNNodeKind.DIR) { if(item.myPath. startsWith(basePath+tested[i].getPath())) { found = true; break; } } } Assert.assertTrue("not found in dir entries", found); } } } } /** * Check the result of a SVNClient.status versus the expected state * @param tested the result to be tested * @param workingCopyPath the path of the working copy * @throws Exception */ void check(ISVNStatus[] tested, String workingCopyPath) throws Exception { // clear the touched flag of all items Iterator it = items.values().iterator(); while (it.hasNext()) { Item item = (Item) it.next(); item.touched = false; } String normalizeWCPath = workingCopyPath.replace(File.separatorChar, '/'); // check all result Staus object for (int i = 0; i < tested.length; i++) { String path = tested[i].getPath().replace(File.separatorChar, '/'); Assert.assertTrue("status path starts not with working copy path", path.startsWith(normalizeWCPath)); // we calculate the relative path to the working copy root if (path.length() > workingCopyPath.length() + 1) { Assert.assertEquals("missing '/' in status path", '/', path.charAt(workingCopyPath.length())); path = path.substring(workingCopyPath.length() + 1); } else // this is the working copy root itself path = ""; Item item = (Item) items.get(path); Assert.assertNotNull("status not found in working copy for "+path, item); Assert.assertEquals("wrong text status in working copy for "+path, item.textStatus, tested[i].getTextStatus()); if (item.workingCopyRev != SVNRevision.INVALID_REVISION) Assert.assertEquals("wrong revision number in working copy for "+path, item.workingCopyRev, tested[i].getRevision()); Assert.assertEquals("lock status wrong for "+path, item.isLocked, tested[i].isWcLocked()); Assert.assertEquals("switch status wrong", item.isSwitched, tested[i].isSwitched()); Assert.assertEquals("copied status wrong for "+path, item.isCopied, tested[i].isCopied()); Assert.assertEquals("wrong prop status in working copy for "+path, item.propStatus, tested[i].getPropStatus()); if (item.myContent != null) { // file // if Item.nodeKind == NONE ==> do not check if (item.nodeKind != SVNNodeKind.NONE) { Assert.assertEquals("state says file, working copy not for "+path, item.nodeKind, tested[i].getNodeKind()); } if (tested[i].getTextStatus() == SVNStatusKind.NORMAL || item.checkContent) { File input = new File(workingCopyPath, item.myPath); Reader rd = new InputStreamReader(new FileInputStream(input)); StringBuffer buffer = new StringBuffer(); int ch; while ((ch = rd.read()) != -1) { buffer.append((char) ch); } rd.close(); Assert.assertEquals("content mismatch for "+path, item.myContent, buffer.toString()); } } else { if (item.nodeKind != SVNNodeKind.NONE) { Assert.assertEquals("state says dir, working copy not for "+path, item.nodeKind, tested[i].getNodeKind()); } } item.touched = true; } // all items which have the touched flag not set, are missing in the // result array it = items.values().iterator(); while (it.hasNext()) { Item item = (Item) it.next(); Assert.assertTrue("item "+item.myPath+" in working copy not found in status", item.touched); } } /** * internal class to discribe a single working copy item */ public class Item { /** * the content of a file. A directory has a null content */ String myContent; /** * the relative path of the item */ String myPath; /** * the text (content) status of the item */ SVNStatusKind textStatus = SVNStatusKind.NORMAL; /** * the property status of the item. */ SVNStatusKind propStatus = SVNStatusKind.NONE; /** * the expected revision number. INVALID_REVISION means do not check. */ SVNRevision.Number workingCopyRev = SVNRevision.INVALID_REVISION; /** * flag if item has been touched. To detect missing items. */ boolean touched; /** * flag if the content will be checked */ boolean checkContent; /** * expected node kind. SVNNodeKind.NONE means do not check. */ SVNNodeKind nodeKind = SVNNodeKind.NONE; /** * expected locked status */ boolean isLocked; /** * expected switched status */ boolean isSwitched; /** * expected copied status */ boolean isCopied; /** * create a new item * @param path the path of the item. * @param content the content of the item. A null signals a directory. */ protected Item(String path, String content) { myPath = path; myContent = content; items.put(path, this); } /** * copy constructor * @param source the copy source. * @param owner the WC of the copy */ private Item(Item source, ExpectedWC owner) { myPath = source.myPath; myContent = source.myContent; textStatus = source.textStatus; propStatus = source.propStatus; owner.items.put(myPath, this); } /** * copy this item * @param owner the new WC * @return the copied item */ protected Item copy(ExpectedWC owner) { return new Item(this, owner); } } } FileUtils.java000066400000000000000000000063721203563747500343070ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/testUtils/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.testUtils; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; /** * Utility class used to copy an entire directory or files */ public class FileUtils { /** Recursively copy all files from one directory to another. * * @param src file or directory to copy from. * @param dest file or directory to copy to. * @throws IOException */ public static void copyFiles(File src, File dest) throws IOException { if (!src.exists()) { return; } if (src.isDirectory()) { dest.mkdirs(); String list[] = src.list(); for (int i = 0; i < list.length; i++) { File src1 = new File(src, list[i]); File dest1 = new File(dest, list[i]); copyFiles(src1 , dest1); } } else { copyFile(src, dest); } } /** * copy a file from a source to a destination * * @param src * @param dest * @throws FileNotFoundException * @throws IOException */ public static void copyFile(File src, File dest) throws FileNotFoundException, IOException { if (dest.exists()) { dest.delete(); } // this part comes from org.apache.tools.ant.util.FileUtils FileInputStream in = null; FileOutputStream out = null; try { in = new FileInputStream(src); out = new FileOutputStream(dest); byte[] buffer = new byte[8 * 1024]; int count = 0; do { out.write(buffer, 0, count); count = in.read(buffer, 0, buffer.length); } while (count != -1); } finally { if (out != null) { out.close(); } if (in != null) { in.close(); } } } /** * Remove a directory with all files and directories it may contain. * @param localTmp */ public static void removeDirectoryWithContent(File localTmp) { if(localTmp.isDirectory()) { File[] content = localTmp.listFiles(); for(int i = 0; i < content.length; i++) removeDirectoryWithContent(content[i]); } localTmp.delete(); } } svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/testUtils/OneTest.java000066400000000000000000000211021203563747500340330ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.testUtils; import java.io.File; import java.util.logging.Logger; import org.tigris.subversion.svnclientadapter.ISVNDirEntry; import org.tigris.subversion.svnclientadapter.ISVNStatus; import org.tigris.subversion.svnclientadapter.SVNRevision; import org.tigris.subversion.svnclientadapter.SVNStatusKind; import org.tigris.subversion.svnclientadapter.SVNUrl; import org.tigris.subversion.svnclientadapter.testUtils.ExpectedWC.Item; /** * this internal class represent the repository and the working copy for one * test. */ public class OneTest { private static final Logger log = Logger.getLogger(OneTest.class.getName()); protected String testName; protected TestsConfig testsConfig = TestsConfig.getTestsConfig(); /** * the file name of repository (used by SVNAdmin) */ protected File repository; /** * the file name of the working copy directory */ protected File workingCopy; /** * the url of the repository (used by SVNClient) */ protected SVNUrl url; /** * the expected layout of the working copy after the next subversion command */ protected ExpectedWC expectedWC; protected ExpectedRepository expectedRepository; protected TestConfig config; /** * build a new test setup with a new repository, a new working and a new * expected working layout * @param testName * @param config * * @throws Exception */ public OneTest(String testName, TestConfig config) throws Exception { this.testName = testName; this.config = config; this.expectedWC = config.getExpectedWC().copy(); this.expectedRepository = config.getExpectedRepository().copy(); repository = createStartRepository(testName, config); url = testsConfig.makeReposUrl(repository); workingCopy = createStartWorkingCopy(repository, testName); } /** * build a new test setup with a new repository, a new working and a new * expected working layout * @param testName * @param config * @param externalConfig (config to be hooked via svn:external) * * @throws Exception */ public OneTest(String testName, TestConfig config, TestConfig externalConfig) throws Exception { this(testName, config); File externalRepository = createStartRepository(testName + ".external", externalConfig); createSvnExternal(repository, externalRepository, testName); } /** * Copy the working copy and the expected working copy layout for tests * which need multiple working copy * * @param append * append to the working copy name of the original * @return second test object. * @throws Exception */ public OneTest copy(String append) throws Exception { return new OneTest(this, append); } /** * constructor for create a copy * * @param orig * original test * @param append * append this to the directory name of the original test * @throws Exception */ private OneTest(OneTest orig, String append) throws Exception { this.testName = orig.testName + append; repository = orig.getRepository(); config = orig.getTestConfig(); url = orig.getUrl(); expectedWC = orig.expectedWC.copy(); expectedRepository = orig.expectedRepository.copy(); workingCopy = createStartWorkingCopy(repository, testName); } /** * Return the directory of the repository * * @return the repository directory name */ public File getRepository() { return repository; } /** * Return the name of the directory of the repository * * @return the name of repository directory */ public String getRepositoryPath() { return repository.getAbsolutePath(); } /** * Return the working copy directory * * @return the working copy directory */ public File getWorkingCopy() { return workingCopy; } /** * Return the working copy directory name * * @return the name of the working copy directory */ public File getWCPath() { return workingCopy.getAbsoluteFile(); } /** * Returns the url of repository * * @return the url */ public SVNUrl getUrl() { return url; } /** * Returns the expected working copy content * * @return the expected working copy content */ public ExpectedWC getExpectedWC() { return expectedWC; } /** * Returns the expected repository content * * @return the expected repository content */ public ExpectedRepository getExpectedRepository() { return expectedRepository; } /** * @return Returns the testsConfig. */ public TestConfig getTestConfig() { return config; } /** * Create the repository for the beginning of the test * * @param aTestName * the name of the test * @return the repository directory * @throws Exception */ protected File createStartRepository(String aTestName, TestConfig aConfig) throws Exception { // build a clean repository directory File repos = new File(testsConfig.repositories, aTestName); log.fine("Creating repository for test "+aTestName+" at "+repos.toString()); FileUtils.removeDirectoryWithContent(repos); FileUtils.copyFiles(aConfig.getReposDirectory(), repos); return repos; } /** * Create the working copy for the beginning of the test * * @param repos * the repository directory * @param aTestName * the name of the test * @return the directory of the working copy * @throws Exception */ protected File createStartWorkingCopy(File repos, String aTestName) throws Exception { // build a clean working directory SVNUrl anUrl = testsConfig.makeReposUrl(repos); workingCopy = new File(testsConfig.workingCopies, aTestName); log.fine("Creating working copy at "+workingCopy.toString()); FileUtils.removeDirectoryWithContent(workingCopy); // checkout the repository config.getClient().checkout(anUrl, workingCopy, SVNRevision.HEAD, true); // sanity check the working with its expected status checkStatusesExpectedWC(); checkEntriesExpectedRepository(); return workingCopy; } protected File createSvnExternal(File repos, File externalRepository, String aTestName) throws Exception { // build a clean working directory SVNUrl anUrl = testsConfig.makeReposUrl(externalRepository); config.getClient().propertySet(workingCopy, "svn:externals", "A/E " + anUrl, false); config.getClient().commit(new File[] {workingCopy} , "Exetrnals prop set", false); config.getClient().update(workingCopy, SVNRevision.HEAD, true); Item item = expectedWC.getItem(""); item.propStatus = SVNStatusKind.NORMAL; expectedWC.addItem("A/E", null); item = expectedWC.getItem("A/E"); item.textStatus = SVNStatusKind.EXTERNAL; item.propStatus = SVNStatusKind.NONE; // sanity check the working with its expected status checkStatusesExpectedWCIgnoreExternals(); checkEntriesExpectedRepository(); return workingCopy; } /** * Check if the working copy has the expected status * * @throws Exception */ public void checkStatusesExpectedWC() throws Exception { ISVNStatus[] states = config.getClient().getStatus(workingCopy, true, true, false, false); expectedWC.check(states, workingCopy.getAbsolutePath()); } /** * Check if the working copy has the expected status * * @throws Exception */ public void checkStatusesExpectedWCIgnoreExternals() throws Exception { ISVNStatus[] states = config.getClient().getStatus(workingCopy, true, true, false, true); expectedWC.check(states, workingCopy.getAbsolutePath()); } /** * Check if repository has expected entries * @throws Exception */ public void checkEntriesExpectedRepository() throws Exception { ISVNDirEntry[] entries = config.getClient().getList(getUrl(), SVNRevision.HEAD, true); expectedRepository.check(entries,"", true); } } svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/testUtils/SVNTest.java000066400000000000000000000202601203563747500337640ustar00rootroot00000000000000/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.testUtils; import java.io.File; import java.io.IOException; import java.util.logging.Logger; import junit.framework.TestCase; import org.tigris.subversion.svnclientadapter.ISVNClientAdapter; import org.tigris.subversion.svnclientadapter.SVNClientAdapterFactory; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.commandline.CmdLineClientAdapterFactory; import org.tigris.subversion.svnclientadapter.javahl.JhlClientAdapterFactory; import org.tigris.subversion.svnclientadapter.svnkit.SvnKitClientAdapterFactory; /** * common base class for the SvnclientAdapter tests */ public abstract class SVNTest extends TestCase { private static final Logger log = Logger.getLogger(SVNTest.class.getName()); //Don't forget to put these credentials into ./test/passwd file public static String TEST_USER = "cedric"; public static String TEST_USERPASS = "cedricpass"; public static final String ANOTHER_TEST_USER = "Mr.Spock"; protected ISVNClientAdapter client; protected ISVNClientAdapter clientAdmin; /** * the directory "local_tmp" in the rootDir. This will be used for the * sample repository and for the config directory */ protected File localTmp; /** * the directory "config" in the localTmp. It will be used as the * configuration directory for all the tests. */ protected File conf; /** * standard log message. Used for all commits. */ protected String logMessage = "Log Message"; private TestConfig greekTestConfig = null; private TestConfig numericTestConfig = null; private TestsConfig testsConfig; private SvnServer svnServer; static { log.fine("Initializing client adapters factories"); try { JhlClientAdapterFactory.setup(); } catch (SVNClientException e) { // can't register this factory } try { CmdLineClientAdapterFactory.setup(); } catch (SVNClientException e1) { // can't register this factory } try { SvnKitClientAdapterFactory.setup(); } catch (SVNClientException e1) { // can't register this factory } } /** * Standard initialization of one test * * @throws Exception */ protected void setUp() throws Exception { super.setUp(); testsConfig = TestsConfig.getTestsConfig(); // create a clean directory for the config files and the sample // repository localTmp = new File(testsConfig.rootDir, "local_tmp"); if (localTmp.exists()) FileUtils.removeDirectoryWithContent(localTmp); localTmp.mkdir(); conf = new File(localTmp, "config"); conf.mkdir(); // create and configure the needed subversion objects client = SVNClientAdapterFactory .createSVNClient(testsConfig.clientType); client.setUsername(TEST_USER); client.setPassword(TEST_USERPASS); // client.setConfigDirectory(conf.getAbsolutePath()); clientAdmin = SVNClientAdapterFactory .createSVNClient(testsConfig.adminClientType); clientAdmin.setUsername(TEST_USER); clientAdmin.setPassword(TEST_USERPASS); startServer(); } protected void startServer() throws IOException { if (testsConfig.protocol.equals("svn")) { //Start it only if it was not running already (e.g. by testSuite) if (!SvnServer.isSvnServerRunning()) { System.out.print("Starting svnserve : "); svnServer = SvnServer.startSvnServer(testsConfig.serverHostname, testsConfig.serverPort, testsConfig.rootDir);; System.out.println("done."); } else { //clear the variable so we'll not stop the server which we didn't started. svnServer = null; } } } protected void stopServer() { if (testsConfig.protocol.equals("svn")) { if (svnServer != null) { System.out.print("Stopping svnserve : "); SvnServer.stopSvnServer(svnServer); System.out.println("done."); svnServer = null; } } } public TestConfig getGreekTestConfig() throws IOException, SVNClientException { if (greekTestConfig == null) { // build the sample repository that will be imported File greekFiles = new File(localTmp, "greek_files"); greekFiles.mkdir(); ExpectedWC greekWC = ExpectedGreekRepositoryFactory.getGreekWC(); greekWC.materialize(greekFiles); ExpectedRepository greekRepository = ExpectedGreekRepositoryFactory.getGreekRepository(); // create the repository File greekRepos = new File(localTmp, "repos"); log.fine("Creating repository :" + greekRepos.toString()); clientAdmin.createRepository(greekRepos, ISVNClientAdapter.REPOSITORY_FSTYPE_FSFS); FileUtils.copyFile(new File("test/svnserve.conf"), new File( greekRepos, "conf/svnserve.conf")); FileUtils.copyFile(new File("test/passwd"), new File(greekRepos, "conf/passwd")); log.fine("Importing from : " + greekFiles.toString() + " to repository :" + greekRepos.toString()); clientAdmin.doImport(greekFiles, testsConfig .makeReposUrl(greekRepos), logMessage, true); greekTestConfig = new TestConfig(client, greekRepos, greekWC, greekRepository); } return greekTestConfig; } public TestConfig getNumericTestConfig() throws IOException, SVNClientException { if (numericTestConfig == null) { // build the sample repository that will be imported File numericFiles = new File(localTmp, "numeric_files"); numericFiles.mkdir(); ExpectedWC numericWC = ExpectedGreekRepositoryFactory.getNumericWC(); numericWC.materialize(numericFiles); ExpectedRepository numericRepository = ExpectedGreekRepositoryFactory.getNumericRepository(); // create the repository File numericRepos = new File(localTmp, "repos2"); log.fine("Creating repository :" + numericRepos.toString()); clientAdmin.createRepository(numericRepos, ISVNClientAdapter.REPOSITORY_FSTYPE_FSFS); FileUtils.copyFile(new File("test/svnserve.conf"), new File( numericRepos, "conf/svnserve.conf")); FileUtils.copyFile(new File("test/passwd"), new File(numericRepos, "conf/passwd")); log.fine("Importing from : " + numericFiles.toString() + " to repository :" + numericRepos.toString()); clientAdmin.doImport(numericFiles, testsConfig .makeReposUrl(numericRepos), logMessage, true); numericTestConfig = new TestConfig(client, numericRepos, numericWC, numericRepository); } return numericTestConfig; } /** * cleanup after one test * * @throws Exception */ protected void tearDown() throws Exception { // take care of our subversion objects. // client.dispose(); // remove the temporary directory FileUtils.removeDirectoryWithContent(localTmp); stopServer(); super.tearDown(); } }SvnServer.java000066400000000000000000000072161203563747500343420ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/testUtils/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.testUtils; import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import org.tigris.subversion.svnclientadapter.utils.Command; /** * Start a svn server */ public class SvnServer { private static SvnServer singleton = null; private Command command; final private int listenPort; final private String listenHost; private File repository; public static boolean isSvnServerRunning() { return singleton != null; } public static SvnServer startSvnServer(String listenHost, int listenPort, File repository) throws IOException { singleton = new SvnServer(listenHost, listenPort, repository); singleton.start(); return singleton; } public static void stopSvnServer(SvnServer instance) { singleton.kill(); singleton = null; } private SvnServer(String listenHost, int listenPort, File repository) { super(); this.listenHost = listenHost; this.listenPort = listenPort; this.repository = repository; if ((listenHost == null) || (listenHost.length() == 0)) { throw new IllegalArgumentException("listenHost must not be null !"); } if (listenPort == 0) { throw new IllegalArgumentException("listenPort must not be 0 !"); } if (repository == null) { throw new IllegalArgumentException("repository must not be null !"); } } /** * @return Returns the listenHost */ public String getListenHost() { return listenHost; } /** * @return Returns the listenPort. */ public int getListenPort() { return listenPort; } /** * @return Returns the repository. */ public File getRepository() { return repository; } public void start() throws IOException { command = getSvnServerCommmand(); command.setParameters(new String[] { "-d", "--foreground", "--listen-host", listenHost, "--listen-port", Integer.toString(listenPort), "-r", repository.toString() }); command.exec(); } public void kill() { if (command != null) { command.kill(); } } protected Command getSvnServerCommmand() { return new Command( (System.getProperty("os.name").indexOf("Win") > -1) ? "svnserve.exe" : whichSvnserve()); } private String whichSvnserve() { try { Process whichProc = Runtime.getRuntime().exec( "/usr/bin/which svnserve"); BufferedReader reader = new BufferedReader(new InputStreamReader( whichProc.getInputStream())); try { String line = reader.readLine(); whichProc.getInputStream().close(); whichProc.getOutputStream().close(); whichProc.getErrorStream().close(); return line; } catch (IOException e) { throw new RuntimeException("Cannot locate svnserve command !", e); } } catch (IOException e1) { throw new RuntimeException("Cannot locate svnserve command !", e1); } } }TestConfig.java000066400000000000000000000045411203563747500344500ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/testUtils/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.testUtils; import java.io.File; import org.tigris.subversion.svnclientadapter.ISVNClientAdapter; /** * Configuration for a given OneTest */ public class TestConfig { /** the svn client to use to create the working copy and check the status */ private ISVNClientAdapter client; /** the directory of the sample repository */ private File reposDirectory; /** the initial working copy of the sample repository */ private ExpectedWC expectedWC; /** the initial repository */ private ExpectedRepository expectedRepository; /** * Constructor * @param client * @param reposDirectory * @param expectedWC * @param expectedRepository */ public TestConfig(ISVNClientAdapter client, File reposDirectory, ExpectedWC expectedWC, ExpectedRepository expectedRepository) { super(); this.client = client; this.reposDirectory = reposDirectory; this.expectedWC = expectedWC; this.expectedRepository = expectedRepository; } /** * @return Returns the client. */ public ISVNClientAdapter getClient() { return client; } /** * @return Returns the expectedRepository. */ public ExpectedRepository getExpectedRepository() { return expectedRepository; } /** * @return Returns the expectedWC. */ public ExpectedWC getExpectedWC() { return expectedWC; } /** * @return Returns the reposDirectory. */ public File getReposDirectory() { return reposDirectory; } } TestsConfig.java000066400000000000000000000132151203563747500346310ustar00rootroot00000000000000svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/testUtils/******************************************************************************* * Copyright (c) 2004, 2006 svnClientAdapter project and others. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Contributors: * svnClientAdapter project committers - initial API and implementation ******************************************************************************/ package org.tigris.subversion.svnclientadapter.testUtils; import java.io.File; import java.net.MalformedURLException; import org.tigris.subversion.svnclientadapter.SVNClientException; import org.tigris.subversion.svnclientadapter.SVNUrl; /** * configuration parameters that are common to all tests */ public class TestsConfig { private static TestsConfig testsConfig; public String clientType; public String adminClientType; /** * common root URL for all tests. Can be set by system property "test.rooturl". * If not set, the file url of the rootDirectoryName is used. */ public SVNUrl rootUrl; /** * the root directory. All other files and directories will created in * here */ public File rootDir; /** * common root directory for all tests. Can be set by the system property * "test.rootdir". If not set, the current directory of this process is used */ public String rootDirectoryName; /** * the directory "repositories" in the rootDir. All test repositories will * be created here. */ public File repositories; /** * the directory "working_copies" in the rootDir. All test working copies * will be created here. */ public File workingCopies; public String serverHostname; public int serverPort; public String protocol; private TestsConfig() throws SVNClientException { clientType = System.getProperty("test.clientType"); if (clientType == null) { clientType = "javahl"; } System.out.println("Using "+clientType+" factory ..."); adminClientType = System.getProperty("test.adminClientType"); if (adminClientType == null) { adminClientType = clientType; } // if (adminClientType.equals("svnkit")) { // adminClientType = "javahl"; // } System.out.println("Using "+adminClientType+" factory for admin commands..."); rootDirectoryName = System.getProperty("test.rootdir"); if (rootDirectoryName == null) rootDirectoryName = System.getProperty("user.dir"); rootDir = new File(rootDirectoryName); if (System.getProperty("test.serverHostname") != null) { serverHostname = System.getProperty("test.serverHostname"); } else { serverHostname = "127.0.0.1"; } if (System.getProperty("test.serverPort") != null) { serverPort = Integer.valueOf(System.getProperty("test.serverPort")).intValue(); } else { serverPort = 3690; } protocol = System.getProperty("test.protocol"); if (protocol == null) protocol = "file"; String rootUrlStr = null; if(protocol.equals("file")) { rootUrlStr = rootDir.toURI().toString(); // java may have a different view about the number of '/' to follow // "file:" than subversion. We convert to the subversion view. if(rootUrlStr.startsWith("file:///")) ; // this is the form subversion needs else if(rootUrlStr.startsWith("file://")) rootUrlStr = rootUrlStr.replaceFirst("file://", "file:///"); else if(rootUrlStr.startsWith("file:/")) rootUrlStr = rootUrlStr.replaceFirst("file:/", "file:///"); } else if (protocol.equals("svn")) { rootUrlStr = "svn://" + serverHostname; } else if (protocol.equals("http")) { rootUrlStr = "http://" + serverHostname + ":8080/svn/repos"; } try { rootUrl = new SVNUrl(rootUrlStr); } catch (MalformedURLException e) { throw new SVNClientException(e); } // create the directory for the repositories and the working copies repositories = new File(rootDir, "repositories"); repositories.mkdirs(); workingCopies = new File(rootDir, "working_copies"); workingCopies.mkdirs(); } public static TestsConfig getTestsConfig() throws SVNClientException { if (testsConfig == null) { testsConfig = new TestsConfig(); } return testsConfig; } /** * Create the url for the repository to be used for the tests. * @param file the directory of the repository * @return the URL for the repository * @throws MalformedURLException */ public SVNUrl makeReposUrl(File file) throws MalformedURLException { // split the common part of the root directory String path = file.getAbsolutePath(). substring(rootDirectoryName.length()+1); // append to the root url return new SVNUrl(rootUrl + "/" + path.replace(File.separatorChar, '/')); } } svnclientadapter-1.8.16/test/000077500000000000000000000000001203563747500161505ustar00rootroot00000000000000svnclientadapter-1.8.16/test/passwd000066400000000000000000000001221203563747500173670ustar00rootroot00000000000000[users] cedric=cedricpass cédric=cedricpass Cédric=cedricpass Mr.Spock=cedricpass svnclientadapter-1.8.16/test/svnserve.conf000066400000000000000000000005401203563747500206710ustar00rootroot00000000000000### This file controls the configuration of the svnserve daemon, if you ### use it to allow access to this repository. (If you only allow ### access through http: and/or file: URLs, then this file is ### irrelevant.) ### Visit http://subversion.tigris.org/ for more information. [general] anon-access = read auth-access = write password-db = passwd