コード例 #1
0
 private void baseRevisionsOfDvcsIntoContext(
     List<Change> textChanges, CommitContext commitContext) {
   ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject);
   if (vcsManager.dvcsUsedInProject()
       && VcsConfiguration.getInstance(myProject).INCLUDE_TEXT_INTO_SHELF) {
     final Set<Change> big = SelectFilesToAddTextsToPatchPanel.getBig(textChanges);
     final ArrayList<FilePath> toKeep = new ArrayList<FilePath>();
     for (Change change : textChanges) {
       if (change.getBeforeRevision() == null || change.getAfterRevision() == null) continue;
       if (big.contains(change)) continue;
       FilePath filePath = ChangesUtil.getFilePath(change);
       final AbstractVcs vcs = vcsManager.getVcsFor(filePath);
       if (vcs != null && VcsType.distibuted.equals(vcs.getType())) {
         toKeep.add(filePath);
       }
     }
     commitContext.putUserData(BaseRevisionTextPatchEP.ourPutBaseRevisionTextKey, true);
     commitContext.putUserData(BaseRevisionTextPatchEP.ourBaseRevisionPaths, toKeep);
   }
 }
コード例 #2
0
 public static File suggestPatchName(
     Project project, final String commitMessage, final File file, String extension) {
   @NonNls String defaultPath = PathUtil.suggestFileName(commitMessage);
   if (defaultPath.length() == 0) {
     defaultPath = "unnamed";
   }
   if (defaultPath.length() > (PatchNameChecker.MAX - 10)) {
     defaultPath = defaultPath.substring(0, PatchNameChecker.MAX - 10);
   }
   while (true) {
     final File nonexistentFile =
         FileUtil.findSequentNonexistentFile(
             file,
             defaultPath,
             extension == null
                 ? VcsConfiguration.getInstance(project).getPatchFileExtension()
                 : extension);
     if (nonexistentFile.getName().length() >= PatchNameChecker.MAX) {
       defaultPath = defaultPath.substring(0, defaultPath.length() - 1);
       continue;
     }
     return nonexistentFile;
   }
 }