Java Code Examples for org.tigris.subversion.svnclientadapter.SVNRevision#toString()

The following examples show how to use org.tigris.subversion.svnclientadapter.SVNRevision#toString() . 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: SVNCompareEditorInput.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the label for the given input element. (which is a ResourceEditionNode)
 */
private String getVersionLabel(ITypedElement element) {
	if (element instanceof ResourceEditionNode) {
		ISVNRemoteResource edition = ((ResourceEditionNode)element).getRemoteResource();
		SVNRevision revision = edition.getLastChangedRevision();
		if (revision == null) {
			revision = edition.getRevision();
		}
		if (edition.isContainer()) {
			return Policy.bind("SVNCompareEditorInput.headLabel"); //$NON-NLS-1$
		} else {
			return revision.toString();
		}
	}
	return element.getName();
}
 
Example 2
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 3
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 4
Source File: CommandlineClient.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public ISVNProperty[] getProperties(SVNUrl url, SVNRevision revision, SVNRevision pegRevision, boolean recursive) throws SVNClientException {
    ListPropertiesCommand cmd = new ListPropertiesCommand(url, revision.toString(), recursive);
    exec(cmd);
    List<String> names = cmd.getPropertyNames();
    List<ISVNProperty> props = new ArrayList<ISVNProperty>(names.size());
    for (String name : names) {
        ISVNProperty prop = propertyGet(url, name);
        if (prop != null) {
            props.add(prop);
        }
    }
    return props.toArray(new ISVNProperty[props.size()]);
}
 
Example 5
Source File: RepositoryPathNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Object getValue() throws IllegalAccessException, InvocationTargetException {
    SVNRevision r = entry.getLastChangedRevision();
    if (r instanceof SVNRevision.Number) {
        return ((SVNRevision.Number) r).getNumber();
    } else if (r == null) {
        return "";
    } else {
        return r.toString();
    }
}
 
Example 6
Source File: RevisionSetupsSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Setup createSetup (SVNDiffSummary summary, File file, SVNUrl leftUrl, SVNRevision leftRevision,
        SVNUrl rightUrl, String rightRevision) {
    FileInformation fi = null;
    Setup localSetup = wcSetups.get(file);
    boolean deleted = summary.getDiffKind() == SVNDiffKind.DELETED;
    boolean added = summary.getDiffKind() == SVNDiffKind.ADDED;
    if (localSetup != null) {
        // local file, diffing WC
        fi = cache.getStatus(file);
        if (added && (fi.getStatus() & FileInformation.STATUS_IN_REPOSITORY) == 0) {
            // don't override added status with modified
            fi = null;
        } else {
            deleted = (fi.getStatus() & (FileInformation.STATUS_VERSIONED_DELETEDLOCALLY
                    | FileInformation.STATUS_VERSIONED_REMOVEDLOCALLY)) != 0;
            added = (fi.getStatus() & (FileInformation.STATUS_VERSIONED_ADDEDLOCALLY
                    | FileInformation.STATUS_NOTVERSIONED_NEWLOCALLY)) != 0;
        }
    }
    if (fi == null) {
        fi = new RevisionsFileInformation(summary);
    }
    wcSetups.remove(file);
    Setup setup = new Setup(file, repositoryUrl,
            leftUrl, added ? null : leftRevision.toString(),
            SVNUrlUtils.getRelativePath(repositoryUrl, leftUrl) + "@" + leftRevision,
            rightUrl, deleted ? null : rightRevision,
            Setup.REVISION_CURRENT.equals(rightRevision)
            ? file.getName() + "@" + rightRevision
            : SVNUrlUtils.getRelativePath(repositoryUrl, rightUrl) + "@" + rightRevision,
            fi);
    setup.setNode(new DiffNode(setup, new SvnFileNode(file), FileInformation.STATUS_ALL));
    return setup;
}
 
Example 7
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void copy(SVNUrl[] srcUrls, SVNUrl destUrl, String message,
		SVNRevision revision, boolean copyAsChild, boolean makeParents)
		throws SVNClientException {
	try {
		String fixedMessage = fixSVNString(message);

		if (fixedMessage == null)
			fixedMessage = "";
		notificationHandler.setCommand(ISVNNotifyListener.Command.COPY);
		List<CopySource> copySources = new ArrayList<CopySource>(
				srcUrls.length);
		for (int i = 0; i < srcUrls.length; i++)
			copySources.add(new CopySource(srcUrls[i].toString(),
					JhlConverter.convert(revision), JhlConverter
							.convert(SVNRevision.HEAD)));
		String dest = destUrl.toString();
		String commandLine = "copy -r" + revision.toString();
		Set<String> paths = new HashSet<String>(srcUrls.length);
		for (int i = 0; i < srcUrls.length; i++) {
			paths.add(srcUrls[i].toString());
		}
		commandLine = appendPaths(commandLine, paths) + " " + dest;
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir();
		svnClient.copy(copySources, dest, copyAsChild, makeParents, true,
				null, new JhlCommitMessage(fixedMessage), null);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example 8
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public long update(File path, SVNRevision revision, int depth,
		boolean setDepth, boolean ignoreExternals, boolean force)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.UPDATE);
		Set<String> target = new HashSet<String>();
		String t = fileToSVNPath(path, false);
		target.add(t);
		Depth d = JhlConverter.depth(depth);
		StringBuffer commandLine;
		if (d == Depth.exclude)
			commandLine = new StringBuffer("update " + t
					+ " --set-depth=exclude");
		else {
			commandLine = new StringBuffer("update " + t + " -r "
					+ revision.toString() + depthCommandLine(d));
			if (ignoreExternals)
				commandLine.append(" --ignore-externals");
			if (force)
				commandLine.append(" --force");
		}
		notificationHandler.logCommandLine(commandLine.toString());
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path));
		boolean makeParents = false;
		long rev[] = svnClient.update(target,
				JhlConverter.convert(revision), d, setDepth, makeParents,
				ignoreExternals, force);
		return rev[0];
	} catch (ClientException e) {
		// upgradeProject(path);

		notificationHandler.logException(e);
		return 0;
		// throw new SVNClientException(e);
	}
}
 
Example 9
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public long[] update(File[] path, SVNRevision revision, int depth,
		boolean setDepth, boolean ignoreExternals, boolean force)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.UPDATE);
		Set<String> targets = new HashSet<String>(path.length);
		for (int i = 0; i < path.length; i++) {
			targets.add(fileToSVNPath(path[i], false));
		}
		Depth d = JhlConverter.depth(depth);
		StringBuffer commandLine = new StringBuffer(appendPaths("update ",
				targets)
				+ " -r "
				+ revision.toString()
				+ depthCommandLine(d));
		if (ignoreExternals)
			commandLine.append(" --ignore-externals");
		if (force)
			commandLine.append(" --force");
		notificationHandler.logCommandLine(commandLine.toString());
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path));
		notificationHandler.holdStats();
		boolean makeParents = false;
		long[] rtnCode = svnClient.update(targets,
				JhlConverter.convert(revision), d, setDepth, makeParents,
				ignoreExternals, force);
		notificationHandler.releaseStats();
		return rtnCode;
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example 10
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void switchToUrl(File path, SVNUrl url, SVNRevision revision,
		SVNRevision pegRevision, int depth, boolean setDepth,
		boolean ignoreExternals, boolean force, boolean ignoreAncestry)
		throws SVNClientException {
	if (depth == Depth.exclude.ordinal()) {
		update(path, pegRevision, depth, true, ignoreExternals, force);
		return;
	}
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.SWITCH);

		Depth d = JhlConverter.depth(depth);
		String target = fileToSVNPath(path, false);
		StringBuffer commandLine = new StringBuffer("switch " + url + " "
				+ target + " -r " + revision.toString()
				+ depthCommandLine(d));
		if (ignoreExternals)
			commandLine.append(" --ignore-externals");
		if (force)
			commandLine.append(" --force");
		notificationHandler.logCommandLine(commandLine.toString());
		File baseDir = SVNBaseDir.getBaseDir(path);
		notificationHandler.setBaseDir(baseDir);
		Revision rev = JhlConverter.convert(revision);
		Revision pegRev = JhlConverter.convert(pegRevision);
		svnClient.doSwitch(target, url.toString(), rev, pegRev, d,
				setDepth, ignoreExternals, force, ignoreAncestry);

	} catch (ClientException e) {
		// upgradeProject(path);
		notificationHandler.logException(e);
		// throw new SVNClientException(e);
	}

}
 
Example 11
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void diff(File path, SVNUrl url, SVNRevision urlRevision,
		File outFile, boolean recurse) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF);

		// we don't want canonical file path (otherwise the complete file
		// name
		// would be in the patch). This way the user can choose to use a
		// relative
		// path
		String wcPath = fileToSVNPath(path, false);
		String svnOutFile = fileToSVNPath(outFile, false);

		String commandLine = "diff --old " + wcPath + " ";
		commandLine += "--new " + url.toString();
		if (!urlRevision.equals(SVNRevision.HEAD))
			commandLine += "@" + urlRevision.toString();

		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir(SVNBaseDir.getBaseDir(path));
		svnClient.diff(wcPath, Revision.WORKING, url.toString(),
				JhlConverter.convert(urlRevision), null, svnOutFile,
				Depth.infinityOrEmpty(recurse), null, false, true, false,
				true);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example 12
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public ISVNDirEntryWithLock[] getListWithLocks(SVNUrl url,
		SVNRevision revision, SVNRevision pegRevision, boolean recurse)
		throws SVNClientException {
	final List<JhlDirEntryWithLock> dirEntryList = new ArrayList<JhlDirEntryWithLock>();
	ListCallback callback = new ListCallback() {
		public void doEntry(DirEntry dirent, Lock lock) {
			if (dirent.getPath().length() == 0) {
				if (dirent.getNodeKind() == org.apache.subversion.javahl.types.NodeKind.file) {
					String absPath = dirent.getAbsPath();
					int lastSeparator = absPath.lastIndexOf('/');
					String path = absPath.substring(lastSeparator,
							absPath.length());
					dirent.setPath(path);
				} else {
					// Don't add requested directory.
					return;
				}
			}

			dirEntryList.add(new JhlDirEntryWithLock(dirent, lock));

		}

	};
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.LS);
		String commandLine = "list -r " + revision.toString()
				+ (recurse ? "-R" : "") + " " + url.toString();
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir(new File("."));
		svnClient.list(url.toString(), JhlConverter.convert(revision),
				JhlConverter.convert(pegRevision),
				Depth.infinityOrImmediates(recurse), DirEntry.Fields.all,
				true, callback);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
	ISVNDirEntryWithLock[] dirEntries = new ISVNDirEntryWithLock[dirEntryList
			.size()];
	dirEntryList.toArray(dirEntries);
	return dirEntries;
}
 
Example 13
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void diff(SVNUrl oldUrl, SVNRevision oldUrlRevision, SVNUrl newUrl,
		SVNRevision newUrlRevision, File outFile, boolean recurse,
		boolean ignoreAncestry, boolean noDiffDeleted, boolean force)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.DIFF);

		if (newUrl == null)
			newUrl = oldUrl;
		if (oldUrlRevision == null)
			oldUrlRevision = SVNRevision.HEAD;
		if (newUrlRevision == null)
			newUrlRevision = SVNRevision.HEAD;

		String svnOutFile = fileToSVNPath(outFile, false);

		String commandLine = "diff ";
		if ((oldUrlRevision.getKind() != Revision.Kind.head.ordinal())
				|| (newUrlRevision.getKind() != Revision.Kind.head
						.ordinal())) {
			commandLine += "-r " + oldUrlRevision.toString();
			if (newUrlRevision.getKind() != Revision.Kind.head.ordinal())
				commandLine += ":" + newUrlRevision.toString();
			commandLine += " ";
		}
		commandLine += oldUrl + " ";
		if (!newUrl.equals(oldUrl))
			commandLine += newUrl + " ";

		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir();
		svnClient.diff(oldUrl.toString(),
				JhlConverter.convert(oldUrlRevision), newUrl.toString(),
				JhlConverter.convert(newUrlRevision), null, svnOutFile,
				Depth.infinityOrEmpty(recurse), null, ignoreAncestry,
				noDiffDeleted, force, false);
	} catch (ClientException e) {
		notificationHandler.logException(e);
		throw new SVNClientException(e);
	}
}
 
Example 14
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
private ISVNAnnotations annotate(String target, SVNRevision revisionStart,
		SVNRevision revisionEnd, SVNRevision pegRevision,
		boolean ignoreMimeType, boolean includeMergedRevisions)
		throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.ANNOTATE);
		if (revisionStart == null)
			revisionStart = new SVNRevision.Number(1);
		if (revisionEnd == null)
			revisionEnd = SVNRevision.HEAD;
		if (pegRevision == null)
			pegRevision = SVNRevision.HEAD;
		String commandLine = "blame ";
		if (includeMergedRevisions)
			commandLine += "-g ";
		commandLine = commandLine + "-r " + revisionStart.toString() + ":"
				+ revisionEnd.toString() + " ";
		commandLine = commandLine + target + "@" + pegRevision;
		notificationHandler.logCommandLine(commandLine);
		notificationHandler.setBaseDir();

		JhlAnnotations annotations = new JhlAnnotations();
		svnClient.blame(target, JhlConverter.convert(pegRevision),
				JhlConverter.convert(revisionStart),
				JhlConverter.convert(revisionEnd), ignoreMimeType,
				includeMergedRevisions, annotations);
		return annotations;
	} catch (ClientException e) {
		if (includeMergedRevisions
				&& ((ClientException) e).getAprError() == SVNClientException.UNSUPPORTED_FEATURE) {
			return annotate(target, revisionStart, revisionEnd,
					pegRevision, ignoreMimeType, false);
		}
		if (e.getAprError() == ErrorCodes.fsNotFound && pegRevision != null
				&& !pegRevision.equals(revisionEnd)) {
			return annotate(target, revisionStart, pegRevision,
					pegRevision, ignoreMimeType, includeMergedRevisions);
		} else {
			notificationHandler.logException(e);
			throw new SVNClientException(e);
		}
	}

}
 
Example 15
Source File: AbstractJhlClientAdapter.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void merge(SVNUrl path1, SVNRevision revision1, SVNUrl path2,
		SVNRevision revision2, SVNRevision pegRevision, File localPath,
		boolean force, int depth, boolean dryRun, boolean ignoreAncestry,
		boolean recordOnly) throws SVNClientException {
	try {
		notificationHandler.setCommand(ISVNNotifyListener.Command.MERGE);

		Depth d = JhlConverter.depth(depth);
		String target = fileToSVNPath(localPath, false);
		String commandLine = "merge";
		boolean samePath = false;
		if (dryRun) {
			commandLine += " --dry-run";
		}
		commandLine += depthCommandLine(d);
		if (force) {
			commandLine += " --force";
		}
		if (ignoreAncestry) {
			commandLine += " --ignore-ancestry";
		}
		if (path1.toString().equals(path2.toString())) {
			samePath = true;
			if (revision1 == null || revision2 == null)
				commandLine += " " + path1;
			else
				commandLine += " -r" + revision1.toString() + ":"
						+ revision2.toString() + " " + path1;
		} else {
			commandLine += " " + path1 + "@" + revision1.toString() + " "
					+ path2 + "@" + revision2.toString();
		}
		commandLine += " " + target;
		notificationHandler.logCommandLine(commandLine);
		File baseDir = SVNBaseDir.getBaseDir(localPath);
		notificationHandler.setBaseDir(baseDir);

		if (samePath) {
			List<RevisionRange> revisionRanges;
			if (revision1 == null && revision2 == null) {
				revisionRanges = null;
			} else {
				Revision rev1;
				Revision rev2;
				if (revision1 == null)
					rev1 = Revision.START;
				else
					rev1 = JhlConverter.convert(revision1);
				if (revision2 == null)
					rev2 = Revision.START;
				else
					rev2 = JhlConverter.convert(revision2);
				revisionRanges = new ArrayList<RevisionRange>();
				revisionRanges.add(new RevisionRange(rev1, rev2));
			}
			svnClient.merge(path1.toString(),
					JhlConverter.convert(pegRevision), revisionRanges,
					target, force, d, ignoreAncestry, dryRun, recordOnly);
		} else
			svnClient.merge(path1.toString(),
					JhlConverter.convert(revision1), path2.toString(),
					JhlConverter.convert(revision2), target, force, d,
					ignoreAncestry, dryRun, recordOnly);
		if (dryRun)
			notificationHandler.logCompleted("Dry-run merge complete.");
		else
			notificationHandler.logCompleted("Merge complete.");
	} catch (ClientException e) {
		// 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;
	}
}