@CalledInAwt public static void refreshPassedFilesAndMoveToChangelist( @NotNull final Project project, final Collection<FilePath> directlyAffected, final Collection<VirtualFile> indirectlyAffected, final Consumer<Collection<FilePath>> targetChangelistMover) { final LocalFileSystem lfs = LocalFileSystem.getInstance(); for (FilePath filePath : directlyAffected) { lfs.refreshAndFindFileByIoFile(filePath.getIOFile()); } if (project.isDisposed()) return; final ChangeListManager changeListManager = ChangeListManager.getInstance(project); if (!directlyAffected.isEmpty() && targetChangelistMover != null) { changeListManager.invokeAfterUpdate( new Runnable() { @Override public void run() { targetChangelistMover.consume(directlyAffected); } }, InvokeAfterUpdateMode.SYNCHRONOUS_CANCELLABLE, VcsBundle.message("change.lists.manager.move.changes.to.list"), new Consumer<VcsDirtyScopeManager>() { @Override public void consume(final VcsDirtyScopeManager vcsDirtyScopeManager) { markDirty(vcsDirtyScopeManager, directlyAffected, indirectlyAffected); } }, null); } else { markDirty(VcsDirtyScopeManager.getInstance(project), directlyAffected, indirectlyAffected); } }
@Nullable private static Consumer<Collection<FilePath>> createMover( final Project project, final LocalChangeList targetChangeList) { final ChangeListManager clm = ChangeListManager.getInstance(project); if (targetChangeList == null || clm.getDefaultListName().equals(targetChangeList.getName())) return null; return new FilesMover(clm, targetChangeList); }
@Override public boolean fileIsUnderVcs(FilePath path) { final ChangeListManager clManager = ChangeListManager.getInstance(myProject); final VirtualFile file = path.getVirtualFile(); if (file == null) { return false; } return !SvnStatusUtil.isIgnoredInAnySense(clManager, file) && !clManager.isUnversioned(file); }
public void doRollback( final Collection<Change> changes, final boolean deleteLocallyAddedFiles, @Nullable final Runnable afterVcsRefreshInAwt, @Nullable final String localHistoryActionName) { final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); final Runnable notifier = changeListManager.prepareForChangeDeletion(changes); final Runnable afterRefresh = new Runnable() { public void run() { changeListManager.invokeAfterUpdate( new Runnable() { public void run() { notifier.run(); if (afterVcsRefreshInAwt != null) { afterVcsRefreshInAwt.run(); } } }, InvokeAfterUpdateMode.SILENT, "Refresh change lists after update", ModalityState.current()); } }; final Runnable rollbackAction = new MyRollbackRunnable( changes, deleteLocallyAddedFiles, afterRefresh, localHistoryActionName); if (ApplicationManager.getApplication().isDispatchThread()) { ProgressManager.getInstance() .run( new Task.Backgroundable( myProject, VcsBundle.message("changes.action.rollback.text"), true, new PerformInBackgroundOption() { public boolean shouldStartInBackground() { return VcsConfiguration.getInstance(myProject).PERFORM_ROLLBACK_IN_BACKGROUND; } public void processSentToBackground() { VcsConfiguration.getInstance(myProject).PERFORM_ROLLBACK_IN_BACKGROUND = true; } }) { public void run(@NotNull ProgressIndicator indicator) { rollbackAction.run(); } }); } else { rollbackAction.run(); } ((ChangeListManagerImpl) changeListManager).showLocalChangesInvalidated(); }
@Override public void consume(Collection<FilePath> directlyAffected) { List<Change> changes = new ArrayList<>(); for (FilePath file : directlyAffected) { final Change change = myChangeListManager.getChange(file); if (change != null) { changes.add(change); } } myChangeListManager.moveChangesTo( myTargetChangeList, changes.toArray(new Change[changes.size()])); }
@Override public void run(ContinuationContext context) { final ChangeListManager clManager = ChangeListManager.getInstance(myVcs.getProject()); final LocalChangeList changeList = clManager.getChangeList(myChange); final ApplyPatchDifferentiatedDialog dialog = new ApplyPatchDifferentiatedDialog( myVcs.getProject(), new TreeConflictApplyTheirsPatchExecutor(myVcs, context, myBaseForPatch), Collections.<ApplyPatchExecutor>singletonList( new ApplyPatchSaveToFileExecutor(myVcs.getProject(), myBaseForPatch)), ApplyPatchMode.APPLY_PATCH_IN_MEMORY, myTextPatches, changeList); context.suspend(); dialog.show(); }
@Override public void deactivate() { FrameStateManager.getInstance().removeListener(myFrameStateListener); final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject); if (myVcsListener != null) { vcsManager.removeVcsListener(myVcsListener); } if (myEntriesFileListener != null) { VirtualFileManager.getInstance().removeVirtualFileListener(myEntriesFileListener); } SvnApplicationSettings.getInstance().svnDeactivated(); if (myCommittedChangesProvider != null) { myCommittedChangesProvider.deactivate(); } if (myChangeListListener != null && !myProject.isDefault()) { ChangeListManager.getInstance(myProject).removeChangeListListener(myChangeListListener); } vcsManager.removeVcsListener(myRootsToWorkingCopies); myRootsToWorkingCopies.clear(); myAuthNotifier.stop(); myAuthNotifier.clear(); mySvnBranchPointsCalculator.deactivate(); mySvnBranchPointsCalculator = null; myWorkingCopiesContent.deactivate(); myLoadedBranchesStorage.deactivate(); myPool.dispose(); myPool = null; }
public SvnVcs( final Project project, MessageBus bus, SvnConfiguration svnConfiguration, final SvnLoadedBrachesStorage storage) { super(project, VCS_NAME); myLoadedBranchesStorage = storage; LOG.debug("ct"); myRootsToWorkingCopies = new RootsToWorkingCopies(this); myConfiguration = svnConfiguration; myAuthNotifier = new SvnAuthenticationNotifier(this); dumpFileStatus(FileStatus.ADDED); dumpFileStatus(FileStatus.DELETED); dumpFileStatus(FileStatus.MERGE); dumpFileStatus(FileStatus.MODIFIED); dumpFileStatus(FileStatus.NOT_CHANGED); dumpFileStatus(FileStatus.UNKNOWN); dumpFileStatus(SvnFileStatus.REPLACED); dumpFileStatus(SvnFileStatus.EXTERNAL); dumpFileStatus(SvnFileStatus.OBSTRUCTED); final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project); myAddConfirmation = vcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.ADD, this); myDeleteConfirmation = vcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.REMOVE, this); myCheckoutOptions = vcsManager.getStandardOption(VcsConfiguration.StandardOption.CHECKOUT, this); if (myProject.isDefault()) { myChangeListListener = null; myEntriesFileListener = null; } else { myEntriesFileListener = new SvnEntriesFileListener(project); upgradeIfNeeded(bus); myChangeListListener = new SvnChangelistListener(myProject, this); myVcsListener = new VcsListener() { @Override public void directoryMappingChanged() { invokeRefreshSvnRoots(true); } }; } myFrameStateListener = project.isDefault() ? null : new MyFrameStateListener( ChangeListManager.getInstance(project), VcsDirtyScopeManager.getInstance(project)); myWorkingCopiesContent = new WorkingCopiesContent(this); // remove used some time before old notification group ids correctNotificationIds(); myChecker = new SvnExecutableChecker(myProject); }
@Nullable private static Change[] loadFakeRevisions(final Project project, final Change[] changes) { List<Change> matchingChanges = new ArrayList<Change>(); for (Change change : changes) { matchingChanges.addAll( ChangeListManager.getInstance(project).getChangesIn(ChangesUtil.getFilePath(change))); } return matchingChanges.toArray(new Change[matchingChanges.size()]); }
private void createChangelist(final ContinuationPause context) { final ChangeListManager listManager = ChangeListManager.getInstance(myProject); String name = myTitle; int i = 1; boolean updateDefaultList = false; while (true) { final LocalChangeList changeList = listManager.findChangeList(name); if (changeList == null) { final LocalChangeList newList = listManager.addChangeList(name, null); listManager.setDefaultChangeList(newList); updateDefaultList = true; break; } if (changeList.getChanges().isEmpty()) { if (!changeList.isDefault()) { listManager.setDefaultChangeList(changeList); updateDefaultList = true; } break; } name = myTitle + " (" + i + ")"; ++i; } if (updateDefaultList) { context.suspend(); listManager.invokeAfterUpdate( new Runnable() { public void run() { context.ping(); } }, InvokeAfterUpdateMode.BACKGROUND_NOT_CANCELLABLE_NOT_AWT, "", ModalityState.NON_MODAL); } }
@Override public void run(ContinuationContext context) { final String message; final Intersection intersection; final ChangeListManager listManager = ChangeListManager.getInstance(myProject); final List<LocalChangeList> localChangeLists = listManager.getChangeListsCopy(); if (myMergeAll) { intersection = getMergeAllIntersection(localChangeLists); message = "There are local changes that can potentially intersect with merge changes.\nDo you want to continue?"; } else { intersection = checkIntersection(myLists, localChangeLists); message = "There are local changes that will intersect with merge changes.\nDo you want to continue?"; } if (intersection == null || intersection.getChangesSubset().isEmpty()) return; final LocalChangesAction action; if (!myMergeAll) { final LocalChangesAction[] possibleResults = { LocalChangesAction.shelve, LocalChangesAction.inspect, LocalChangesAction.continueMerge, LocalChangesAction.cancel }; final int result = Messages.showDialog( message, myTitle, new String[] { "Shelve local changes", "Inspect changes", "Continue merge", "Cancel" }, 0, Messages.getQuestionIcon()); action = possibleResults[result]; } else { final LocalChangesAction[] possibleResults = { LocalChangesAction.shelve, LocalChangesAction.continueMerge, LocalChangesAction.cancel }; final int result = Messages.showDialog( message, myTitle, new String[] {"Shelve local changes", "Continue merge", "Cancel"}, 0, Messages.getQuestionIcon()); action = possibleResults[result]; } switch (action) { // shelve case shelve: context.next(new ShelveLocalChanges(intersection)); return; // cancel case cancel: context.cancelEverything(); return; // continue case continueMerge: return; // inspect case inspect: final Collection<Change> changes = (Collection<Change>) intersection.getChangesSubset().values(); final List<FilePath> paths = ChangesUtil.getPaths(changes); Collections.sort(paths, FilePathByPathComparator.getInstance()); // todo rework message IntersectingLocalChangesPanel.showInVersionControlToolWindow( myProject, myTitle + ", local changes intersection", paths, "The following file(s) have local changes that will intersect with merge changes:"); context.cancelEverything(); return; default: } }
public void actionPerformed(final AnActionEvent e) { final Project project = e.getData(CommonDataKeys.PROJECT); if (project == null) return; if (ChangeListManager.getInstance(project).isFreezedWithNotification(null)) return; final Change[] changes = e.getData(VcsDataKeys.CHANGES); if (changes == null) return; final boolean needsConvertion = checkIfThereAreFakeRevisions(project, changes); final List<Change> changesInList = e.getData(VcsDataKeys.CHANGES_IN_LIST_KEY); // this trick is essential since we are under some conditions to refresh changes; // but we can only rely on callback after refresh final Runnable performer = new Runnable() { public void run() { Change[] convertedChanges; if (needsConvertion) { convertedChanges = loadFakeRevisions(project, changes); } else { convertedChanges = changes; } if (convertedChanges == null || convertedChanges.length == 0) { return; } List<Change> changesInListCopy = changesInList; int index = 0; if (convertedChanges.length == 1) { final Change selectedChange = convertedChanges[0]; ChangeList changeList = ((ChangeListManagerImpl) ChangeListManager.getInstance(project)) .getIdentityChangeList(selectedChange); if (changeList != null) { if (changesInListCopy == null) { changesInListCopy = new ArrayList<Change>(changeList.getChanges()); Collections.sort( changesInListCopy, new Comparator<Change>() { public int compare(final Change o1, final Change o2) { return ChangesUtil.getFilePath(o1) .getName() .compareToIgnoreCase(ChangesUtil.getFilePath(o2).getName()); } }); } convertedChanges = changesInListCopy.toArray(new Change[changesInListCopy.size()]); for (int i = 0; i < convertedChanges.length; i++) { if (convertedChanges[i] == selectedChange) { index = i; break; } } } } showDiffForChange(convertedChanges, index, project); } }; if (needsConvertion) { ChangeListManager.getInstance(project) .invokeAfterUpdate( performer, InvokeAfterUpdateMode.BACKGROUND_CANCELLABLE, ourText, ModalityState.current()); } else { performer.run(); } }
@Override public void activate() { createPool(); final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject); if (!myProject.isDefault()) { ChangeListManager.getInstance(myProject).addChangeListListener(myChangeListListener); vcsManager.addVcsListener(myVcsListener); } SvnApplicationSettings.getInstance().svnActivated(); if (myEntriesFileListener != null) { VirtualFileManager.getInstance().addVirtualFileListener(myEntriesFileListener); } // this will initialize its inner listener for committed changes upload LoadedRevisionsCache.getInstance(myProject); FrameStateManager.getInstance().addListener(myFrameStateListener); myAuthNotifier.init(); mySvnBranchPointsCalculator = new SvnBranchPointsCalculator(myProject); mySvnBranchPointsCalculator.activate(); if (SystemInfo.isWindows) { if (!SVNJNAUtil.isJNAPresent()) { Notifications.Bus.notify( new Notification( getDisplayName(), "Subversion plugin: no JNA", "A problem with JNA initialization for svnkit library. Encryption is not available.", NotificationType.WARNING), NotificationDisplayType.BALLOON, myProject); } else if (!SVNJNAUtil.isWinCryptEnabled()) { Notifications.Bus.notify( new Notification( getDisplayName(), "Subversion plugin: no encryption", "A problem with encryption module (Crypt32.dll) initialization for svnkit library. Encryption is not available.", NotificationType.WARNING), NotificationDisplayType.BALLOON, myProject); } } final SvnConfiguration.UseAcceleration accelerationType = SvnConfiguration.getInstance(myProject).myUseAcceleration; if (SvnConfiguration.UseAcceleration.javaHL.equals(accelerationType)) { CheckJavaHL.runtimeCheck(myProject); } else if (SvnConfiguration.UseAcceleration.commandLine.equals(accelerationType) && !ApplicationManager.getApplication().isHeadlessEnvironment()) { myChecker.checkExecutableAndNotifyIfNeeded(); } // do one time after project loaded StartupManager.getInstance(myProject) .runWhenProjectIsInitialized( new DumbAwareRunnable() { @Override public void run() { postStartup(); // for IDEA, it takes 2 minutes - and anyway this can be done in background, no // sense... // once it could be mistaken about copies for 2 minutes on start... /*if (! myMapping.getAllWcInfos().isEmpty()) { invokeRefreshSvnRoots(); return; } ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() { public void run() { myCopiesRefreshManager.getCopiesRefresh().ensureInit(); } }, SvnBundle.message("refreshing.working.copies.roots.progress.text"), true, myProject);*/ } }); vcsManager.addVcsListener(myRootsToWorkingCopies); myLoadedBranchesStorage.activate(); }