pax_global_header 0000666 0000000 0000000 00000000064 12035637475 0014526 g ustar 00root root 0000000 0000000 52 comment=8e876bdb828259f8b41004ac74d7f023c21662c2
svnclientadapter-1.8.16/ 0000775 0000000 0000000 00000000000 12035637475 0015171 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/.classpath 0000664 0000000 0000000 00000001463 12035637475 0017160 0 ustar 00root root 0000000 0000000
* 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 safetoString()
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.java 0000664 0000000 0000000 00000011014 12035637475 0037270 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000005516 12035637475 0040467 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000003311 12035637475 0036345 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000027363 12035637475 0036146 0 ustar 00root root 0000000 0000000 svnclientadapter-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?
// 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.java 0000664 0000000 0000000 00000022764 12035637475 0036452 0 ustar 00root root 0000000 0000000 svnclientadapter-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: //* 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 // //* 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.java 0000664 0000000 0000000 00000033624 12035637475 0037211 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000016007 12035637475 0036527 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000013763 12035637475 0036236 0 ustar 00root root 0000000 0000000 svnclientadapter-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; /** * Digestsstatus
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.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.java 0000664 0000000 0000000 00000004676 12035637475 0034411 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000003327 12035637475 0037010 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000100031 12035637475 0036025 0 ustar 00root root 0000000 0000000 svnclientadapter-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.
*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.
** 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 * 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.java 0000664 0000000 0000000 00000006035 12035637475 0037503 0 ustar 00root root 0000000 0000000 svnclientadapter-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/ 0000775 0000000 0000000 00000000000 12035637475 0033665 5 ustar 00root root 0000000 0000000 SvnActionRE.java 0000664 0000000 0000000 00000012431 12035637475 0036605 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000017604 12035637475 0037625 0 ustar 00root root 0000000 0000000 svnclientadapter-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/ 0000775 0000000 0000000 00000000000 12035637475 0017225 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/javahl/org/ 0000775 0000000 0000000 00000000000 12035637475 0020014 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/javahl/org/tigris/ 0000775 0000000 0000000 00000000000 12035637475 0021315 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/ 0000775 0000000 0000000 00000000000 12035637475 0023514 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/ 0000775 0000000 0000000 00000000000 12035637475 0027062 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/javahl/org/tigris/subversion/svnclientadapter/javahl/ 0000775 0000000 0000000 00000000000 12035637475 0030327 5 ustar 00root root 0000000 0000000 AbstractJhlClientAdapter.java 0000664 0000000 0000000 00000375670 12035637475 0035776 0 ustar 00root root 0000000 0000000 svnclientadapter-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); SetlineNumber
*
* @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.java 0000664 0000000 0000000 00000174724 12035637475 0032642 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000003102 12035637475 0033363 0 ustar 00root root 0000000 0000000 package 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.java 0000664 0000000 0000000 00000003433 12035637475 0031647 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000000240 12035637475 0033305 0 ustar 00root root 0000000 0000000 package org.tigris.subversion.svnclientadapter;
public interface ISVNDirEntryWithLock {
public ISVNDirEntry getDirEntry();
public ISVNLock getLock();
}
svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNInfo.java 0000664 0000000 0000000 00000007374 12035637475 0031012 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000003173 12035637475 0031000 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000006261 12035637475 0032137 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000003607 12035637475 0033555 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000003210 12035637475 0033772 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000004737 12035637475 0031772 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000000356 12035637475 0033273 0 ustar 00root root 0000000 0000000 package 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.java 0000664 0000000 0000000 00000010122 12035637475 0033056 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000000227 12035637475 0033417 0 ustar 00root root 0000000 0000000 package org.tigris.subversion.svnclientadapter;
public interface ISVNProgressListener {
public void onProgress(SVNProgressEvent progressEvent);
}
svnclientadapter-1.8.16/src/main/org/tigris/subversion/svnclientadapter/ISVNPromptUserPassword.java 0000664 0000000 0000000 00000012444 12035637475 0033754 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000006233 12035637475 0031734 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000010707 12035637475 0031374 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000000231 12035637475 0033000 0 ustar 00root root 0000000 0000000 package 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.java 0000664 0000000 0000000 00000013655 12035637475 0031316 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java0000664 0000000 0000000 00000007661 12035637475 0034054 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000007011 12035637475 0033067 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000013664 12035637475 0033605 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000004005 12035637475 0032732 0 ustar 00root root 0000000 0000000 package 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.java 0000664 0000000 0000000 00000002510 12035637475 0033100 0 ustar 00root root 0000000 0000000 package 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.java 0000664 0000000 0000000 00000002513 12035637475 0031750 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000004004 12035637475 0032064 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000012325 12035637475 0032224 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000010561 12035637475 0033113 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000011315 12035637475 0031603 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000001375 12035637475 0033444 0 ustar 00root root 0000000 0000000 package 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.java0000664 0000000 0000000 00000005231 12035637475 0033745 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000007701 12035637475 0031473 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000014713 12035637475 0033725 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000000606 12035637475 0032603 0 ustar 00root root 0000000 0000000 package 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.java 0000664 0000000 0000000 00000020665 12035637475 0031602 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000017545 12035637475 0032562 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000007727 12035637475 0032352 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000000766 12035637475 0032704 0 ustar 00root root 0000000 0000000 package 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.java 0000664 0000000 0000000 00000017457 12035637475 0032102 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.
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.java 0000664 0000000 0000000 00000003231 12035637475 0031607 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000006115 12035637475 0032316 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000003534 12035637475 0033103 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000011103 12035637475 0033433 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000015522 12035637475 0032723 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000007665 12035637475 0033051 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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/ 0000775 0000000 0000000 00000000000 12035637475 0017424 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/samples/org/ 0000775 0000000 0000000 00000000000 12035637475 0020213 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/samples/org/tigris/ 0000775 0000000 0000000 00000000000 12035637475 0021514 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/samples/org/tigris/subversion/ 0000775 0000000 0000000 00000000000 12035637475 0023713 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/samples/org/tigris/subversion/svnclientadapter/ 0000775 0000000 0000000 00000000000 12035637475 0027261 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/samples/org/tigris/subversion/svnclientadapter/samples/ 0000775 0000000 0000000 00000000000 12035637475 0030725 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/samples/org/tigris/subversion/svnclientadapter/samples/Sample.java 0000664 0000000 0000000 00000011557 12035637475 0033022 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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/ 0000775 0000000 0000000 00000000000 12035637475 0017276 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/svnkit/org/ 0000775 0000000 0000000 00000000000 12035637475 0020065 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/svnkit/org/tigris/ 0000775 0000000 0000000 00000000000 12035637475 0021366 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/svnkit/org/tigris/subversion/ 0000775 0000000 0000000 00000000000 12035637475 0023565 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/svnkit/org/tigris/subversion/svnclientadapter/ 0000775 0000000 0000000 00000000000 12035637475 0027133 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/svnkit/org/tigris/subversion/svnclientadapter/svnkit/ 0000775 0000000 0000000 00000000000 12035637475 0030451 5 ustar 00root root 0000000 0000000 SvnKitClientAdapter.java 0000664 0000000 0000000 00000012424 12035637475 0035116 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000005453 12035637475 0036452 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000011272 12035637475 0036242 0 ustar 00root root 0000000 0000000 svnclientadapter-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/ 0000775 0000000 0000000 00000000000 12035637475 0017756 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/testcases/org/ 0000775 0000000 0000000 00000000000 12035637475 0020545 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/testcases/org/tigris/ 0000775 0000000 0000000 00000000000 12035637475 0022046 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/ 0000775 0000000 0000000 00000000000 12035637475 0024245 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/ 0000775 0000000 0000000 00000000000 12035637475 0027613 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/SVNBaseDirTest.java 0000664 0000000 0000000 00000003542 12035637475 0033222 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000014515 12035637475 0032455 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000011315 12035637475 0033471 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000004274 12035637475 0033614 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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/ 0000775 0000000 0000000 00000000000 12035637475 0031757 5 ustar 00root root 0000000 0000000 svnclientadapter-1.8.16/src/testcases/org/tigris/subversion/svnclientadapter/basictests/AddTest.java0000664 0000000 0000000 00000004757 12035637475 0034167 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000015633 12035637475 0034433 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java0000664 0000000 0000000 00000012265 12035637475 0034177 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000012277 12035637475 0035121 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000005620 12035637475 0034775 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000005235 12035637475 0034640 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000012255 12035637475 0034322 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000027622 12035637475 0034616 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000003570 12035637475 0034671 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000007472 12035637475 0034667 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000012445 12035637475 0034304 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java0000664 0000000 0000000 00000016017 12035637475 0034210 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000011562 12035637475 0034045 0 ustar 00root root 0000000 0000000 /*******************************************************************************
* 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.java 0000664 0000000 0000000 00000011324 12035637475 0034452 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000014760 12035637475 0034321 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000012037 12035637475 0035542 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000017714 12035637475 0035034 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000012755 12035637475 0034664 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000006114 12035637475 0036212 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000002526 12035637475 0035475 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000002601 12035637475 0035361 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000002771 12035637475 0035402 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000033426 12035637475 0034676 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000005527 12035637475 0034655 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000021610 12035637475 0034625 0 ustar 00root root 0000000 0000000 svnclientadapter-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.txt 0000664 0000000 0000000 00000000351 12035637475 0033754 0 ustar 00root root 0000000 0000000 These 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/ 0000775 0000000 0000000 00000000000 12035637475 0032101 5 ustar 00root root 0000000 0000000 HelperTest.java 0000664 0000000 0000000 00000003533 12035637475 0034750 0 ustar 00root root 0000000 0000000 svnclientadapter-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.java 0000664 0000000 0000000 00000016410 12035637475 0036673 0 ustar 00root root 0000000 0000000 svnclientadapter-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" +
"