use of com.intellij.openapi.vcs.changes.ContentRevision in project intellij-community by JetBrains.
the class ChangesChecker method gather.
public void gather(final List<Change> changes) {
final TreeMap<String, File> renames = new TreeMap<>();
final Set<String> alsoReverted = new HashSet<>();
final Map<String, FilePath> files = new HashMap<>();
for (Change change : changes) {
final ContentRevision beforeRevision = change.getBeforeRevision();
final ContentRevision afterRevision = change.getAfterRevision();
final String key = afterRevision == null ? null : FilePathsHelper.convertWithLastSeparator(afterRevision.getFile());
if (SvnRollbackEnvironment.isMoveRenameReplace(change)) {
final File beforeFile = beforeRevision.getFile().getIOFile();
renames.put(key, beforeFile);
files.put(key, afterRevision.getFile());
myCollector.markRename(beforeFile, afterRevision.getFile().getIOFile());
} else if (afterRevision != null) {
alsoReverted.add(key);
}
}
if (!renames.isEmpty()) {
final ArrayList<String> paths = new ArrayList<>(renames.keySet());
if (paths.size() > 1) {
FilterFilePathStrings.getInstance().doFilter(paths);
}
myCollector.setRenamesMap(renames);
myCollector.setAlsoReverted(alsoReverted);
for (String path : paths) {
try {
myChangeProvider.getChanges(files.get(path), true, myCollector);
} catch (SVNException e) {
myExceptions.add(new VcsException(e));
} catch (SvnBindException e) {
myExceptions.add(e);
}
}
}
for (Change change : changes) {
final ContentRevision afterRevision = change.getAfterRevision();
boolean checked = myForAdds.accept(change);
checked |= myForDeletes.accept(change);
if (!checked) {
myForEdits.add(afterRevision.getFile().getIOFile());
}
}
}
use of com.intellij.openapi.vcs.changes.ContentRevision in project intellij-community by JetBrains.
the class HgDiffProviderTest method shouldFindCurrentRevisionForRenamedFile.
@Test
public void shouldFindCurrentRevisionForRenamedFile() throws Exception {
fillFile(myProjectDir, new String[] { AFILE }, INITIAL_FILE_CONTENT);
addAll();
commitAll("initial content");
fillFile(myProjectDir, new String[] { AFILE }, UPDATED_FILE_CONTENT);
commitAll("updated content");
runHgOnProjectRepo("rename", AFILE, BFILE);
//don't commit
refreshVfs();
ChangeListManager.getInstance(myProject).ensureUpToDate(false);
HgDiffProvider diffProvider = new HgDiffProvider(myProject);
VirtualFile child = myWorkingCopyDir.findChild(BFILE);
ContentRevision fileContent = diffProvider.createFileContent(diffProvider.getCurrentRevision(child), child);
assertNotNull(fileContent);
assertEquals(fileContent.getContent(), UPDATED_FILE_CONTENT);
}
use of com.intellij.openapi.vcs.changes.ContentRevision in project intellij-community by JetBrains.
the class SvnCommittedViewTest method printChanges.
private static String printChanges(final Data data, final Collection<Change> changes) {
final StringBuilder sb = new StringBuilder("Data: ").append(data.myLocalPath).append(" exists: ").append(new File(data.myLocalPath).exists()).append(" Changes: ");
for (Change change : changes) {
final ContentRevision cr = change.getAfterRevision() == null ? change.getBeforeRevision() : change.getAfterRevision();
final File ioFile = cr.getFile().getIOFile();
sb.append("'").append(ioFile.getAbsolutePath()).append("' exists: ").append(ioFile.exists()).append(" | ");
}
return sb.toString();
}
Aggregations