use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.
the class LatestExistentSearcher method existsInRevision.
private boolean existsInRevision(@NotNull SVNURL url, long revisionNumber) throws SvnBindException {
SVNRevision revision = SVNRevision.create(revisionNumber);
Info info = null;
try {
info = myVcs.getInfo(url, revision, revision);
} catch (SvnBindException e) {
// throw error if not "does not exist" error code
if (!e.contains(SVNErrorCode.RA_ILLEGAL_URL)) {
throw e;
}
}
return info != null;
}
use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.
the class BranchInfo method checkPathGoingUp.
@NotNull
private SvnMergeInfoCache.MergeCheckResult checkPathGoingUp(final long revisionAsked, final long targetRevision, @NotNull String branchRootPath, @NotNull String path, final String trunkUrl, final boolean self) throws VcsException, SVNException {
SvnMergeInfoCache.MergeCheckResult result;
final File pathFile = new File(path);
// check whether we locally have path
if (targetRevision == -1 && !pathFile.exists()) {
result = goUp(revisionAsked, targetRevision, branchRootPath, path, trunkUrl);
} else {
final Info svnInfo = myVcs.getInfo(pathFile);
if (svnInfo == null || svnInfo.getURL() == null) {
LOG.info("Svninfo for " + pathFile + " is null or not full.");
result = SvnMergeInfoCache.MergeCheckResult.NOT_MERGED;
} else {
final long actualRevision = svnInfo.getRevision().getNumber();
final long targetRevisionCorrected = (targetRevision == -1) ? actualRevision : targetRevision;
// here we know local URL and revision
// check existing info
final String keyString = path + "@" + targetRevisionCorrected;
final Set<Long> selfInfo = self ? myNonInheritablePathMergedMap.get(keyString) : null;
final Set<Long> mergeInfo = myPathMergedMap.get(keyString);
if (mergeInfo != null || selfInfo != null) {
boolean merged = mergeInfo != null && mergeInfo.contains(revisionAsked) || selfInfo != null && selfInfo.contains(revisionAsked);
// take from self or first parent with info; do not go further
result = SvnMergeInfoCache.MergeCheckResult.getInstance(merged);
} else {
if (actualRevision != targetRevisionCorrected) {
myMixedRevisionsFound = true;
}
SvnTarget target;
SVNRevision revision;
if (actualRevision == targetRevisionCorrected) {
// look in WC
target = SvnTarget.fromFile(pathFile, SVNRevision.WORKING);
revision = SVNRevision.WORKING;
} else {
// in repo
target = SvnTarget.fromURL(svnInfo.getURL());
revision = SVNRevision.create(targetRevisionCorrected);
}
PropertyValue mergeinfoProperty = myVcs.getFactory(target).createPropertyClient().getProperty(target, SvnPropertyKeys.MERGE_INFO, false, revision);
result = mergeinfoProperty == null ? goUp(revisionAsked, targetRevisionCorrected, branchRootPath, path, trunkUrl) : processMergeinfoProperty(keyString, revisionAsked, mergeinfoProperty, trunkUrl, self);
}
}
}
return result;
}
use of org.tmatesoft.svn.core.wc.SVNRevision in project intellij-community by JetBrains.
the class CreateBranchOrTagAction method perform.
@Override
protected void perform(@NotNull SvnVcs vcs, @NotNull VirtualFile file, @NotNull DataContext context) throws VcsException {
CreateBranchOrTagDialog dialog = new CreateBranchOrTagDialog(vcs.getProject(), true, virtualToIoFile(file));
if (dialog.showAndGet()) {
String dstURL = dialog.getToURL();
SVNRevision revision = dialog.getRevision();
String comment = dialog.getComment();
Ref<Exception> exception = new Ref<>();
boolean isSrcFile = dialog.isCopyFromWorkingCopy();
File srcFile = new File(dialog.getCopyFromPath());
SVNURL srcUrl;
SVNURL dstSvnUrl;
SVNURL parentUrl;
try {
srcUrl = SVNURL.parseURIEncoded(dialog.getCopyFromUrl());
dstSvnUrl = SVNURL.parseURIEncoded(dstURL);
parentUrl = dstSvnUrl.removePathTail();
} catch (SVNException e) {
throw new SvnBindException(e);
}
if (!dirExists(vcs, parentUrl)) {
int rc = Messages.showYesNoDialog(vcs.getProject(), "The repository path '" + parentUrl + "' does not exist. Would you like to create it?", "Branch or Tag", Messages.getQuestionIcon());
if (rc == Messages.NO) {
return;
}
}
Runnable copyCommand = () -> {
try {
ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
CommitEventHandler handler = null;
if (progress != null) {
progress.setText(SvnBundle.message("progress.text.copy.to", dstURL));
handler = new IdeaCommitHandler(progress);
}
SvnTarget source = isSrcFile ? SvnTarget.fromFile(srcFile, revision) : SvnTarget.fromURL(srcUrl, revision);
long newRevision = vcs.getFactory(source).createCopyMoveClient().copy(source, SvnTarget.fromURL(dstSvnUrl), revision, true, false, comment, handler);
updateStatusBar(newRevision, vcs.getProject());
} catch (Exception e) {
exception.set(e);
}
};
ProgressManager.getInstance().runProcessWithProgressSynchronously(copyCommand, SvnBundle.message("progress.title.copy"), false, vcs.getProject());
if (!exception.isNull()) {
throw new VcsException(exception.get());
}
if (dialog.isCopyFromWorkingCopy() && dialog.isSwitchOnCreate()) {
SingleRootSwitcher switcher = new SingleRootSwitcher(vcs.getProject(), VcsUtil.getFilePath(srcFile, srcFile.isDirectory()), dstSvnUrl);
AutoSvnUpdater.run(switcher, SvnBundle.message("action.name.switch"));
}
}
}
use of org.tmatesoft.svn.core.wc.SVNRevision in project sling by apache.
the class SvnChangeLogFinder method getChanges.
public List<String> getChanges(String first, String second) throws SVNException {
SVNURL svnUrl = SVNURL.parseURIEncoded(SLING_SVN_REPO_BASE);
List<String> changes = new ArrayList<>();
SVNClientManager manager = SVNClientManager.newInstance();
SVNRepository repo = manager.getRepositoryPool().createRepository(svnUrl, true);
SVNRevision from = SVNRevision.create(getRevision(first, repo));
SVNRevision to = SVNRevision.create(getRevision(second, repo));
repo.log(new String[] { "tags/" + second }, from.getNumber(), to.getNumber(), false, false, (e) -> changes.add(e.getMessage()));
return changes;
}
Aggregations