use of com.intellij.history.Label in project intellij-community by JetBrains.
the class HistoryReverterToLabelTest method testRevertContentChange.
public void testRevertContentChange() throws Exception {
VirtualFile f = createChildData(myRoot, "foo.txt");
int modificationStamp1 = -1;
setBinaryContent(f, new byte[] { 1 }, modificationStamp1, 1000, this);
final Label testLabel = LocalHistory.getInstance().putSystemLabel(myProject, "testLabel");
int modificationStamp = -1;
setBinaryContent(f, new byte[] { 2 }, modificationStamp, 2000, this);
setBinaryContent(f, new byte[] { 3 }, modificationStamp, 3000, this);
revertToLabel(testLabel, myRoot);
f = myRoot.findChild("foo.txt");
assertNotNull(f);
assertEquals(1, f.contentsToByteArray()[0]);
assertEquals(1000, f.getTimeStamp());
}
use of com.intellij.history.Label in project intellij-community by JetBrains.
the class PatchApplier method executePatchGroup.
@CalledInAwt
public static ApplyPatchStatus executePatchGroup(final Collection<PatchApplier> group, final LocalChangeList localChangeList) {
//?
if (group.isEmpty())
return ApplyPatchStatus.SUCCESS;
final Project project = group.iterator().next().myProject;
ApplyPatchStatus result = ApplyPatchStatus.SUCCESS;
for (PatchApplier patchApplier : group) {
result = ApplyPatchStatus.and(result, patchApplier.nonWriteActionPreCheck());
}
final Label beforeLabel = LocalHistory.getInstance().putSystemLabel(project, "Before patch");
final TriggerAdditionOrDeletion trigger = new TriggerAdditionOrDeletion(project);
final Ref<ApplyPatchStatus> refStatus = new Ref<>(result);
try {
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
for (PatchApplier applier : group) {
refStatus.set(ApplyPatchStatus.and(refStatus.get(), applier.createFiles()));
applier.addSkippedItems(trigger);
}
trigger.prepare();
if (refStatus.get() == ApplyPatchStatus.SUCCESS) {
// all pre-check results are valuable only if not successful; actual status we can receive after executeWritable
refStatus.set(null);
}
for (PatchApplier applier : group) {
refStatus.set(ApplyPatchStatus.and(refStatus.get(), applier.executeWritable()));
if (refStatus.get() == ApplyPatchStatus.ABORT)
break;
}
}
}, VcsBundle.message("patch.apply.command"), null);
} finally {
VcsFileListenerContextHelper.getInstance(project).clearContext();
LocalHistory.getInstance().putSystemLabel(project, "After patch");
}
result = refStatus.get();
result = result == null ? ApplyPatchStatus.FAILURE : result;
trigger.processIt();
final Set<FilePath> directlyAffected = new HashSet<>();
final Set<VirtualFile> indirectlyAffected = new HashSet<>();
for (PatchApplier applier : group) {
directlyAffected.addAll(applier.getDirectlyAffected());
indirectlyAffected.addAll(applier.getIndirectlyAffected());
}
directlyAffected.addAll(trigger.getAffected());
final Consumer<Collection<FilePath>> mover = localChangeList == null ? null : createMover(project, localChangeList);
refreshPassedFilesAndMoveToChangelist(project, directlyAffected, indirectlyAffected, mover);
if (result == ApplyPatchStatus.FAILURE) {
suggestRollback(project, group, beforeLabel);
} else if (result == ApplyPatchStatus.ABORT) {
rollbackUnderProgress(project, project.getBaseDir(), beforeLabel);
}
showApplyStatus(project, result);
return result;
}
use of com.intellij.history.Label in project intellij-community by JetBrains.
the class ShowUpdatedDiffAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final DataContext dc = e.getDataContext();
if ((!isVisible(dc)) || (!isEnabled(dc)))
return;
final Project project = CommonDataKeys.PROJECT.getData(dc);
final Iterable<Pair<VirtualFilePointer, FileStatus>> iterable = e.getRequiredData(VcsDataKeys.UPDATE_VIEW_FILES_ITERABLE);
final Label before = (Label) e.getRequiredData(VcsDataKeys.LABEL_BEFORE);
final Label after = (Label) e.getRequiredData(VcsDataKeys.LABEL_AFTER);
final String selectedUrl = VcsDataKeys.UPDATE_VIEW_SELECTED_PATH.getData(dc);
MyDiffRequestChain requestChain = new MyDiffRequestChain(project, iterable, before, after, selectedUrl);
DiffManager.getInstance().showDiff(project, requestChain, DiffDialogHints.FRAME);
}
use of com.intellij.history.Label in project intellij-community by JetBrains.
the class GitPushOperation method execute.
@NotNull
public GitPushResult execute() {
PushUpdateSettings updateSettings = readPushUpdateSettings();
Label beforePushLabel = null;
Label afterPushLabel = null;
Map<GitRepository, String> preUpdatePositions = updateRootInfoAndRememberPositions();
Boolean rebaseOverMergeProblemDetected = null;
final Map<GitRepository, GitPushRepoResult> results = ContainerUtil.newHashMap();
Map<GitRepository, GitUpdateResult> updatedRoots = ContainerUtil.newHashMap();
try {
Collection<GitRepository> remainingRoots = myPushSpecs.keySet();
for (int pushAttempt = 0; pushAttempt < MAX_PUSH_ATTEMPTS && !remainingRoots.isEmpty(); pushAttempt++, remainingRoots = getRejectedAndNotPushed(results)) {
Map<GitRepository, GitPushRepoResult> resultMap = push(remainingRoots);
results.putAll(resultMap);
GroupedPushResult result = GroupedPushResult.group(resultMap);
// stop if error happens, or if push is rejected for a custom reason (not because a pull is needed)
if (!result.errors.isEmpty() || !result.customRejected.isEmpty()) {
break;
}
// propose to update if rejected
if (!result.rejected.isEmpty()) {
boolean shouldUpdate = true;
if (myForce || pushingToNotTrackedBranch(result.rejected)) {
shouldUpdate = false;
} else if (pushAttempt == 0 && !mySettings.autoUpdateIfPushRejected()) {
// the dialog will be shown => check for rebase-over-merge problem in advance to avoid showing several dialogs in a row
rebaseOverMergeProblemDetected = !findRootsWithMergeCommits(getRootsToUpdate(updateSettings, result.rejected.keySet())).isEmpty();
updateSettings = showDialogAndGetExitCode(result.rejected.keySet(), updateSettings, rebaseOverMergeProblemDetected.booleanValue());
if (updateSettings != null) {
savePushUpdateSettings(updateSettings, rebaseOverMergeProblemDetected.booleanValue());
} else {
shouldUpdate = false;
}
}
if (!shouldUpdate) {
break;
}
if (beforePushLabel == null) {
// put the label only before the very first update
beforePushLabel = LocalHistory.getInstance().putSystemLabel(myProject, "Before push");
}
Collection<GitRepository> rootsToUpdate = getRootsToUpdate(updateSettings, result.rejected.keySet());
GitUpdateResult updateResult = update(rootsToUpdate, updateSettings.getUpdateMethod(), rebaseOverMergeProblemDetected == null);
for (GitRepository repository : rootsToUpdate) {
// TODO update result in GitUpdateProcess is a single for several roots
updatedRoots.put(repository, updateResult);
}
if (!updateResult.isSuccess() || updateResult == GitUpdateResult.SUCCESS_WITH_RESOLVED_CONFLICTS || updateResult == GitUpdateResult.INCOMPLETE) {
break;
}
}
}
} finally {
if (beforePushLabel != null) {
afterPushLabel = LocalHistory.getInstance().putSystemLabel(myProject, "After push");
}
for (GitRepository repository : myPushSpecs.keySet()) {
repository.update();
}
}
return prepareCombinedResult(results, updatedRoots, preUpdatePositions, beforePushLabel, afterPushLabel);
}
use of com.intellij.history.Label in project intellij-community by JetBrains.
the class HistoryReverterToLabelTest method testFileCreationAsFirstAction.
public void testFileCreationAsFirstAction() throws Exception {
final Label testLabel = LocalHistory.getInstance().putSystemLabel(myProject, "testLabel");
createChildData(myRoot, "foo.txt");
revertToLabel(testLabel, myRoot);
assertNull(myRoot.findChild("foo.txt"));
}
Aggregations