コード例 #1
0
 public void setAutoDirectoryMapping(String path, String activeVcsName) {
   final List<VirtualFile> defaultRoots = myMappings.getDefaultRoots();
   if (defaultRoots.size() == 1 && StringUtil.isEmpty(myMappings.haveDefaultMapping())) {
     myMappings.removeDirectoryMapping(new VcsDirectoryMapping("", ""));
   }
   myMappings.setMapping(path, activeVcsName);
 }
コード例 #2
0
 public void unregisterVcs(@NotNull AbstractVcs vcs) {
   if (!ApplicationManager.getApplication().isUnitTestMode()
       && myMappings.haveActiveVcs(vcs.getName())) {
     // unlikely
     LOG.warn(
         "Active vcs '" + vcs.getName() + "' is being unregistered. Remove from mappings first.");
   }
   myMappings.beingUnregistered(vcs.getName());
   AllVcses.getInstance(myProject).unregisterManually(vcs);
 }
コード例 #3
0
 @Override
 public void setDirectoryMapping(final String path, final String activeVcsName) {
   if (myMappingsLoaded)
     return; // ignore per-module VCS settings if the mapping table was loaded from .ipr
   myHaveLegacyVcsConfiguration = true;
   myMappings.setMapping(FileUtil.toSystemIndependentName(path), activeVcsName);
 }
コード例 #4
0
 @Override
 public VirtualFile[] getAllVersionedRoots() {
   List<VirtualFile> vFiles = new ArrayList<VirtualFile>();
   final AbstractVcs[] vcses = myMappings.getActiveVcses();
   for (AbstractVcs vcs : vcses) {
     Collections.addAll(vFiles, getRootsUnderVcs(vcs));
   }
   return VfsUtilCore.toVirtualFileArray(vFiles);
 }
コード例 #5
0
 @Override
 @Nullable
 public AbstractVcs getVcsFor(@NotNull VirtualFile file) {
   final String vcsName = myMappings.getVcsFor(file);
   if (vcsName == null || vcsName.isEmpty()) {
     return null;
   }
   return AllVcses.getInstance(myProject).getByName(vcsName);
 }
コード例 #6
0
 @Override
 @Nullable
 public VcsDirectoryMapping getDirectoryMappingFor(final FilePath path) {
   VirtualFile vFile = ChangesUtil.findValidParentAccurately(path);
   if (vFile != null) {
     return myMappings.getMappingFor(vFile);
   }
   return null;
 }
コード例 #7
0
  public void readDirectoryMappings(final Element element) {
    myMappings.clear();

    final List<VcsDirectoryMapping> mappingsList = new ArrayList<VcsDirectoryMapping>();
    boolean haveNonEmptyMappings = false;
    for (Element child : element.getChildren(ELEMENT_MAPPING)) {
      final String vcs = child.getAttributeValue(ATTRIBUTE_VCS);
      if (vcs != null && !vcs.isEmpty()) {
        haveNonEmptyMappings = true;
      }
      VcsDirectoryMapping mapping =
          new VcsDirectoryMapping(child.getAttributeValue(ATTRIBUTE_DIRECTORY), vcs);
      mappingsList.add(mapping);

      Element rootSettingsElement = child.getChild(ELEMENT_ROOT_SETTINGS);
      if (rootSettingsElement != null) {
        String className = rootSettingsElement.getAttributeValue(ATTRIBUTE_CLASS);
        AbstractVcs vcsInstance = findVcsByName(mapping.getVcs());
        if (vcsInstance != null && className != null) {
          final VcsRootSettings rootSettings = vcsInstance.createEmptyVcsRootSettings();
          if (rootSettings != null) {
            try {
              rootSettings.readExternal(rootSettingsElement);
              mapping.setRootSettings(rootSettings);
            } catch (InvalidDataException e) {
              LOG.error(
                  "Failed to load VCS root settings class "
                      + className
                      + " for VCS "
                      + vcsInstance.getClass().getName(),
                  e);
            }
          }
        }
      }
    }
    boolean defaultProject =
        Boolean.TRUE.toString().equals(element.getAttributeValue(ATTRIBUTE_DEFAULT_PROJECT));
    // run autodetection if there's no VCS in default project and
    if (haveNonEmptyMappings || !defaultProject) {
      myMappingsLoaded = true;
    }
    myMappings.setDirectoryMappings(mappingsList);
  }
コード例 #8
0
 @Override
 @Nullable
 public VirtualFile getVcsRootFor(@Nullable final VirtualFile file) {
   final VcsDirectoryMapping mapping = myMappings.getMappingFor(file);
   if (mapping == null) {
     return null;
   }
   final String directory = mapping.getDirectory();
   if (directory.isEmpty()) {
     return myDefaultVcsRootPolicy.getVcsRootFor(file);
   }
   return LocalFileSystem.getInstance().findFileByPath(directory);
 }
コード例 #9
0
  @Override
  public void disposeComponent() {
    releaseEditor();
    myMappings.disposeMe();
    myConnect.disconnect();
    Disposer.dispose(myAnnotationLocalChangesListener);
    myContentManager = null;

    ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
    if (toolWindowManager != null && toolWindowManager.getToolWindow(ToolWindowId.VCS) != null) {
      toolWindowManager.unregisterToolWindow(ToolWindowId.VCS);
    }
  }
コード例 #10
0
 @Override
 @NotNull
 public VcsRoot[] getAllVcsRoots() {
   List<VcsRoot> vcsRoots = new ArrayList<VcsRoot>();
   final AbstractVcs[] vcses = myMappings.getActiveVcses();
   for (AbstractVcs vcs : vcses) {
     final VirtualFile[] roots = getRootsUnderVcs(vcs);
     for (VirtualFile root : roots) {
       vcsRoots.add(new VcsRoot(vcs, root));
     }
   }
   return vcsRoots.toArray(new VcsRoot[vcsRoots.size()]);
 }
コード例 #11
0
 @Override
 @Nullable
 public VcsRoot getVcsRootObjectFor(final VirtualFile file) {
   final VcsDirectoryMapping mapping = myMappings.getMappingFor(file);
   if (mapping == null) {
     return null;
   }
   final String directory = mapping.getDirectory();
   final AbstractVcs vcs = findVcsByName(mapping.getVcs());
   if (directory.isEmpty()) {
     return new VcsRoot(vcs, myDefaultVcsRootPolicy.getVcsRootFor(file));
   }
   return new VcsRoot(vcs, LocalFileSystem.getInstance().findFileByPath(directory));
 }
コード例 #12
0
 @Override
 public String haveDefaultMapping() {
   return myMappings.haveDefaultMapping();
 }
コード例 #13
0
 @Override
 public void fireDirectoryMappingsChanged() {
   if (myProject.isOpen() && !myProject.isDisposed()) {
     myMappings.mappingsChanged();
   }
 }
コード例 #14
0
 @Override
 public List<VirtualFile> getRootsUnderVcsWithoutFiltering(final AbstractVcs vcs) {
   return myMappings.getMappingsAsFilesUnderVcs(vcs);
 }
コード例 #15
0
 @Override
 public boolean checkVcsIsActive(final String vcsName) {
   return myMappings.haveActiveVcs(vcsName);
 }
コード例 #16
0
 public void removeDirectoryMapping(VcsDirectoryMapping mapping) {
   myMappings.removeDirectoryMapping(mapping);
 }
コード例 #17
0
 @Override
 public void setDirectoryMappings(final List<VcsDirectoryMapping> items) {
   myHaveLegacyVcsConfiguration = true;
   myMappings.setDirectoryMappings(items);
 }
コード例 #18
0
 @Override
 public boolean hasActiveVcss() {
   return myMappings.hasActiveVcss();
 }
コード例 #19
0
 @Override
 public AbstractVcs[] getAllActiveVcss() {
   return myMappings.getActiveVcses();
 }
コード例 #20
0
 public boolean hasExplicitMapping(final VirtualFile vFile) {
   final VcsDirectoryMapping mapping = myMappings.getMappingFor(vFile);
   return mapping != null && !mapping.isDefaultMapping();
 }
コード例 #21
0
 @Override
 public boolean hasAnyMappings() {
   return !myMappings.isEmpty();
 }
コード例 #22
0
 @Override
 public List<VcsDirectoryMapping> getDirectoryMappings(final AbstractVcs vcs) {
   return myMappings.getDirectoryMappings(vcs.getName());
 }
コード例 #23
0
 @Override
 public List<VcsDirectoryMapping> getDirectoryMappings() {
   return myMappings.getDirectoryMappings();
 }
コード例 #24
0
 public void cleanupMappings() {
   myMappings.cleanupMappings();
 }