Пример #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);
    }
  }
Пример #2
0
 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);
   }
 }
    private void addNestedRoots(final boolean clearState) {
      final List<VirtualFile> basicVfRoots =
          ObjectsConvertor.convert(
              myTopRoots,
              new Convertor<RootUrlInfo, VirtualFile>() {
                public VirtualFile convert(final RootUrlInfo real) {
                  return real.getVirtualFile();
                }
              });

      final ChangeListManager clManager = ChangeListManager.getInstance(myVcs.getProject());

      if (clearState) {
        // clear what was reported before (could be for currently-not-existing roots)
        myGate.get();
      }
      clManager.invokeAfterUpdate(
          new Runnable() {
            public void run() {
              final List<RootUrlInfo> nestedRoots = new ArrayList<RootUrlInfo>();

              final NestedCopiesData data = myGate.get();
              for (NestedCopiesBuilder.MyPointInfo info : data.getSet()) {
                if (NestedCopyType.external.equals(info.getType())
                    || NestedCopyType.switched.equals(info.getType())) {
                  final File infoFile = new File(info.getFile().getPath());
                  boolean copyFound = false;
                  for (RootUrlInfo topRoot : myTopRoots) {
                    if (topRoot.getIoFile().equals(infoFile)) {
                      topRoot.setType(info.getType());
                      copyFound = true;
                      break;
                    }
                  }
                  if (copyFound) {
                    continue;
                  }
                  try {
                    final SVNStatus svnStatus = SvnUtil.getStatus(myVcs, infoFile);
                    if (svnStatus.getURL() == null) continue;
                    info.setUrl(svnStatus.getURL());
                    info.setFormat(WorkingCopyFormat.getInstance(svnStatus.getWorkingCopyFormat()));
                  } catch (Exception e) {
                    continue;
                  }
                }
                for (RootUrlInfo topRoot : myTopRoots) {
                  if (VfsUtil.isAncestor(topRoot.getVirtualFile(), info.getFile(), true)) {
                    final SVNURL repoRoot = myRepositoryRoots.ask(info.getUrl());
                    if (repoRoot != null) {
                      final RootUrlInfo rootInfo =
                          new RootUrlInfo(
                              repoRoot,
                              info.getUrl(),
                              info.getFormat(),
                              info.getFile(),
                              topRoot.getRoot());
                      rootInfo.setType(info.getType());
                      nestedRoots.add(rootInfo);
                    }
                    break;
                  }
                }
              }
              // check those top roots which ARE externals, but that was not detected due to they
              // itself were the status request target
              // new SvnNestedTypeRechecker(myVcs.getProject(), myTopRoots).run();

              myTopRoots.addAll(nestedRoots);
              myApplier.apply(myVcs, myTopRoots, myLonelyRoots);
            }
          },
          InvokeAfterUpdateMode.SILENT_CALLBACK_POOLED,
          null,
          new Consumer<VcsDirtyScopeManager>() {
            public void consume(VcsDirtyScopeManager vcsDirtyScopeManager) {
              if (clearState) {
                vcsDirtyScopeManager.filesDirty(null, basicVfRoots);
              }
            }
          },
          null);
    }