use of org.jetbrains.idea.svn.SvnRevisionNumber in project intellij-community by JetBrains.
the class SvnMergeProvider method loadRevisions.
@NotNull
public MergeData loadRevisions(@NotNull final VirtualFile file) throws VcsException {
final MergeData data = new MergeData();
VcsRunnable runnable = () -> {
File oldFile = null;
File newFile = null;
File workingFile = null;
boolean mergeCase = false;
SvnVcs vcs = SvnVcs.getInstance(myProject);
Info info = vcs.getInfo(file);
if (info != null) {
oldFile = info.getConflictOldFile();
newFile = info.getConflictNewFile();
workingFile = info.getConflictWrkFile();
mergeCase = workingFile == null || workingFile.getName().contains("working");
// for debug
if (workingFile == null) {
LOG.info("Null working file when merging text conflict for " + file.getPath() + " old file: " + oldFile + " new file: " + newFile);
}
if (mergeCase) {
// this is merge case
oldFile = info.getConflictNewFile();
newFile = info.getConflictOldFile();
workingFile = info.getConflictWrkFile();
}
data.LAST_REVISION_NUMBER = new SvnRevisionNumber(info.getRevision());
} else {
throw new VcsException("Could not get info for " + file.getPath());
}
if (oldFile == null || newFile == null || workingFile == null) {
ByteArrayOutputStream bos = getBaseRevisionContents(vcs, file);
data.ORIGINAL = bos.toByteArray();
data.LAST = bos.toByteArray();
data.CURRENT = readFile(virtualToIoFile(file));
} else {
data.ORIGINAL = readFile(oldFile);
data.LAST = readFile(newFile);
data.CURRENT = readFile(workingFile);
}
if (mergeCase) {
final ByteArrayOutputStream contents = getBaseRevisionContents(vcs, file);
if (!Arrays.equals(contents.toByteArray(), data.ORIGINAL)) {
// swap base and server: another order of merge arguments
byte[] original = data.ORIGINAL;
data.ORIGINAL = data.LAST;
data.LAST = original;
}
}
};
VcsUtil.runVcsProcessWithProgress(runnable, VcsBundle.message("multiple.file.merge.loading.progress.title"), false, myProject);
return data;
}
use of org.jetbrains.idea.svn.SvnRevisionNumber in project intellij-community by JetBrains.
the class UpdateEventHandler method setRevisionForWaitingFiles.
private void setRevisionForWaitingFiles(long revisionNumber) {
SvnRevisionNumber revision = new SvnRevisionNumber(SVNRevision.create(revisionNumber));
for (Pair<String, String> pair : myFilesWaitingForRevision.pop()) {
FileGroup fileGroup = myUpdatedFiles.getGroupById(pair.getFirst());
fileGroup.add(pair.getSecond(), SvnVcs.getKey(), revision);
}
}
use of org.jetbrains.idea.svn.SvnRevisionNumber in project intellij-community by JetBrains.
the class SvnHistoryProvider method reportAppendableHistory.
public void reportAppendableHistory(FilePath path, final VcsAppendableHistorySessionPartner partner, @Nullable final SVNRevision from, @Nullable final SVNRevision to, final int limit, SVNRevision peg, final boolean forceBackwards) throws VcsException {
FilePath committedPath = path;
Change change = ChangeListManager.getInstance(myVcs.getProject()).getChange(path);
if (change != null) {
final ContentRevision beforeRevision = change.getBeforeRevision();
final ContentRevision afterRevision = change.getAfterRevision();
if (beforeRevision != null && afterRevision != null && !beforeRevision.getFile().equals(afterRevision.getFile()) && afterRevision.getFile().equals(path)) {
committedPath = beforeRevision.getFile();
}
// revision can be VcsRevisionNumber.NULL
if (peg == null && change.getBeforeRevision() != null && change.getBeforeRevision().getRevisionNumber() instanceof SvnRevisionNumber) {
peg = ((SvnRevisionNumber) change.getBeforeRevision().getRevisionNumber()).getRevision();
}
}
boolean showMergeSources = myVcs.getSvnConfiguration().isShowMergeSourcesInAnnotate();
final LogLoader logLoader;
if (path.isNonLocal()) {
logLoader = new RepositoryLoader(myVcs, committedPath, from, to, limit, peg, forceBackwards, showMergeSources);
} else {
logLoader = new LocalLoader(myVcs, committedPath, from, to, limit, peg, showMergeSources);
}
try {
logLoader.preliminary();
} catch (SVNException e) {
throw new VcsException(e);
}
logLoader.check();
if (showMergeSources) {
logLoader.initSupports15();
}
final SvnHistorySession historySession = new SvnHistorySession(myVcs, Collections.emptyList(), committedPath, showMergeSources && Boolean.TRUE.equals(logLoader.mySupport15), null, false, !path.isNonLocal());
final Ref<Boolean> sessionReported = new Ref<>();
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
if (indicator != null) {
indicator.setText(SvnBundle.message("progress.text2.collecting.history", path.getName()));
}
final Consumer<VcsFileRevision> consumer = vcsFileRevision -> {
if (!Boolean.TRUE.equals(sessionReported.get())) {
partner.reportCreatedEmptySession(historySession);
sessionReported.set(true);
}
partner.acceptRevision(vcsFileRevision);
};
logLoader.setConsumer(consumer);
logLoader.load();
logLoader.check();
}
Aggregations