@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); } }
@Override public void rebuildList() { if (myInRebuildList) return; try { myInRebuildList = true; if (myChangesToDisplay == null) { // changes set not fixed === local changes final ChangeListManager manager = ChangeListManager.getInstance(myProject); myChangeListsMap = new HashMap<Change, LocalChangeList>(); final List<LocalChangeList> lists = manager.getChangeListsCopy(); Collection<Change> allChanges = new ArrayList<Change>(); for (LocalChangeList list : lists) { final Collection<Change> changes = list.getChanges(); allChanges.addAll(changes); for (Change change : changes) { myChangeListsMap.put(change, list); } } myAllChanges = allChanges; // refresh selected list also updateListsInChooser(); } super.rebuildList(); if (myRebuildListListener != null) { myRebuildListListener.run(); } } finally { myInRebuildList = false; } }
@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); }
@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()])); }
public void projectOpened() { TaskProjectConfiguration projectConfiguration = getProjectConfiguration(); servers: for (TaskProjectConfiguration.SharedServer server : projectConfiguration.servers) { if (server.type == null || server.url == null) { continue; } for (TaskRepositoryType<?> repositoryType : TaskRepositoryType.getRepositoryTypes()) { if (repositoryType.getName().equals(server.type)) { for (TaskRepository repository : myRepositories) { if (!repositoryType.equals(repository.getRepositoryType())) { continue; } if (server.url.equals(repository.getUrl())) { continue servers; } } TaskRepository repository = repositoryType.createRepository(); repository.setUrl(server.url); myRepositories.add(repository); } } } myContextManager.pack(200, 50); // make sure the task is associated with default changelist LocalTask defaultTask = findTask(LocalTaskImpl.DEFAULT_TASK_ID); LocalChangeList defaultList = myChangeListManager.findChangeList(LocalChangeList.DEFAULT_NAME); if (defaultList != null && defaultTask != null) { ChangeListInfo listInfo = new ChangeListInfo(defaultList); if (!defaultTask.getChangeLists().contains(listInfo)) { defaultTask.addChangelist(listInfo); } } // remove already not existing changelists from tasks changelists for (LocalTask localTask : getLocalTasks()) { for (Iterator<ChangeListInfo> iterator = localTask.getChangeLists().iterator(); iterator.hasNext(); ) { final ChangeListInfo changeListInfo = iterator.next(); if (myChangeListManager.getChangeList(changeListInfo.id) == null) { iterator.remove(); } } } myChangeListManager.addChangeListListener(myChangeListListener); }
private void createChangeList(LocalTask task, String name, @Nullable String comment) { LocalChangeList changeList = myChangeListManager.findChangeList(name); if (changeList == null) { changeList = myChangeListManager.addChangeList(name, comment); } else { final LocalTask associatedTask = getAssociatedTask(changeList); if (associatedTask != null) { associatedTask.removeChangelist(new ChangeListInfo(changeList)); } changeList.setComment(comment); } task.addChangelist(new ChangeListInfo(changeList)); myChangeListManager.setDefaultChangeList(changeList); }
@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(); }
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); }
@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; }
// todo terrible constructor public MultipleChangeListBrowser( Project project, List<? extends ChangeList> changeLists, List<Change> changes, Disposable parentDisposable, ChangeList initialListSelection, boolean capableOfExcludingChanges, boolean highlightProblems, Runnable rebuildListListener, @Nullable Runnable inclusionListener, AnAction... additionalActions) { super( project, changeLists, changes, initialListSelection, capableOfExcludingChanges, highlightProblems, inclusionListener, MyUseCase.LOCAL_CHANGES, null); myParentDisposable = parentDisposable; myRebuildListListener = rebuildListListener; myChangeListChooser = new ChangeListChooser(changeLists); myHeaderPanel.add(myChangeListChooser, BorderLayout.EAST); myShowingAllChangeLists = Comparing.haveEqualElements( changeLists, ChangeListManager.getInstance(project).getChangeLists()); ChangeListManager.getInstance(myProject).addChangeListListener(myChangeListListener); myExtender = new Extender(project, this, additionalActions); ActionManager actionManager = ActionManager.getInstance(); final AnAction moveAction = actionManager.getAction(IdeActions.MOVE_TO_ANOTHER_CHANGE_LIST); actionManager.addAnActionListener( new AnActionListener.Adapter() { @Override public void afterActionPerformed( AnAction action, DataContext dataContext, AnActionEvent event) { if (moveAction.equals(action)) { rebuildList(); } } }, myParentDisposable); }
@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 LocalTask restoreVcsContext(LocalTask task) { if (!isVcsEnabled()) return task; List<ChangeListInfo> changeLists = task.getChangeLists(); if (!changeLists.isEmpty()) { ChangeListInfo info = changeLists.get(0); LocalChangeList changeList = myChangeListManager.getChangeList(info.id); if (changeList == null) { changeList = myChangeListManager.addChangeList(info.name, info.comment); info.id = changeList.getId(); } myChangeListManager.setDefaultChangeList(changeList); } List<BranchInfo> branches = task.getBranches(false); VcsTaskHandler.TaskInfo info = fromBranches(branches); VcsTaskHandler[] handlers = VcsTaskHandler.getAllHandlers(myProject); for (VcsTaskHandler handler : handlers) { handler.switchToTask(info); } return task; }
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 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(); }
@Override public void dispose() { ChangeListManager.getInstance(myProject).removeChangeListListener(myChangeListListener); }
public void disposeComponent() { if (myCacheRefreshTimer != null) { myCacheRefreshTimer.stop(); } myChangeListManager.removeChangeListListener(myChangeListListener); }
@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()]); index = Math.max(0, ContainerUtil.indexOfIdentity(changesInListCopy, selectedChange)); } } showDiffForChange(convertedChanges, index, project); } }; if (needsConvertion) { ChangeListManager.getInstance(project) .invokeAfterUpdate( performer, InvokeAfterUpdateMode.BACKGROUND_CANCELLABLE, ourText, ModalityState.current()); } else { performer.run(); } }