use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class SingleCommittedListProvider method searchFromHead.
// return changed path, if any
private FilePath searchFromHead(@NotNull SVNURL url) throws VcsException {
final SvnCopyPathTracker pathTracker = new SvnCopyPathTracker(repositoryUrl.toDecodedString(), repositoryRelativeUrl);
SvnTarget target = SvnTarget.fromURL(url);
myVcs.getFactory(target).createHistoryClient().doLog(target, SVNRevision.HEAD, revisionBefore, false, true, false, 0, null, logEntry -> {
checkDisposed();
if (logEntry.getDate() != null) {
pathTracker.accept(logEntry);
if (logEntry.getRevision() == revisionBefore.getNumber()) {
changeList[0] = createChangeList(logEntry);
}
}
});
FilePath path = pathTracker.getFilePath(myVcs);
return path == null ? filePath : path;
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class SvnChangeList method createLists.
private void createLists() {
myListsHolder = new ChangesListCreationHelper();
// key: copied-from
final Map<String, ExternallyRenamedChange> copiedAddedChanges = new HashMap<>();
correctBeforePaths();
final List<String> copyDeleted = new ArrayList<>(myDeletedPaths);
for (String path : myAddedPaths) {
final Change addedChange;
if (myCopiedAddedPaths.containsKey(path)) {
final String copyTarget = myCopiedAddedPaths.get(path);
if (copyDeleted.contains(copyTarget)) {
addedChange = new ExternallyRenamedChange(myListsHolder.createRevisionLazily(copyTarget, true), myListsHolder.createRevisionLazily(path, false), copyTarget);
addedChange.getMoveRelativePath(myVcs.getProject());
((ExternallyRenamedChange) addedChange).setCopied(false);
copyDeleted.remove(copyTarget);
} else {
addedChange = new ExternallyRenamedChange(null, myListsHolder.createRevisionLazily(path, false), copyTarget);
}
copiedAddedChanges.put(copyTarget, (ExternallyRenamedChange) addedChange);
} else {
addedChange = new Change(null, myListsHolder.createRevisionLazily(path, false));
}
myListsHolder.add(path, addedChange);
}
for (String path : copyDeleted) {
final Change deletedChange;
if (copiedAddedChanges.containsKey(path)) {
// seems never occurs any more
final ExternallyRenamedChange addedChange = copiedAddedChanges.get(path);
final FilePath source = addedChange.getAfterRevision().getFile();
deletedChange = new ExternallyRenamedChange(myListsHolder.createDeletedItemRevision(path, true), null, path);
((ExternallyRenamedChange) deletedChange).setCopied(false);
//noinspection ConstantConditions
//addedChange.setRenamedOrMovedTarget(deletedChange.getBeforeRevision().getFile());
//noinspection ConstantConditions
((ExternallyRenamedChange) deletedChange).setRenamedOrMovedTarget(source);
} else {
deletedChange = new Change(myListsHolder.createDeletedItemRevision(path, true), null);
}
myListsHolder.add(path, deletedChange);
}
for (String path : myChangedPaths) {
boolean moveAndChange = false;
final boolean replaced = myReplacedPaths.contains(path);
// this piece: for copied-from (or moved) and further modified
for (String addedPath : myAddedPaths) {
String copyFromPath = myCopiedAddedPaths.get(addedPath);
if ((copyFromPath != null) && (SVNPathUtil.isAncestor(addedPath, path))) {
if (addedPath.length() < path.length()) {
final String relative = SVNPathUtil.getRelativePath(addedPath, path);
copyFromPath = SVNPathUtil.append(copyFromPath, relative);
}
final ExternallyRenamedChange renamedChange = new ExternallyRenamedChange(myListsHolder.createRevisionLazily(copyFromPath, true), myListsHolder.createRevisionLazily(path, false), copyFromPath);
moveAndChange = true;
renamedChange.getMoveRelativePath(myVcs.getProject());
renamedChange.setIsReplaced(replaced);
final ExternallyRenamedChange addedChange = copiedAddedChanges.get(myCopiedAddedPaths.get(addedPath));
renamedChange.setCopied(addedChange != null && addedChange.isCopied());
myListsHolder.add(path, renamedChange);
break;
}
}
if (!moveAndChange) {
final ExternallyRenamedChange renamedChange = new ExternallyRenamedChange(myListsHolder.createRevisionLazily(path, true), myListsHolder.createRevisionLazily(path, false), null);
renamedChange.setIsReplaced(replaced);
renamedChange.setCopied(false);
myListsHolder.add(path, renamedChange);
}
}
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class SvnChangeList method patchChange.
private void patchChange(Change change, final String path) {
final SVNURL becameUrl;
SVNURL wasUrl;
try {
becameUrl = SVNURL.parseURIEncoded(SVNPathUtil.append(myRepositoryRoot, path));
wasUrl = becameUrl;
if (change instanceof ExternallyRenamedChange && change.getBeforeRevision() != null) {
String originUrl = ((ExternallyRenamedChange) change).getOriginUrl();
if (originUrl != null) {
// use another url for origin
wasUrl = SVNURL.parseURIEncoded(SVNPathUtil.append(myRepositoryRoot, originUrl));
}
}
} catch (SVNException e) {
// nothing to do
LOG.info(e);
return;
}
final FilePath filePath = ChangesUtil.getFilePath(change);
final Change additional = new Change(createPropertyRevision(filePath, change.getBeforeRevision(), wasUrl), createPropertyRevision(filePath, change.getAfterRevision(), becameUrl));
change.addAdditionalLayerElement(SvnChangeProvider.PROPERTY_LAYER, additional);
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class ChangeListTodosTreeStructure method accept.
@Override
public boolean accept(final PsiFile psiFile) {
if (!psiFile.isValid())
return false;
VirtualFile file = psiFile.getVirtualFile();
ChangeListManager listManager = ChangeListManager.getInstance(myProject);
FileStatus status = listManager.getStatus(file);
if (status == FileStatus.NOT_CHANGED)
return false;
FilePath filePath = VcsUtil.getFilePath(file);
final Collection<Change> changes = listManager.getDefaultChangeList().getChanges();
for (Change change : changes) {
ContentRevision afterRevision = change.getAfterRevision();
if (afterRevision != null && afterRevision.getFile().equals(filePath)) {
return (myTodoFilter != null && myTodoFilter.accept(mySearchHelper, psiFile) || (myTodoFilter == null && mySearchHelper.getTodoItemsCount(psiFile) > 0));
}
}
return false;
}
use of com.intellij.openapi.vcs.FilePath in project intellij-community by JetBrains.
the class DiffRequestFactoryImpl method getTitle.
@NotNull
public static String getTitle(@NotNull FilePath path1, @NotNull FilePath path2, @NotNull String separator) {
if ((path1.isDirectory() || path2.isDirectory()) && path1.getPath().equals(path2.getPath())) {
return path1.getPresentableUrl();
}
String name1 = path1.getName();
String name2 = path2.getName();
if (path1.isDirectory() ^ path2.isDirectory()) {
if (path1.isDirectory())
name1 += File.separatorChar;
if (path2.isDirectory())
name2 += File.separatorChar;
}
FilePath parent1 = path1.getParentPath();
FilePath parent2 = path2.getParentPath();
return getRequestTitle(name1, path1.getPresentableUrl(), parent1 != null ? parent1.getPresentableUrl() : null, name2, path2.getPresentableUrl(), parent2 != null ? parent2.getPresentableUrl() : null, separator);
}
Aggregations