當前位置: 首頁>>代碼示例>>Java>>正文


Java HgUtil.getHgRootOrNull方法代碼示例

本文整理匯總了Java中org.zmlx.hg4idea.util.HgUtil.getHgRootOrNull方法的典型用法代碼示例。如果您正苦於以下問題:Java HgUtil.getHgRootOrNull方法的具體用法?Java HgUtil.getHgRootOrNull怎麽用?Java HgUtil.getHgRootOrNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.zmlx.hg4idea.util.HgUtil的用法示例。


在下文中一共展示了HgUtil.getHgRootOrNull方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: filterUniqueRoots

import org.zmlx.hg4idea.util.HgUtil; //導入方法依賴的package包/類
@Override
public <S> List<S> filterUniqueRoots(final List<S> in, final Convertor<S, VirtualFile> convertor) {
  Collections.sort(in, new ComparatorDelegate<S, VirtualFile>(convertor, FilePathComparator.getInstance()));

  for (int i = 1; i < in.size(); i++) {
    final S sChild = in.get(i);
    final VirtualFile child = convertor.convert(sChild);
    final VirtualFile childRoot = HgUtil.getHgRootOrNull(myProject, child);
    if (childRoot == null) {
      continue;
    }
    for (int j = i - 1; j >= 0; --j) {
      final S sParent = in.get(j);
      final VirtualFile parent = convertor.convert(sParent);
      // if the parent is an ancestor of the child and that they share common root, the child is removed
      if (VfsUtilCore.isAncestor(parent, child, false) && VfsUtilCore.isAncestor(childRoot, parent, false)) {
        in.remove(i);
        //noinspection AssignmentToForLoopParameter
        --i;
        break;
      }
    }
  }
  return in;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:HgVcs.java

示例2: filterUniqueRoots

import org.zmlx.hg4idea.util.HgUtil; //導入方法依賴的package包/類
@Override
public <S> List<S> filterUniqueRoots(final List<S> in, final Convertor<S, VirtualFile> convertor) {
  Collections.sort(in, new ComparatorDelegate<S, VirtualFile>(convertor, FilePathComparator.getInstance()));

  for (int i = 1; i < in.size(); i++) {
    final S sChild = in.get(i);
    final VirtualFile child = convertor.convert(sChild);
    final VirtualFile childRoot = HgUtil.getHgRootOrNull(myProject, child);
    if (childRoot == null) {
      continue;
    }
    for (int j = i - 1; j >= 0; --j) {
      final S sParent = in.get(j);
      final VirtualFile parent = convertor.convert(sParent);
      // if the parent is an ancestor of the child and that they share common root, the child is removed
      if (VfsUtil.isAncestor(parent, child, false) && VfsUtil.isAncestor(childRoot, parent, false)) {
        in.remove(i);
        //noinspection AssignmentToForLoopParameter
        --i;
        break;
      }
    }
  }
  return in;
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:26,代碼來源:HgVcs.java

示例3: skipNotUnderHg

import org.zmlx.hg4idea.util.HgUtil; //導入方法依賴的package包/類
/**
 * Changes the given collection of files by filtering out unversioned files and
 * files which are not under Mercurial repository.
 *
 * @param filesToFilter    files to be filtered.
 */
private void skipNotUnderHg(Collection<FilePath> filesToFilter) {
  for (Iterator<FilePath> iter = filesToFilter.iterator(); iter.hasNext(); ) {
    final FilePath filePath = iter.next();
    if (HgUtil.getHgRootOrNull(myProject, filePath) == null) {
      iter.remove();
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:HgVFSListener.java

示例4: actionPerformed

import org.zmlx.hg4idea.util.HgUtil; //導入方法依賴的package包/類
public void actionPerformed(AnActionEvent event) {
  final DataContext dataContext = event.getDataContext();
  final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return;
  }
  VirtualFile file = event.getData(PlatformDataKeys.VIRTUAL_FILE);
  VirtualFile repo = file != null ? HgUtil.getHgRootOrNull(project, file) : null;
  List<VirtualFile> repos = HgUtil.getHgRepositories(project);
  if (!repos.isEmpty()) {
    execute(project, repos, repo);
  }
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:14,代碼來源:HgAbstractGlobalAction.java

示例5: actionPerformed

import org.zmlx.hg4idea.util.HgUtil; //導入方法依賴的package包/類
@Override
public void actionPerformed(AnActionEvent event) {
  final DataContext dataContext = event.getDataContext();
  final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return;
  }
  VirtualFile file = event.getData(PlatformDataKeys.VIRTUAL_FILE);
  VirtualFile repo = file != null ? HgUtil.getHgRootOrNull(project, file) : null;
  execute(project, repo);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:12,代碼來源:HgAction.java

示例6: HgFile

import org.zmlx.hg4idea.util.HgUtil; //導入方法依賴的package包/類
public HgFile(@NotNull Project project, @NotNull VirtualFile file) {
  this(HgUtil.getHgRootOrNull(project, file), VcsUtil.getFilePath(file.getPath()));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:4,代碼來源:HgFile.java

示例7: executeAdd

import org.zmlx.hg4idea.util.HgUtil; //導入方法依賴的package包/類
@Override
protected void executeAdd(final List<VirtualFile> addedFiles, final Map<VirtualFile, VirtualFile> copyFromMap) {
  // if a file is copied from another repository, then 'hg add' should be used instead of 'hg copy'.
  // Thus here we remove such files from the copyFromMap.
  for (Iterator<Map.Entry<VirtualFile, VirtualFile>> it = copyFromMap.entrySet().iterator(); it.hasNext(); ) {
    final Map.Entry<VirtualFile, VirtualFile> entry = it.next();
    final VirtualFile rootFrom = HgUtil.getHgRootOrNull(myProject, entry.getKey());
    final VirtualFile rootTo = HgUtil.getHgRootOrNull(myProject, entry.getValue());

    if (rootTo == null || !rootTo.equals(rootFrom)) {
      it.remove();
    }
  }

  // exclude files which are added to a directory which is not version controlled
  for (Iterator<VirtualFile> it = addedFiles.iterator(); it.hasNext(); ) {
    if (HgUtil.getHgRootOrNull(myProject, it.next()) == null) {
      it.remove();
    }
  }
  // exclude files which are ignored in .hgignore in background and execute adding after that
  final Map<VirtualFile, Collection<VirtualFile>> sortedFiles = HgUtil.sortByHgRoots(myProject, addedFiles);
  final HashSet<VirtualFile> untrackedFiles = new HashSet<VirtualFile>();
  new Task.Backgroundable(myProject, HgVcsMessages.message("hg4idea.progress.checking.ignored"), false) {
    @Override
    public void run(@NotNull ProgressIndicator pi) {
      for (Map.Entry<VirtualFile, Collection<VirtualFile>> e : sortedFiles.entrySet()) {
        VirtualFile repo = e.getKey();
        final Collection<VirtualFile> files = e.getValue();
        pi.setText(repo.getPresentableUrl());
        try {
          untrackedFiles
            .addAll(new HgStatusCommand.Builder(false).unknown(true).removed(true).build(myProject)
                      .getHgUntrackedFiles(repo, new ArrayList<VirtualFile>(files)));
        }
        catch (final VcsException ex) {
          UIUtil.invokeLaterIfNeeded(new Runnable() {
            public void run() {
              ((HgVcs)myVcs).showMessageInConsole(ex.getMessage(), ConsoleViewContentType.ERROR_OUTPUT.getAttributes());
            }
          });
        }
      }
      addedFiles.retainAll(untrackedFiles);
      // select files to add if there is something to select
      if (!addedFiles.isEmpty() || !copyFromMap.isEmpty()) {

        AppUIUtil.invokeLaterIfProjectAlive(myProject, new Runnable() {
          @Override
          public void run() {
            originalExecuteAdd(addedFiles, copyFromMap);
          }
        });
      }
    }
  }.queue();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:58,代碼來源:HgVFSListener.java

示例8: executeAdd

import org.zmlx.hg4idea.util.HgUtil; //導入方法依賴的package包/類
@Override
protected void executeAdd(final List<VirtualFile> addedFiles, final Map<VirtualFile, VirtualFile> copyFromMap) {
  // if a file is copied from another repository, then 'hg add' should be used instead of 'hg copy'.
  // Thus here we remove such files from the copyFromMap.
  for (Iterator<Map.Entry<VirtualFile, VirtualFile>> it = copyFromMap.entrySet().iterator(); it.hasNext(); ) {
    final Map.Entry<VirtualFile, VirtualFile> entry = it.next();
    final VirtualFile rootFrom = HgUtil.getHgRootOrNull(myProject, entry.getKey());
    final VirtualFile rootTo = HgUtil.getHgRootOrNull(myProject, entry.getValue());

    if (rootTo == null || !rootTo.equals(rootFrom)) {
      it.remove();
    }
  }

  // exclude files which are added to a directory which is not version controlled
  for (Iterator<VirtualFile> it = addedFiles.iterator(); it.hasNext(); ) {
    if (HgUtil.getHgRootOrNull(myProject, it.next()) == null) {
      it.remove();
    }
  }
  // exclude files which are ignored in .hgignore in background and execute adding after that
  final Map<VirtualFile, Collection<VirtualFile>> sortedFiles = HgUtil.sortByHgRoots(myProject, addedFiles);
  final HashSet<VirtualFile> untrackedFiles = new HashSet<VirtualFile>();
  new Task.Backgroundable(myProject, HgVcsMessages.message("hg4idea.progress.checking.ignored"), false) {
    @Override
    public void run(@NotNull ProgressIndicator pi) {
      for (Map.Entry<VirtualFile, Collection<VirtualFile>> e : sortedFiles.entrySet()) {
        VirtualFile repo = e.getKey();
        final Collection<VirtualFile> files = e.getValue();
        pi.setText(repo.getPresentableUrl());
        try {
          untrackedFiles
            .addAll(new HgStatusCommand.Builder(false).unknown(true).build(myProject)
                      .getHgUntrackedFiles(repo, new ArrayList<VirtualFile>(files)));
        }
        catch (final VcsException ex) {
          UIUtil.invokeLaterIfNeeded(new Runnable() {
            public void run() {
              ((HgVcs)myVcs).showMessageInConsole(ex.getMessage(), ConsoleViewContentType.ERROR_OUTPUT.getAttributes());
            }
          });
        }
      }
      addedFiles.retainAll(untrackedFiles);
      // select files to add if there is something to select
      if (!addedFiles.isEmpty() || !copyFromMap.isEmpty()) {

        AppUIUtil.invokeLaterIfProjectAlive(myProject, new Runnable() {
          @Override
          public void run() {
            originalExecuteAdd(addedFiles, copyFromMap);
          }
        });
      }
    }
  }.queue();
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:58,代碼來源:HgVFSListener.java

示例9: convertRoot

import org.zmlx.hg4idea.util.HgUtil; //導入方法依賴的package包/類
@Nullable
private VirtualFile convertRoot(@Nullable VirtualFile root) {
  return HgUtil.getHgRootOrNull(myProject, root);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:5,代碼來源:HgRootsHandler.java


注:本文中的org.zmlx.hg4idea.util.HgUtil.getHgRootOrNull方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。