Пример #1
0
 public void processChangeLists(final List<LocalChangeList> lists) {
   final ProjectLevelVcsManager plVcsManager =
       ProjectLevelVcsManager.getInstanceChecked(myProject);
   plVcsManager.startBackgroundVcsOperation();
   try {
     final SVNChangelistClient client = createChangelistClient();
     for (LocalChangeList list : lists) {
       if (!list.isDefault()) {
         final Collection<Change> changes = list.getChanges();
         for (Change change : changes) {
           correctListForRevision(
               plVcsManager, change.getBeforeRevision(), client, list.getName());
           correctListForRevision(plVcsManager, change.getAfterRevision(), client, list.getName());
         }
       }
     }
   } finally {
     final Application appManager = ApplicationManager.getApplication();
     if (appManager.isDispatchThread()) {
       appManager.executeOnPooledThread(
           new Runnable() {
             @Override
             public void run() {
               plVcsManager.stopBackgroundVcsOperation();
             }
           });
     } else {
       plVcsManager.stopBackgroundVcsOperation();
     }
   }
 }
 protected void processInChange(Couple<String> key, Change change) {
   final LocalChangeList list = myInternalMap.get(key);
   if (list != null) {
     myIncludedListsCopies.put(list.getName(), list);
     myValidChanges.add(change);
   }
 }
  private ChangeListWorker(final ChangeListWorker worker) {
    myProject = worker.myProject;
    myMap = new LinkedHashMap<String, LocalChangeList>();
    myIdx = new ChangeListsIndexes(worker.myIdx);
    myLocallyDeleted = worker.myLocallyDeleted.copy();
    mySwitchedHolder = worker.mySwitchedHolder.copy();
    myDelta = worker.myDelta;
    myListsToDisappear = new LinkedList<String>(worker.myListsToDisappear);

    LocalChangeList defaultList = null;
    for (LocalChangeList changeList : worker.myMap.values()) {
      final LocalChangeList copy = changeList.copy();

      final String changeListName = copy.getName();
      myMap.put(changeListName, copy);
      if (copy.isDefault()) {
        defaultList = copy;
      }
    }
    if (defaultList == null) {
      LOG.info("default list not found when copy");
      defaultList = myMap.get(worker.getDefaultListName());
    }

    if (defaultList == null) {
      LOG.info("default list not found when copy in original object too");
      if (!myMap.isEmpty()) {
        defaultList = myMap.values().iterator().next();
      } else {
        // can be when there's no vcs configured
        /// LOG.error("no changelists at all");
      }
    }
    myDefault = defaultList;
  }
Пример #4
0
 @Nullable
 private static Consumer<Collection<FilePath>> createMover(
     final Project project, final LocalChangeList targetChangeList) {
   final ChangeListManager clm = ChangeListManager.getInstance(project);
   if (targetChangeList == null || clm.getDefaultListName().equals(targetChangeList.getName()))
     return null;
   return new FilesMover(clm, targetChangeList);
 }
Пример #5
0
  private Intersection getMergeAllIntersection(List<LocalChangeList> localChangeLists) {
    final Intersection intersection = new Intersection();

    for (LocalChangeList localChangeList : localChangeLists) {
      final Collection<Change> localChanges = localChangeList.getChanges();
      for (Change localChange : localChanges) {
        intersection.add(localChangeList.getName(), localChangeList.getComment(), localChange);
      }
    }
    return intersection;
  }
 @Override
 public void trackContext(LocalChangeList changeList) {
   ChangeListInfo changeListInfo = new ChangeListInfo(changeList);
   String changeListName = changeList.getName();
   LocalTaskImpl task = createLocalTask(changeListName);
   task.addChangelist(changeListInfo);
   addTask(task);
   if (changeList.isDefault()) {
     activateTask(task, false);
   }
 }
 protected void processInChange(Couple<String> key, Change change) {
   LocalChangeList tmpList = myInternalMap.get(key);
   if (tmpList == null) {
     tmpList = myDefaultCopy;
   }
   final String tmpName = tmpList.getName();
   List<Change> list = myListToChangesMap.get(tmpName);
   if (list == null) {
     list = new ArrayList<Change>();
     myListToChangesMap.put(tmpName, list);
     myIncludedListsCopies.put(tmpName, tmpList);
   }
   list.add(change);
 }
 public void addChangeToCorrespondingList(final Change change, final VcsKey vcsKey) {
   final String path = ChangesUtil.getFilePath(change).getPath();
   LOG.debug(
       "[addChangeToCorrespondingList] for change "
           + path
           + " type: "
           + change.getType()
           + " have before revision: "
           + (change.getBeforeRevision() != null));
   assert myDefault != null;
   for (LocalChangeList list : myMap.values()) {
     if (list.isDefault()) {
       LOG.debug(
           "[addChangeToCorrespondingList] skip default list: "
               + list.getName()
               + " type: "
               + change.getType()
               + " have before revision: "
               + (change.getBeforeRevision() != null));
       continue;
     }
     if (((LocalChangeListImpl) list).processChange(change)) {
       LOG.debug(
           "[addChangeToCorrespondingList] matched: "
               + list.getName()
               + " type: "
               + change.getType()
               + " have before revision: "
               + (change.getBeforeRevision() != null));
       myIdx.changeAdded(change, vcsKey);
       return;
     }
   }
   ((LocalChangeListImpl) myDefault).processChange(change);
   myIdx.changeAdded(change, vcsKey);
 }
  /**
   * @return if list with name exists, return previous default list name or null of there wasn't
   *     previous
   */
  @Nullable
  public String setDefault(final String name) {
    final LocalChangeList newDefault = myMap.get(name);
    if (newDefault == null) {
      return null;
    }
    String previousName = null;
    if (myDefault != null) {
      ((LocalChangeListImpl) myDefault).setDefault(false);
      previousName = myDefault.getName();
    }

    ((LocalChangeListImpl) newDefault).setDefault(true);
    myDefault = newDefault;

    return previousName;
  }
  public boolean removeChangeList(@NotNull String name) {
    final LocalChangeList list = myMap.get(name);
    if (list == null) {
      return false;
    }
    if (list.isDefault()) {
      throw new RuntimeException(
          new IncorrectOperationException("Cannot remove default changelist"));
    }
    final String listName = list.getName();

    for (Change change : list.getChanges()) {
      ((LocalChangeListImpl) myDefault).addChange(change);
    }

    final LocalChangeList removed = myMap.remove(listName);
    return true;
  }
Пример #11
0
    @Nullable
    private Intersection checkIntersection(
        @Nullable final List<CommittedChangeList> lists, List<LocalChangeList> localChangeLists) {
      if (lists == null || lists.isEmpty()) {
        return null;
      }
      final Set<FilePath> mergePaths = new HashSet<FilePath>();
      for (CommittedChangeList list : lists) {
        final SvnChangeList svnList = (SvnChangeList) list;
        final List<String> paths = new ArrayList<String>(svnList.getAddedPaths());
        paths.addAll(svnList.getChangedPaths());
        paths.addAll(svnList.getDeletedPaths());
        for (String path : paths) {
          final File localPath = getLocalPath(path);
          if (localPath != null) {
            mergePaths.add(new FilePathImpl(localPath, false));
          }
        }
      }

      final Intersection intersection = new Intersection();
      for (LocalChangeList localChangeList : localChangeLists) {
        final Collection<Change> localChanges = localChangeList.getChanges();

        for (Change localChange : localChanges) {
          final FilePath before =
              localChange.getBeforeRevision() == null
                  ? null
                  : localChange.getBeforeRevision().getFile();
          final FilePath after =
              localChange.getAfterRevision() == null
                  ? null
                  : localChange.getAfterRevision().getFile();

          if ((before != null && mergePaths.contains(before))
              || (after != null && mergePaths.contains(after))) {
            intersection.add(localChangeList.getName(), localChangeList.getComment(), localChange);
          }
        }
      }
      return intersection;
    }
  private void checkForMultipleCopiesNotMove(boolean somethingChanged) {
    final MultiMap<FilePath, Pair<Change, String>> moves =
        new MultiMap<FilePath, Pair<Change, String>>() {
          @NotNull
          protected Collection<Pair<Change, String>> createCollection() {
            return new LinkedList<Pair<Change, String>>();
          }
        };

    for (LocalChangeList changeList : myMap.values()) {
      final Collection<Change> changes = changeList.getChanges();
      for (Change change : changes) {
        if (change.isMoved() || change.isRenamed()) {
          moves.putValue(
              change.getBeforeRevision().getFile(), Pair.create(change, changeList.getName()));
        }
      }
    }
    for (FilePath filePath : moves.keySet()) {
      final List<Pair<Change, String>> copies = (List<Pair<Change, String>>) moves.get(filePath);
      if (copies.size() == 1) continue;
      Collections.sort(copies, MyChangesAfterRevisionComparator.getInstance());
      for (int i = 0; i < (copies.size() - 1); i++) {
        somethingChanged = true;
        final Pair<Change, String> item = copies.get(i);
        final Change oldChange = item.getFirst();
        final Change newChange = new Change(null, oldChange.getAfterRevision());

        final LocalChangeListImpl list = (LocalChangeListImpl) myMap.get(item.getSecond());
        list.removeChange(oldChange);
        list.addChange(newChange);

        final VcsKey key = myIdx.getVcsFor(oldChange);
        myIdx.changeRemoved(oldChange);
        myIdx.changeAdded(newChange, key);
      }
    }
    if (somethingChanged) {
      FileStatusManager.getInstance(myProject).fileStatusesChanged();
    }
  }
  @Nullable
  public String listNameIfOnlyOne(final @Nullable Change[] changes) {
    if (changes == null || changes.length == 0) {
      return null;
    }

    final Change first = changes[0];

    for (LocalChangeList list : myMap.values()) {
      final Collection<Change> listChanges = list.getChanges();
      if (listChanges.contains(first)) {
        // must contain all other
        for (int i = 1; i < changes.length; i++) {
          final Change change = changes[i];
          if (!listChanges.contains(change)) {
            return null;
          }
        }
        return list.getName();
      }
    }
    return null;
  }
 public String getDefaultListName() {
   return myDefault == null ? null : myDefault.getName();
 }