예제 #1
0
  @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);
    }
  }
  @Test
  public void testSetActive() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile file = createFileInCommand("a.txt", "old content");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    changeListManager.ensureUpToDate(false);

    final LocalChangeList list = changeListManager.addChangeList("test", null);
    final LocalChangeList target = changeListManager.addChangeList("target", null);
    changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});

    myScheme.doTest(
        new Runnable() {
          @Override
          public void run() {
            changeListManager.setDefaultChangeList(target);
            assert changeListManager.getDefaultChangeList().getName().equals(target.getName());
          }
        });

    assert changeListManager.getDefaultChangeList().getName().equals(target.getName());

    changeListManager.ensureUpToDate(false);
    assert changeListManager.getDefaultChangeList().getName().equals(target.getName());
  }
  private void fillAddedFiles(
      Project project,
      SvnVcs vcs,
      List<VirtualFile> addedVFiles,
      Map<VirtualFile, File> copyFromMap,
      Set<VirtualFile> recursiveItems) {
    final Collection<AddedFileInfo> addedFileInfos = myAddedFiles.remove(project);
    final ChangeListManager changeListManager = ChangeListManager.getInstance(project);

    for (AddedFileInfo addedFileInfo : addedFileInfos) {
      final File ioFile = new File(getIOFile(addedFileInfo.myDir), addedFileInfo.myName);
      VirtualFile addedFile = addedFileInfo.myDir.findChild(addedFileInfo.myName);
      if (addedFile == null) {
        addedFile = myLfs.refreshAndFindFileByIoFile(ioFile);
      }
      if (addedFile != null) {
        final SVNStatus fileStatus = getFileStatus(vcs, ioFile);
        if (fileStatus == null || !SvnVcs.svnStatusIs(fileStatus, SVNStatusType.STATUS_IGNORED)) {
          boolean isIgnored = changeListManager.isIgnoredFile(addedFile);
          if (!isIgnored) {
            addedVFiles.add(addedFile);
            copyFromMap.put(addedFile, addedFileInfo.myCopyFrom);
            if (addedFileInfo.myRecursive) {
              recursiveItems.add(addedFile);
            }
          }
        }
      }
    }
  }
  @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;
    }
  }
  private boolean stash() {
    if (!mySyncResult.hasLocalRepository()) {
      LOG.error("unexpected null local repro in call to stash");
      return false;
    }

    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    if (changeListManager.isFreezedWithNotification("Can not stash changes now")) return false;

    final GitLineHandler handler =
        new GitLineHandler(myProject, mySourceRepository.getRoot(), GitCommand.STASH);
    handler.addParameters("save");
    handler.addParameters("--keep-index");
    String date =
        DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT).format(new Date());
    myStashMessage =
        "Cloud Debugger saved changes from branch " + myOriginalBranchName + " at " + date;
    handler.addParameters(myStashMessage);
    AccessToken token = DvcsUtil.workingTreeChangeStarted(myProject);
    try {
      GitHandlerUtil.doSynchronously(
          handler, GitBundle.getString("stashing.title"), handler.printableCommandLine());
    } finally {
      DvcsUtil.workingTreeChangeFinished(myProject, token);
    }
    return true;
  }
  @Nullable
  public LocalChangeList getSelectedList(Project project) {
    ChangeListManager manager = ChangeListManager.getInstance(project);
    if (myRbNew.isSelected()) {
      String newText = myNewListPanel.getChangeListName();
      if (manager.findChangeList(newText) != null) {
        Messages.showErrorDialog(
            project,
            VcsBundle.message("changes.newchangelist.warning.already.exists.text", newText),
            VcsBundle.message("changes.newchangelist.warning.already.exists.title"));
        return null;
      }
    }
    final boolean existingSelected = myRbExisting.isSelected();
    VcsConfiguration.getInstance(myProject).PRESELECT_EXISTING_CHANGELIST = existingSelected;

    if (existingSelected) {
      return (LocalChangeList) myExistingListsCombo.getSelectedItem();
    } else {
      LocalChangeList changeList =
          manager.addChangeList(
              myNewListPanel.getChangeListName(), myNewListPanel.getDescription());
      myNewListPanel.changelistCreatedOrChanged(changeList);
      if (myNewListPanel.getMakeActiveCheckBox().isSelected()) {
        manager.setDefaultChangeList(changeList);
      }
      VcsConfiguration.getInstance(project).MAKE_NEW_CHANGELIST_ACTIVE =
          myNewListPanel.getMakeActiveCheckBox().isSelected();

      return changeList;
    }
  }
예제 #7
0
 @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);
 }
 private static Collection<LocalChangeList> getChangeListsForRoot(
     ChangeListManager changeListManager, final FilePath dirPath) {
   Collection<Change> changes = changeListManager.getChangesIn(dirPath);
   Set<LocalChangeList> changeLists = new HashSet<LocalChangeList>();
   for (Change change : changes) {
     changeLists.add(changeListManager.getChangeList(change));
   }
   return changeLists;
 }
예제 #9
0
 @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);
 }
예제 #10
0
  public void actionPerformed(AnActionEvent e) {
    final Project project = e.getData(CommonDataKeys.PROJECT);
    if (project == null) return;
    final ShelvedChangeList[] changeLists =
        e.getData(ShelvedChangesViewManager.SHELVED_CHANGELIST_KEY);
    List<ShelvedChange> changes = e.getData(ShelvedChangesViewManager.SHELVED_CHANGE_KEY);
    List<ShelvedBinaryFile> binaryFiles =
        e.getData(ShelvedChangesViewManager.SHELVED_BINARY_FILE_KEY);
    if (changes != null && binaryFiles != null && changes.size() == 0 && binaryFiles.size() == 0) {
      changes = null;
      binaryFiles = null;
    }
    LOG.assertTrue(changeLists != null);

    final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
    final List<LocalChangeList> allChangeLists = changeListManager.getChangeListsCopy();
    String defaultName = changeLists[0].DESCRIPTION;
    LocalChangeList list = null;
    if (changeLists.length == 1) {
      final LocalChangeList sameNamedList = changeListManager.findChangeList(defaultName);
      if (sameNamedList != null) {
        list = sameNamedList;
      }
    }
    if (list == null) {
      list = changeListManager.getDefaultChangeList();
    }
    final ChangeListChooser chooser =
        new ChangeListChooser(
            project,
            allChangeLists,
            list,
            VcsBundle.message("unshelve.changelist.chooser.title"),
            defaultName);
    chooser.show();
    if (!chooser.isOK()) {
      return;
    }

    FileDocumentManager.getInstance().saveAllDocuments();

    final List<ShelvedBinaryFile> finalBinaryFiles = binaryFiles;
    final List<ShelvedChange> finalChanges = changes;
    ProgressManager.getInstance()
        .run(
            new Task.Backgroundable(
                project, "Unshelve changes", true, BackgroundFromStartOption.getInstance()) {
              @Override
              public void run(@NotNull ProgressIndicator indicator) {
                for (ShelvedChangeList changeList : changeLists) {
                  ShelveChangesManager.getInstance(project)
                      .unshelveChangeList(
                          changeList, finalChanges, finalBinaryFiles, chooser.getSelectedList());
                }
              }
            });
  }
  @Test
  public void testDoubleMove() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile file = createFileInCommand("a.txt", "old content");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    changeListManager.ensureUpToDate(false);

    final LocalChangeList list = changeListManager.addChangeList("test", null);
    final LocalChangeList target = changeListManager.addChangeList("target", null);
    final LocalChangeList target2 = changeListManager.addChangeList("target2", null);
    changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});

    myScheme.doTest(
        new Runnable() {
          @Override
          public void run() {
            changeListManager.moveChangesTo(
                target, new Change[] {changeListManager.getChange(file)});
            checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
            changeListManager.moveChangesTo(
                target2, new Change[] {changeListManager.getChange(file)});
            checkFilesAreInList(new VirtualFile[] {file}, target2.getName(), changeListManager);
          }
        });

    checkFilesAreInList(new VirtualFile[] {file}, target2.getName(), changeListManager);

    changeListManager.ensureUpToDate(false);
    checkFilesAreInList(new VirtualFile[] {file}, target2.getName(), changeListManager);
  }
  @Test
  public void testEditComment() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile file = createFileInCommand("a.txt", "old content");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    changeListManager.ensureUpToDate(false);

    final String listName = "test";
    final LocalChangeList list = changeListManager.addChangeList(listName, null);
    changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});

    final String finalText = "final text";

    myScheme.doTest(
        new Runnable() {
          public void run() {
            final String intermediate = "intermediate text";
            changeListManager.editComment(list.getName(), intermediate);
            assert changeListManager.findChangeList(listName) != null;
            LocalChangeList list = changeListManager.findChangeList(listName);
            assert intermediate.equals(list.getComment());

            changeListManager.editComment(list.getName(), finalText);
            list = changeListManager.findChangeList(listName);
            assert finalText.equals(list.getComment());
          }
        });

    LocalChangeList changedList = changeListManager.findChangeList(listName);
    assert finalText.equals(changedList.getComment());

    changeListManager.ensureUpToDate(false);
    changedList = changeListManager.findChangeList(listName);
    assert finalText.equals(changedList.getComment());
  }
  @Test
  public void testRemove() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile file = createFileInCommand("a.txt", "old content");
    final VirtualFile fileB = createFileInCommand("b.txt", "old content");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    changeListManager.ensureUpToDate(false);

    final LocalChangeList list = changeListManager.addChangeList("test", null);
    changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});

    myScheme.doTest(
        new Runnable() {
          @Override
          public void run() {
            changeListManager.removeChangeList(list.getName());
            assert changeListManager.findChangeList(list.getName()) == null;
            checkFilesAreInList(
                new VirtualFile[] {file, fileB}, myDefaulListName, changeListManager);
          }
        });

    assert changeListManager.findChangeList(list.getName()) == null;
    checkFilesAreInList(new VirtualFile[] {file, fileB}, myDefaulListName, changeListManager);

    changeListManager.ensureUpToDate(false);
    assert changeListManager.findChangeList(list.getName()) == null;
    checkFilesAreInList(new VirtualFile[] {file, fileB}, myDefaulListName, changeListManager);
  }
  @NotNull
  public AnalysisScope getScope(
      @NotNull AnalysisUIOptions uiOptions,
      @NotNull AnalysisScope defaultScope,
      @NotNull Project project,
      Module module) {
    AnalysisScope scope;
    if (isProjectScopeSelected()) {
      scope = new AnalysisScope(project);
      uiOptions.SCOPE_TYPE = AnalysisScope.PROJECT;
    } else {
      final SearchScope customScope = getCustomScope();
      if (customScope != null) {
        scope = new AnalysisScope(customScope, project);
        uiOptions.SCOPE_TYPE = AnalysisScope.CUSTOM;
        uiOptions.CUSTOM_SCOPE_NAME = customScope.getDisplayName();
      } else if (isModuleScopeSelected()) {
        scope = new AnalysisScope(module);
        uiOptions.SCOPE_TYPE = AnalysisScope.MODULE;
      } else if (isUncommitedFilesSelected()) {
        final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
        List<VirtualFile> files;
        if (myChangeLists.getSelectedItem() == ALL) {
          files = changeListManager.getAffectedFiles();
        } else {
          files = new ArrayList<VirtualFile>();
          for (ChangeList list : changeListManager.getChangeListsCopy()) {
            if (!Comparing.strEqual(list.getName(), (String) myChangeLists.getSelectedItem()))
              continue;
            final Collection<Change> changes = list.getChanges();
            for (Change change : changes) {
              final ContentRevision afterRevision = change.getAfterRevision();
              if (afterRevision != null) {
                final VirtualFile vFile = afterRevision.getFile().getVirtualFile();
                if (vFile != null) {
                  files.add(vFile);
                }
              }
            }
          }
        }
        scope = new AnalysisScope(project, new HashSet<VirtualFile>(files));
        uiOptions.SCOPE_TYPE = AnalysisScope.UNCOMMITTED_FILES;
      } else {
        scope = defaultScope;
        uiOptions.SCOPE_TYPE = defaultScope.getScopeType(); // just not project scope
      }
    }
    uiOptions.ANALYZE_TEST_SOURCES = isInspectTestSources();
    scope.setIncludeTestSource(isInspectTestSources());
    scope.setScope(getCustomScope());

    FindSettings.getInstance().setDefaultScopeName(scope.getDisplayName());
    return scope;
  }
 /**
  * Get name of the file in the last commit. If file was renamed, returns the previous name.
  *
  * @param project the context project
  * @param path the path to check
  * @return the name of file in the last commit or argument
  */
 public static FilePath getLastCommitName(final Project project, FilePath path) {
   if (project.isDefault()) return path;
   final ChangeListManager changeManager = ChangeListManager.getInstance(project);
   final Change change = changeManager.getChange(path);
   if (change != null && change.getType() == Change.Type.MOVED) {
     // GitContentRevision r = (GitContentRevision)change.getBeforeRevision();
     assert change.getBeforeRevision() != null : "Move change always have beforeRevision";
     path = change.getBeforeRevision().getFile();
   }
   return path;
 }
예제 #16
0
  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();
  }
 @Test
 public void testDeletion() throws Exception {
   final File f = new File(myClientRoot, "f.txt");
   f.createNewFile();
   final VirtualFile vf = myLFS.refreshAndFindFileByIoFile(f);
   myChangeListManager.ensureUpToDate(false);
   ((ChangeListManagerImpl) myChangeListManager).getUnversionedFiles().contains(vf);
   FileUtil.delete(f);
   myWorkingCopyDir.refresh(false, true);
   myChangeListManager.ensureUpToDate(false);
   ((ChangeListManagerImpl) myChangeListManager).getUnversionedFiles().isEmpty();
 }
예제 #18
0
    @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);
  }
  @Test
  public void testAddListBySvn() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile file = createFileInCommand("a.txt", "old content");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);

    final String targetName = "target";
    // not parralel, just test of correct detection
    runSvn("changelist", targetName, file.getPath());

    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    changeListManager.ensureUpToDate(false);
    checkFilesAreInList(new VirtualFile[] {file}, targetName, changeListManager);
  }
 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);
 }
 @NotNull
 private Map<VirtualFile, GitUpdater> tryFastForwardMergeForRebaseUpdaters(
     @NotNull Map<VirtualFile, GitUpdater> updaters) {
   Map<VirtualFile, GitUpdater> modifiedUpdaters = new HashMap<VirtualFile, GitUpdater>();
   Map<VirtualFile, Collection<Change>> changesUnderRoots =
       new LocalChangesUnderRoots(
               ChangeListManager.getInstance(myProject),
               ProjectLevelVcsManager.getInstance(myProject))
           .getChangesUnderRoots(updaters.keySet());
   for (Map.Entry<VirtualFile, GitUpdater> updaterEntry : updaters.entrySet()) {
     VirtualFile root = updaterEntry.getKey();
     GitUpdater updater = updaterEntry.getValue();
     Collection<Change> changes = changesUnderRoots.get(root);
     if (updater instanceof GitRebaseUpdater && changes != null && !changes.isEmpty()) {
       // check only if there are local changes, otherwise stash won't happen anyway and there
       // would be no optimization
       GitRebaseUpdater rebaseUpdater = (GitRebaseUpdater) updater;
       if (rebaseUpdater.fastForwardMerge()) {
         continue;
       }
     }
     modifiedUpdaters.put(root, updater);
   }
   return modifiedUpdaters;
 }
 @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();
 }
  /** call in setUp */
  public DuringChangeListManagerUpdateTestScheme(final Project project, final String tmpDirPath) {
    final MockAbstractVcs vcs = new MockAbstractVcs(project);
    myChangeProvider = new MockDelayingChangeProvider();
    vcs.setChangeProvider(myChangeProvider);

    final File mockVcsRoot = new File(tmpDirPath, "mock");
    mockVcsRoot.mkdir();
    final VirtualFile vRoot = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(mockVcsRoot);

    final ProjectLevelVcsManagerImpl projectLevelVcsManager =
        (ProjectLevelVcsManagerImpl) ProjectLevelVcsManager.getInstance(project);
    projectLevelVcsManager.registerVcs(vcs);
    // projectLevelVcsManager.setDirectoryMapping(mockVcsRoot.getAbsolutePath(), vcs.getName());
    final ArrayList<VcsDirectoryMapping> list =
        new ArrayList<VcsDirectoryMapping>(projectLevelVcsManager.getDirectoryMappings());
    list.add(new VcsDirectoryMapping(vRoot.getPath(), vcs.getName()));
    projectLevelVcsManager.setDirectoryMappings(list);

    AbstractVcs vcsFound = projectLevelVcsManager.findVcsByName(vcs.getName());
    final VirtualFile[] roots = projectLevelVcsManager.getRootsUnderVcs(vcsFound);
    assert roots.length == 1
        : Arrays.asList(roots)
            + "; "
            + vcs.getName()
            + "; "
            + Arrays.toString(AllVcses.getInstance(project).getAll());

    myDirtyScopeManager = VcsDirtyScopeManager.getInstance(project);
    myClManager = ChangeListManager.getInstance(project);
  }
예제 #25
0
  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);
  }
 public ChangesBrowserChangeListNode(
     Project project, ChangeList userObject, final ChangeListRemoteState changeListRemoteState) {
   super(userObject);
   myChangeListRemoteState = changeListRemoteState;
   myClManager = (ChangeListManagerEx) ChangeListManager.getInstance(project);
   myDecorators = ComponentsPackage.getComponents(project, ChangeListDecorator.class);
 }
예제 #27
0
 /**
  * Given the list of paths converts them to the list of {@link Change Changes} found in the {@link
  * ChangeListManager}, i.e. this works only for local changes. </br> Paths can be absolute or
  * relative to the repository. If a path is not found in the local changes, it is ignored, but the
  * fact is logged.
  */
 @NotNull
 public static List<Change> findLocalChangesForPaths(
     @NotNull Project project,
     @NotNull VirtualFile root,
     @NotNull Collection<String> affectedPaths,
     boolean relativePaths) {
   ChangeListManagerEx changeListManager =
       (ChangeListManagerEx) ChangeListManager.getInstance(project);
   List<Change> affectedChanges = new ArrayList<Change>();
   for (String path : affectedPaths) {
     String absolutePath = relativePaths ? toAbsolute(root, path) : path;
     VirtualFile file = findRefreshFileOrLog(absolutePath);
     if (file != null) {
       Change change = changeListManager.getChange(file);
       if (change != null) {
         affectedChanges.add(change);
       } else {
         String message = "Change is not found for " + file.getPath();
         if (changeListManager.isInUpdate()) {
           message += " because ChangeListManager is being updated.";
         }
         LOG.warn(message);
       }
     }
   }
   return affectedChanges;
 }
예제 #28
0
  @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);
  }
 private VcsRootProblemNotifier(@NotNull Project project) {
   myProject = project;
   mySettings = VcsConfiguration.getInstance(myProject);
   myChangeListManager = ChangeListManager.getInstance(project);
   myProjectFileIndex = ProjectFileIndex.SERVICE.getInstance(myProject);
   myVcsManager = ProjectLevelVcsManager.getInstance(project);
   myReportedUnregisteredRoots = new HashSet<>(mySettings.IGNORED_UNREGISTERED_ROOTS);
 }