private PatchStrippable(final FilePatch patch) {
      final boolean onePath =
          patch.isDeletedFile()
              || patch.isNewFile()
              || Comparing.equal(patch.getAfterName(), patch.getBeforeName());
      final int size = onePath ? 1 : 2;
      myParts = new Strippable[size];

      int cnt = 0;
      if (patch.getAfterName() != null) {
        myAfterIdx = 0;
        myParts[cnt] = new StripCapablePath(patch.getAfterName());
        ++cnt;
      } else {
        myAfterIdx = -1;
      }
      if (cnt < size) {
        myParts[cnt] = new StripCapablePath(patch.getBeforeName());
        myBeforeIdx = cnt;
      } else {
        myBeforeIdx = 0;
      }
    }
示例#2
0
 public List<ShelvedChange> getChanges(Project project) {
   if (myChanges == null) {
     try {
       myChanges = new ArrayList<ShelvedChange>();
       final List<? extends FilePatch> list =
           ShelveChangesManager.loadPatchesWithoutContent(project, PATH, null);
       for (FilePatch patch : list) {
         FileStatus status;
         if (patch.isNewFile()) {
           status = FileStatus.ADDED;
         } else if (patch.isDeletedFile()) {
           status = FileStatus.DELETED;
         } else {
           status = FileStatus.MODIFIED;
         }
         myChanges.add(
             new ShelvedChange(PATH, patch.getBeforeName(), patch.getAfterName(), status));
       }
     } catch (Exception e) {
       LOG.error("Failed to parse the file patch: [" + PATH + "]", e);
     }
   }
   return myChanges;
 }