@Override public void rebuildList() { if (myInRebuildList) return; try { myInRebuildList = true; if (myChangesToDisplay == null) { // changes set not fixed === local changes final ChangeListManager manager = ChangeListManager.getInstance(myProject); myChangeListsMap = new HashMap<Change, LocalChangeList>(); final List<LocalChangeList> lists = manager.getChangeListsCopy(); Collection<Change> allChanges = new ArrayList<Change>(); for (LocalChangeList list : lists) { final Collection<Change> changes = list.getChanges(); allChanges.addAll(changes); for (Change change : changes) { myChangeListsMap.put(change, list); } } myAllChanges = allChanges; // refresh selected list also updateListsInChooser(); } super.rebuildList(); if (myRebuildListListener != null) { myRebuildListListener.run(); } } finally { myInRebuildList = false; } }
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(); } } }
private static String debugRealListContent(final LocalChangeList list) { final StringBuilder sb = new StringBuilder(list.getName() + ": "); final Collection<Change> changeCollection = list.getChanges(); for (Change change : changeCollection) { sb.append(change.toString()).append(' '); } return sb.toString(); }
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; }
@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; }
public static void checkDeletedFilesAreInList( final VirtualFile[] files, final String listName, final ChangeListManager manager) { assert manager.findChangeList(listName) != null; final LocalChangeList list = manager.findChangeList(listName); final Collection<Change> changes = list.getChanges(); assert changes.size() == files.length : debugRealListContent(list); for (Change change : changes) { final File vf = change.getBeforeRevision().getFile().getIOFile(); boolean found = false; for (VirtualFile vfile : files) { final File file = new File(vfile.getPath()); if (file.equals(vf)) { found = true; break; } } assert found == true : debugRealListContent(list); } }
public static void checkFilesAreInList( final String listName, final ChangeListManager manager, final VirtualFile... files) { assert manager.findChangeList(listName) != null; final LocalChangeList list = manager.findChangeList(listName); final Collection<Change> changes = list.getChanges(); assert changes.size() == files.length : "size: " + changes.size() + " " + debugRealListContent(list); for (Change change : changes) { final VirtualFile vf = change.getAfterRevision().getFile().getVirtualFile(); boolean found = false; for (VirtualFile file : files) { if (file.equals(vf)) { found = true; break; } } assert found == true : debugRealListContent(list); } }
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); } }