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;
  }
示例#2
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();
     }
   }
 }
 @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);
   }
 }
  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;
  }
  public void notifyDoneProcessingChanges(final ChangeListListener dispatcher) {
    List<ChangeList> changedLists = new ArrayList<ChangeList>();
    final Map<LocalChangeListImpl, List<Change>> removedChanges =
        new HashMap<LocalChangeListImpl, List<Change>>();
    final Map<LocalChangeListImpl, List<Change>> addedChanges =
        new HashMap<LocalChangeListImpl, List<Change>>();
    for (LocalChangeList list : myMap.values()) {
      final List<Change> removed = new ArrayList<Change>();
      final List<Change> added = new ArrayList<Change>();
      final LocalChangeListImpl listImpl = (LocalChangeListImpl) list;
      if (listImpl.doneProcessingChanges(removed, added)) {
        changedLists.add(list);
      }
      if (!removed.isEmpty()) {
        removedChanges.put(listImpl, removed);
      }
      if (!added.isEmpty()) {
        addedChanges.put(listImpl, added);
      }
    }
    for (Map.Entry<LocalChangeListImpl, List<Change>> entry : removedChanges.entrySet()) {
      dispatcher.changesRemoved(entry.getValue(), entry.getKey());
    }
    for (Map.Entry<LocalChangeListImpl, List<Change>> entry : addedChanges.entrySet()) {
      dispatcher.changesAdded(entry.getValue(), entry.getKey());
    }
    for (ChangeList changeList : changedLists) {
      dispatcher.changeListChanged(changeList);
    }
    mySwitchedHolder.calculateChildren();

    for (String name : myListsToDisappear) {
      final LocalChangeList changeList = myMap.get(name);
      if ((changeList != null)
          && changeList.getChanges().isEmpty()
          && (!changeList.isReadOnly())
          && (!changeList.isDefault())) {
        removeChangeList(name);
      }
    }
    myListsToDisappear.clear();
  }
  public void testAddChangeListViaVcsAction() throws Exception {
    Task task = myRepository.findTask("TEST-001");
    assertNotNull(task);
    activateAndCreateChangelist(task);
    myChangeListManager.waitUntilRefreshed();

    LocalTask defaultTask = myTaskManager.findTask(LocalTaskImpl.DEFAULT_TASK_ID);
    assertNotNull(defaultTask);
    activateAndCreateChangelist(defaultTask);
    myChangeListManager.waitUntilRefreshed();
    assertEquals(defaultTask, myTaskManager.getActiveTask());

    LocalTask anotherTask = myTaskManager.findTask("TEST-001");
    assertNotNull(anotherTask);
    addChangeList("Default (1)", "");

    assertEquals(1, anotherTask.getChangeLists().size());
    assertEquals(2, defaultTask.getChangeLists().size());
    assertEquals(3, myChangeListManager.getChangeListsCopy().size());

    LocalChangeList defaultChangeListActive =
        myChangeListManager.findChangeList(LocalChangeList.DEFAULT_NAME);
    assertNotNull(defaultChangeListActive);
    assertTrue(myChangeListManager.getDefaultListName(), defaultChangeListActive.isDefault());

    LocalChangeList defaultChangeListInactive = myChangeListManager.findChangeList("Default (1)");
    assertNotNull(defaultChangeListInactive);
    LocalChangeList anotherChangeList = myChangeListManager.findChangeList("TEST-001 Summary");
    assertNotNull(anotherChangeList);

    assertEquals(defaultTask, myTaskManager.getAssociatedTask(defaultChangeListActive));
    assertEquals(LocalChangeList.DEFAULT_NAME, defaultChangeListActive.getName());

    assertEquals(defaultTask, myTaskManager.getAssociatedTask(defaultChangeListInactive));
    assertEquals("Default (1)", defaultChangeListInactive.getName());

    assertEquals(anotherTask, myTaskManager.getAssociatedTask(anotherChangeList));
    assertEquals("TEST-001 Summary", anotherChangeList.getName());
  }
示例#7
0
 private void createChangelist(final ContinuationPause context) {
   final ChangeListManager listManager = ChangeListManager.getInstance(myProject);
   String name = myTitle;
   int i = 1;
   boolean updateDefaultList = false;
   while (true) {
     final LocalChangeList changeList = listManager.findChangeList(name);
     if (changeList == null) {
       final LocalChangeList newList = listManager.addChangeList(name, null);
       listManager.setDefaultChangeList(newList);
       updateDefaultList = true;
       break;
     }
     if (changeList.getChanges().isEmpty()) {
       if (!changeList.isDefault()) {
         listManager.setDefaultChangeList(changeList);
         updateDefaultList = true;
       }
       break;
     }
     name = myTitle + " (" + i + ")";
     ++i;
   }
   if (updateDefaultList) {
     context.suspend();
     listManager.invokeAfterUpdate(
         new Runnable() {
           public void run() {
             context.ping();
           }
         },
         InvokeAfterUpdateMode.BACKGROUND_NOT_CANCELLABLE_NOT_AWT,
         "",
         ModalityState.NON_MODAL);
   }
 }
 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);
 }
 @Override
 public void render(
     final ChangesBrowserNodeRenderer renderer,
     final boolean selected,
     final boolean expanded,
     final boolean hasFocus) {
   if (userObject instanceof LocalChangeList) {
     final LocalChangeList list = ((LocalChangeList) userObject);
     renderer.appendTextWithIssueLinks(
         list.getName(),
         list.isDefault()
             ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES
             : SimpleTextAttributes.REGULAR_ATTRIBUTES);
     appendCount(renderer);
     for (ChangeListDecorator decorator : myDecorators) {
       decorator.decorateChangeList(list, renderer, selected, expanded, hasFocus);
     }
     final String freezed = myClManager.isFreezed();
     if (freezed != null) {
       renderer.append(" " + freezed, SimpleTextAttributes.GRAYED_ATTRIBUTES);
     } else if (myClManager.isInUpdate()) {
       renderer.append(
           " " + VcsBundle.message("changes.nodetitle.updating"),
           SimpleTextAttributes.GRAYED_ATTRIBUTES);
     }
     if (!myChangeListRemoteState.getState()) {
       renderer.append(" ");
       renderer.append(
           VcsBundle.message("changes.nodetitle.have.outdated.files"),
           SimpleTextAttributes.ERROR_ATTRIBUTES);
     }
   } else {
     renderer.append(getUserObject().getName(), SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES);
     appendCount(renderer);
   }
 }