org.tigris.subversion.svnclientadapter.ISVNNotifyListener Java Examples

The following examples show how to use org.tigris.subversion.svnclientadapter.ISVNNotifyListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void mkdir(SVNUrl url, boolean makeParents, String message)
		throws SVNClientException {
	try {
		String fixedMessage = fixSVNString(message);

		if (fixedMessage == null)
			fixedMessage = "";
		notificationHandler.setCommand(ISVNNotifyListener.Command.MKDIR);
		Set<String> target = new HashSet<String>();
		target.add(url.toString());
		if (makeParents)
			notificationHandler.logCommandLine("mkdir --parents -m \""
					+ getFirstMessageLine(fixedMessage) + "\" " + target);
		else
			notificationHandler.logCommandLine("mkdir -m \""
					+ getFirstMessageLine(fixedMessage) + "\" " + target);
		notificationHandler.setBaseDir();
		svnClient.mkdir(target, makeParents, null, new JhlCommitMessage(
				fixedMessage), null);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #2
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public ISVNInfo getInfo(SVNUrl url, SVNRevision revision, SVNRevision peg)
		throws SVNClientException {
	notificationHandler.setCommand(ISVNNotifyListener.Command.INFO);
	String target = url.toString();
	notificationHandler.logCommandLine("info " + target);
	// notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(url));
	JhlInfoCallback callback = new JhlInfoCallback();

	try {
		svnClient.info2(target, JhlConverter.convert(revision),
				JhlConverter.convert(peg), Depth.empty, null, callback);
	} catch (ClientException e) {
		// e.printStackTrace();
	}
	ISVNInfo[] items = callback.getInfo();
	if (items == null || items.length == 0) {
		return new SVNInfoUnversioned(null);
	} else {
		return items[0];
	}
}
 
Example #3
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public ISVNInfo getInfoFromWorkingCopy(File path) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.INFO);

		String target = fileToSVNPath(path, false);
		notificationHandler.logCommandLine("info " + target);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path));
		JhlInfoCallback callback = new JhlInfoCallback();

		svnClient.info2(target, null, null, Depth.empty, null, callback);
		ISVNInfo[] items = callback.getInfo();
		if (items == null) {
			return new SVNInfoUnversioned(path);
		}
		return items[0];
	} catch (ClientException e) {
		// upgradeProject(path);
		if (e.getAprError() == ErrorCodes.wcNotDirectory
				|| e.getAprError() == ErrorCodes.wcPathNotFound) {
			return new SVNInfoUnversioned(path);
		} else {
			notificationHandler.logException(e);
			throw new SVNClientException(e);
		}
	}
}
 
Example #4
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public ISVNProperty propertyGet(SVNUrl url, SVNRevision revision,
		SVNRevision peg, String propertyName) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.PROPGET);
		String target = url.toString();
		String commandLine = "propget -r " + revision.toString() + " "
				+ propertyName + " " + target;
		if (!peg.equals(SVNRevision.HEAD))
			commandLine += "@" + peg.toString();
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir();
		byte[] bytes = svnClient.propertyGet(target, propertyName,
				JhlConverter.convert(revision), JhlConverter.convert(peg));
		if (bytes == null)
			return null;
		else
			return JhlPropertyData.newForUrl(target, propertyName, bytes);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #5
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void lock(File[] paths, String comment, boolean force)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.LOCK);
		Set<String> files = new HashSet<String>(paths.length);
		String commandLine = "lock -m \"" + comment + "\"";
		if (force)
			commandLine += " --force";

		for (int i = 0; i < paths.length; i++) {
			files.add(fileToSVNPath(paths[i], false));
		}
		commandLine = appendPaths(commandLine, files);
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(paths));

		svnClient.lock(files, comment, force);
		for (String file : files) {
			notificationHandler.notifyListenersOfChange(file);
		}
	} catch (ClientException e) {
		notificationHandler.logException(e);
		// throw new SVNClientException(e);
	}

}
 
Example #6
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public ISVNProperty propertyGet(File path, String propertyName)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.PROPGET);

		String target = fileToSVNPath(path, false);
		notificationHandler.logCommandLine("propget " + propertyName + " "
				+ target);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path));
		byte[] bytes = svnClient.propertyGet(target, propertyName, null,
				null);
		if (bytes == null)
			return null;
		else
			return JhlPropertyData.newForFile(target, propertyName, bytes);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}

}
 
Example #7
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void propertySet(SVNUrl url, SVNRevision.Number baseRev,
		String propertyName, String propertyValue, String message)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.PROPSET);
		if (propertyName.startsWith("svn:")) {
			// Normalize line endings in property value
			svnClient.propertySetRemote(url.toString(),
					baseRev.getNumber(), propertyName,
					fixSVNString(propertyValue).getBytes(),
					new JhlCommitMessage(message), false, null,
					new JhlCommitCallback());
		} else {
			svnClient.propertySetRemote(url.toString(),
					baseRev.getNumber(), propertyName,
					propertyValue.getBytes(),
					new JhlCommitMessage(message), false, null,
					new JhlCommitCallback());
		}
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #8
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private ISVNProperty[] getPropertiesIncludingInherited(String path,
		boolean isFile) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.PROPLIST);
		notificationHandler.logCommandLine("proplist " + path);
		notificationHandler.setBaseDir();
		InheritedJhlProplistCallback callback = new InheritedJhlProplistCallback(
				isFile);
		Revision revision = null;
		if (!isFile) {
			revision = JhlConverter.convert(SVNRevision.HEAD);
		}
		svnClient.properties(path, revision, revision, Depth.empty, null,
				callback);
		return callback.getPropertyData();
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #9
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public ISVNProperty[] getProperties(SVNUrl url, SVNRevision revision,
		SVNRevision pegRevision, boolean recurse) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.PROPLIST);
		String target = url.toString();
		notificationHandler.logCommandLine("proplist " + target);
		notificationHandler.setBaseDir();
		JhlProplistCallback callback = new JhlProplistCallback(false);
		Depth depth;
		if (recurse) {
			depth = Depth.infinity;
		} else {
			depth = Depth.empty;
		}
		svnClient.properties(target, JhlConverter.convert(revision),
				JhlConverter.convert(pegRevision), depth, null, callback);
		return callback.getPropertyData();
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #10
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public ISVNProperty[] getProperties(File path, boolean descend)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.PROPLIST);
		String target = fileToSVNPath(path, false);
		StringBuffer commandLine = new StringBuffer("propList ");
		if (descend) {
			commandLine.append(" -R ");
		}
		commandLine.append(target);
		notificationHandler.logCommandLine(commandLine.toString());
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path));
		JhlProplistCallback callback = new JhlProplistCallback(true);
		if (descend) {
			svnClient.properties(target, null, null, Depth.infinity, null,
					callback);
		} else {
			svnClient.properties(target, null, null, Depth.empty, null,
					callback);
		}
		return callback.getPropertyData();
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #11
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public InputStream getContent(SVNUrl url, SVNRevision revision,
		SVNRevision pegRevision) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.CAT);
		String commandLine = "cat -r " + revision + " " + url;
		if (pegRevision != null) {
			commandLine = commandLine + "@" + pegRevision;
		}
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir();

		byte[] contents = svnClient.fileContent(url.toString(),
				JhlConverter.convert(revision),
				JhlConverter.convert(pegRevision));
		InputStream input = new ByteArrayInputStream(contents);
		return input;
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #12
Source File: JhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void createRepository(File path, String repositoryType) throws SVNClientException {
	try {
		String fsType = (repositoryType == null) ? REPOSITORY_FSTYPE_FSFS : repositoryType; 
	    notificationHandler.setCommand(ISVNNotifyListener.Command.CREATE_REPOSITORY);
	     
	    notificationHandler.logCommandLine(
	    		MessageFormat.format(
	    				"create --fstype {0} {1}", 
						(Object[])new String[] { fsType, fileToSVNPath(path, false) }));
	    svnAdmin.create(path, false, false, null, fsType);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);            
	}        
    
}
 
Example #13
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void move(File srcPath, File destPath, boolean force)
		throws SVNClientException {
	// use force when you want to move file even if there are local
	// modifications
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.MOVE);
		Set<String> src = new HashSet<String>();
		src.add(fileToSVNPath(srcPath, false));
		String dest = fileToSVNPath(destPath, false);
		notificationHandler.logCommandLine("move "
				+ fileToSVNPath(srcPath, false) + ' ' + dest);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(new File[] {
				srcPath, destPath }));
		svnClient.move(src, dest, force, false, false, null, null, null);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #14
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public InputStream getContent(File path, SVNRevision revision)
		throws SVNClientException {
	try {
		String target = fileToSVNPath(path, false);
		notificationHandler.setCommand(ISVNNotifyListener.Command.CAT);
		notificationHandler.logCommandLine("cat -r " + revision.toString()
				+ " " + target);
		notificationHandler.setBaseDir();

		if (revision.equals(SVNRevision.BASE)) {
			// This is to work-around a JavaHL problem when trying to
			// retrieve the base revision of a newly added file.
			ISVNStatus status = getSingleStatus(path);
			if (status.getTextStatus().equals(SVNStatusKind.ADDED))
				return new ByteArrayInputStream(new byte[0]);
		}
		byte[] contents = svnClient.fileContent(target,
				JhlConverter.convert(revision), Revision.BASE);
		InputStream input = new ByteArrayInputStream(contents);
		return input;
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #15
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void remove(File file[], boolean force) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.REMOVE);

		String commandLine = "delete" + (force ? " --force" : "");
		Set<String> targets = new HashSet<String>(file.length);

		for (int i = 0; i < file.length; i++) {
			targets.add(fileToSVNPath(file[i], false));
		}
		commandLine = appendPaths(commandLine, targets);

		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(file));

		svnClient.remove(targets, force, false, null, null, null);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #16
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void remove(SVNUrl url[], String message) throws SVNClientException {
	try {
		String fixedMessage = fixSVNString(message);

		if (fixedMessage == null)
			fixedMessage = "";
		notificationHandler.setCommand(ISVNNotifyListener.Command.REMOVE);

		String commandLine = "delete -m \""
				+ getFirstMessageLine(fixedMessage) + "\"";

		Set<String> targets = new HashSet<String>(url.length);
		for (int i = 0; i < url.length; i++) {
			targets.add(url[i].toString());
		}
		commandLine = appendPaths(commandLine, targets);
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir();
		svnClient.remove(targets, false, false, null, new JhlCommitMessage(
				fixedMessage), null);

	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #17
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void copy(SVNUrl srcUrl, File destPath, SVNRevision revision,
		SVNRevision pegRevision, boolean copyAsChild, boolean makeParents)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.COPY);
		String dest = fileToSVNPath(destPath, false);
		List<CopySource> copySources = new ArrayList<CopySource>();
		copySources.add(new CopySource(srcUrl.toString(), JhlConverter
				.convert(revision), JhlConverter.convert(pegRevision)));
		notificationHandler.logCommandLine("copy " + srcUrl + " " + dest);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(destPath));
		svnClient.copy(copySources, dest, copyAsChild, makeParents, true,
				null, null, null);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #18
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void doExport(File srcPath, File destPath, boolean force)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.EXPORT);
		String src = fileToSVNPath(srcPath, false);
		String dest = fileToSVNPath(destPath, false);
		notificationHandler.logCommandLine("export " + src + ' ' + dest);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(new File[] {
				srcPath, destPath }));
		// in this case, revision is not used but must be valid
		svnClient.doExport(src, dest, Revision.WORKING, Revision.BASE,
				force, false, Depth.infinity, null);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #19
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void copy(File srcPath, SVNUrl destUrl, String message)
		throws SVNClientException {
	try {
		String fixedMessage = fixSVNString(message);
		if (fixedMessage == null)
			fixedMessage = "";
		notificationHandler.setCommand(ISVNNotifyListener.Command.COPY);
		String src = fileToSVNPath(srcPath, false);
		String dest = destUrl.toString();
		notificationHandler.logCommandLine("copy " + src + " " + dest);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(srcPath));
		List<CopySource> copySources = new ArrayList<CopySource>();
		copySources.add(new CopySource(src, Revision.WORKING,
				Revision.WORKING));
		svnClient.copy(copySources, dest, true, true, true, null,
				new JhlCommitMessage(fixedMessage), null);
		// last parameter is not used
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #20
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void setRevProperty(SVNUrl url, SVNRevision.Number revisionNo,
		String propName, String propertyData, boolean force)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.PROPSET);

		notificationHandler.logCommandLine("propset --revprop -r "
				+ revisionNo.toString() + (force ? " --force " : "")
				+ " \"" + propName + "\"  \"" + propertyData + "\" "
				+ url.toString());
		notificationHandler.setBaseDir();
		if (propName.startsWith("svn:")) {
			svnClient.setRevProperty(url.toString(), propName,
					Revision.getInstance(revisionNo.getNumber()),
					fixSVNString(propertyData), null, true);
		} else {
			svnClient.setRevProperty(url.toString(), propName,
					Revision.getInstance(revisionNo.getNumber()),
					propertyData, null, true);
		}
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #21
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void doImport(File path, SVNUrl url, String message, boolean recurse)
		throws SVNClientException {
	try {
		String fixedMessage = fixSVNString(message);

		if (fixedMessage == null)
			fixedMessage = "";
		notificationHandler.setCommand(ISVNNotifyListener.Command.IMPORT);
		String src = fileToSVNPath(path, false);
		String dest = url.toString();
		notificationHandler.logCommandLine("import -m \""
				+ getFirstMessageLine(fixedMessage) + "\" "
				+ (recurse ? "" : "-N ") + src + ' ' + dest);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path));
		svnClient
				.doImport(src, dest, Depth.infinityOrEmpty(recurse), false,
						true, null, new JhlCommitMessage(fixedMessage),
						null);
		notificationHandler.logCompleted(Messages
				.bind("notify.import.complete"));
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #22
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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);
	}
}
 
Example #23
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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);
	}
}
 
Example #24
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public void move(SVNUrl srcUrl, SVNUrl destUrl, String message,
		SVNRevision revision) throws SVNClientException {
	try {
		String fixedMessage = fixSVNString(message);

		// NOTE: The revision arg is ignored as you cannot move
		// a specific revision, only HEAD.
		if (fixedMessage == null)
			fixedMessage = "";
		notificationHandler.setCommand(ISVNNotifyListener.Command.MOVE);
		Set<String> src = new HashSet<String>();
		src.add(srcUrl.toString());
		String dest = destUrl.toString();
		notificationHandler.logCommandLine("move -m \""
				+ getFirstMessageLine(fixedMessage) + ' '
				+ srcUrl.toString() + ' ' + dest);
		notificationHandler.setBaseDir();
		svnClient.move(src, dest, false, false, false, null,
				new JhlCommitMessage(fixedMessage), null);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #25
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void mkdir(File file) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.MKDIR);
		Set<String> target = new HashSet<String>();
		target.add(fileToSVNPath(file, false));
		notificationHandler.logCommandLine("mkdir " + target);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(file));
		svnClient.mkdir(target, false, null, null, null);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example #26
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public ISVNInfo getInfo(File path) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.INFO);

		String target = fileToSVNPath(path, false);
		notificationHandler.logCommandLine("info " + target);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path));

		JhlInfoCallback callback = new JhlInfoCallback();

		svnClient.info2(target, Revision.WORKING, Revision.BASE,
				Depth.infinity, null, callback);
		ISVNInfo[] items = callback.getInfo();
		if (items == null || items.length == 0) {
			return new SVNInfoUnversioned(path);
		} else {
			return items[0];
		}

	} catch (ClientException e) {
		if (e.getAprError() == ErrorCodes.wcNotDirectory
				|| e.getAprError() == ErrorCodes.wcPathNotFound) {
			return new SVNInfoUnversioned(path);
		} else {
			notificationHandler.logException(e);
			throw new SVNClientException(e);
		}
	}
}
 
Example #27
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
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);
	}
}
 
Example #28
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public ISVNInfo[] getInfo(File path, boolean descend)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.INFO);
		String target = fileToSVNPath(path, false);
		if (descend)
			notificationHandler.logCommandLine("info " + target
					+ " --depth=infinity");
		else
			notificationHandler.logCommandLine("info " + target);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path));
		JhlInfoCallback callback = new JhlInfoCallback();

		svnClient.info2(target, null, null, Depth.infinityOrEmpty(descend),
				null, callback);
		ISVNInfo[] items = callback.getInfo();
		if (items == null) {
			return new ISVNInfo[] { new SVNInfoUnversioned(path) };
		} else {
			return items;
		}
	} catch (ClientException e) {
		if (e.getAprError() == ErrorCodes.wcNotDirectory
				|| e.getAprError() == ErrorCodes.wcPathNotFound) {
			return new ISVNInfo[] { new SVNInfoUnversioned(path) };
		} else {
			notificationHandler.logException(e);
			throw new SVNClientException(e);
		}
	}
}
 
Example #29
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void mergeReintegrate(SVNUrl path, SVNRevision pegRevision,
		File localPath, boolean force, boolean dryRun)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.MERGE);

		String target = fileToSVNPath(localPath, false);
		String commandLine = "merge --reintegrate";
		if (dryRun) {
			commandLine += " --dry-run";
		}
		if (force) {
			commandLine += " --force";
		}
		commandLine += " " + path + " " + target;
		notificationHandler.logCommandLine(commandLine);
		File baseDir = SVNBaseDir.getBaseDir(localPath);
		notificationHandler.setBaseDir(baseDir);

		Revision peg = JhlConverter.convert(pegRevision);
		if (peg == null)
			peg = Revision.HEAD;
		svnClient.mergeReintegrate(path.toString(), peg, target, dryRun);
		if (dryRun)
			notificationHandler.logCompleted("Dry-run merge complete.");
		else
			notificationHandler.logCompleted("Merge complete.");
	} catch (ClientException e) {
		// upgradeProject(localPath);
		notificationHandler.logException(e);
		if (dryRun)
			notificationHandler
					.logCompleted("Dry-run merge completed abnormally.");
		else
			notificationHandler.logCompleted("Merge completed abnormally.");
		SVNClientException svnClientException = new SVNClientException(e);
		svnClientException.setAprError(e.getAprError());
		throw svnClientException;
	}
}
 
Example #30
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void relocate(String from, String to, String path, boolean recurse)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.RELOCATE);
		notificationHandler.logCommandLine("switch --relocate " + from
				+ " " + to + " " + path);
		notificationHandler.setBaseDir(SVNBaseDir
				.getBaseDir(new File(path)));
		boolean ignoreAncestry = false;
		svnClient.relocate(from, to, path, ignoreAncestry);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}