use of com.intellij.openapi.vcs.changes.Change in project intellij-community by JetBrains.
the class HgUtil method getOriginalFileName.
@NotNull
public static FilePath getOriginalFileName(@NotNull FilePath filePath, ChangeListManager changeListManager) {
Change change = changeListManager.getChange(filePath);
if (change == null) {
return filePath;
}
FileStatus status = change.getFileStatus();
if (status == HgChangeProvider.COPIED || status == HgChangeProvider.RENAMED) {
ContentRevision beforeRevision = change.getBeforeRevision();
assert beforeRevision != null : "If a file's status is copied or renamed, there must be an previous version";
return beforeRevision.getFile();
} else {
return filePath;
}
}
use of com.intellij.openapi.vcs.changes.Change in project intellij-community by JetBrains.
the class HgUtil method getDiff.
@NotNull
public static List<Change> getDiff(@NotNull final Project project, @NotNull final VirtualFile root, @NotNull final FilePath path, @Nullable final HgRevisionNumber revNum1, @Nullable final HgRevisionNumber revNum2) {
HgStatusCommand statusCommand;
if (revNum1 != null) {
//rev2==null means "compare with local version"
statusCommand = new HgStatusCommand.Builder(true).ignored(false).unknown(false).copySource(!path.isDirectory()).baseRevision(revNum1).targetRevision(revNum2).build(project);
} else {
//rev1 and rev2 can't be null both//
LOG.assertTrue(revNum2 != null, "revision1 and revision2 can't both be null. Path: " + path);
//get initial changes//
statusCommand = new HgStatusCommand.Builder(true).ignored(false).unknown(false).copySource(false).baseRevision(revNum2).build(project);
}
Collection<HgChange> hgChanges = statusCommand.executeInCurrentThread(root, Collections.singleton(path));
List<Change> changes = new ArrayList<>();
//convert output changes to standard Change class
for (HgChange hgChange : hgChanges) {
FileStatus status = convertHgDiffStatus(hgChange.getStatus());
if (status != FileStatus.UNKNOWN) {
changes.add(HgHistoryUtil.createChange(project, root, hgChange.beforeFile().getRelativePath(), revNum1, hgChange.afterFile().getRelativePath(), revNum2, status));
}
}
return changes;
}
use of com.intellij.openapi.vcs.changes.Change in project intellij-community by JetBrains.
the class SvnCheckinHandlerFactory method splitIntoCopies.
@NotNull
private static MultiMap<String, WorkingCopyFormat> splitIntoCopies(@NotNull SvnVcs vcs, @NotNull Collection<Change> changes) {
MultiMap<String, WorkingCopyFormat> result = MultiMap.createSet();
SvnFileUrlMapping mapping = vcs.getSvnFileUrlMapping();
for (Change change : changes) {
RootUrlInfo path = mapping.getWcRootForFilePath(ChangesUtil.getFilePath(change).getIOFile());
if (path != null) {
result.putValue(path.getRepositoryUrl(), path.getFormat());
}
}
return result;
}
use of com.intellij.openapi.vcs.changes.Change in project intellij-community by JetBrains.
the class HgVFSListener method executeDelete.
protected void executeDelete() {
final List<FilePath> filesToDelete = new ArrayList<>(myDeletedWithoutConfirmFiles);
final List<FilePath> filesToConfirmDeletion = new ArrayList<>(myDeletedFiles);
myDeletedWithoutConfirmFiles.clear();
myDeletedFiles.clear();
// skip files which are not under Mercurial
skipNotUnderHg(filesToDelete);
skipNotUnderHg(filesToConfirmDeletion);
filesToDelete.removeAll(processAndGetVcsIgnored(filesToDelete));
filesToConfirmDeletion.removeAll(processAndGetVcsIgnored(filesToConfirmDeletion));
// but without user confirmation.
for (Iterator<FilePath> it = filesToConfirmDeletion.iterator(); it.hasNext(); ) {
FilePath filePath = it.next();
Change fileChange = ChangeListManager.getInstance(myProject).getChange(filePath);
if (fileChange != null && fileChange.getFileStatus().equals(FileStatus.ADDED)) {
filesToDelete.add(filePath);
it.remove();
}
}
new Task.ConditionalModal(myProject, HgVcsMessages.message("hg4idea.remove.progress"), false, VcsConfiguration.getInstance(myProject).getAddRemoveOption()) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
// confirm removal from the VCS if needed
if (myRemoveOption.getValue() != VcsShowConfirmationOption.Value.DO_NOTHING_SILENTLY) {
if (myRemoveOption.getValue() == VcsShowConfirmationOption.Value.DO_ACTION_SILENTLY || filesToConfirmDeletion.isEmpty()) {
filesToDelete.addAll(filesToConfirmDeletion);
} else {
final AtomicReference<Collection<FilePath>> filePaths = new AtomicReference<>();
ApplicationManager.getApplication().invokeAndWait(() -> filePaths.set(selectFilePathsToDelete(filesToConfirmDeletion)));
if (filePaths.get() != null) {
filesToDelete.addAll(filePaths.get());
}
}
}
if (!filesToDelete.isEmpty()) {
performDeletion(filesToDelete);
}
}
}.queue();
}
use of com.intellij.openapi.vcs.changes.Change in project intellij-community by JetBrains.
the class HgCompareWithBranchAction method getDiffChanges.
@Override
@NotNull
protected Collection<Change> getDiffChanges(@NotNull Project project, @NotNull VirtualFile file, @NotNull String branchToCompare) throws VcsException {
HgRepository repository = getRepositoryManager(project).getRepositoryForFile(file);
if (repository == null) {
throw new VcsException("Couldn't find repository for " + file.getName());
}
final FilePath filePath = VcsUtil.getFilePath(file);
final VirtualFile repositoryRoot = repository.getRoot();
final HgFile hgFile = new HgFile(repositoryRoot, filePath);
Hash refHashToCompare = detectActiveHashByName(repository, branchToCompare);
if (refHashToCompare == null) {
throw new VcsException(String.format("Couldn't detect commit related to %s name for %s.", branchToCompare, file));
}
final HgRevisionNumber compareWithRevisionNumber = HgRevisionNumber.getInstance(branchToCompare, refHashToCompare.toString());
List<Change> changes = HgUtil.getDiff(project, repositoryRoot, filePath, compareWithRevisionNumber, null);
if (changes.isEmpty() && !existInBranch(repository, filePath, compareWithRevisionNumber)) {
throw new VcsException(fileDoesntExistInBranchError(file, branchToCompare));
}
return changes.isEmpty() && !filePath.isDirectory() ? createChangesWithCurrentContentForFile(filePath, HgContentRevision.create(project, hgFile, compareWithRevisionNumber)) : changes;
}
Aggregations