当前位置: 首页>>代码示例>>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;未经允许,请勿转载。