Search in sources :

Example 1 with MockChangelistBuilder

use of com.intellij.testFramework.vcs.MockChangelistBuilder in project intellij-community by JetBrains.

the class GitChangeProviderTest method getChanges.

/**
   * Marks the given files dirty in myDirtyScope, gets changes from myChangeProvider and groups the changes in the map.
   * Assumes that only one change for a file has happened.
   */
protected Map<FilePath, Change> getChanges(VirtualFile... changedFiles) throws VcsException {
    final List<FilePath> changedPaths = ObjectsConvertor.vf2fp(Arrays.asList(changedFiles));
    // get changes
    MockChangelistBuilder builder = new MockChangelistBuilder();
    myChangeProvider.getChanges(myDirtyScope, builder, new EmptyProgressIndicator(), new MockChangeListManagerGate(ChangeListManager.getInstance(myProject)));
    List<Change> changes = builder.getChanges();
    // get changes for files
    final Map<FilePath, Change> result = new HashMap<>();
    for (Change change : changes) {
        VirtualFile file = change.getVirtualFile();
        FilePath filePath = null;
        if (file == null) {
            // if a file was deleted, just find the reference in the original list of files and use it. 
            String path = change.getBeforeRevision().getFile().getPath();
            for (FilePath fp : changedPaths) {
                if (FileUtil.pathsEqual(fp.getPath(), path)) {
                    filePath = fp;
                    break;
                }
            }
        } else {
            filePath = VcsUtil.getFilePath(file);
        }
        result.put(filePath, change);
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) MockChangeListManagerGate(com.intellij.testFramework.vcs.MockChangeListManagerGate) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) HashMap(java.util.HashMap) Change(com.intellij.openapi.vcs.changes.Change) MockChangelistBuilder(com.intellij.testFramework.vcs.MockChangelistBuilder)

Example 2 with MockChangelistBuilder

use of com.intellij.testFramework.vcs.MockChangelistBuilder in project intellij-community by JetBrains.

the class SvnTestCase method getChangesInScope.

protected List<Change> getChangesInScope(final VcsDirtyScope dirtyScope) throws VcsException {
    ChangeProvider changeProvider = SvnVcs.getInstance(myProject).getChangeProvider();
    MockChangelistBuilder builder = new MockChangelistBuilder();
    changeProvider.getChanges(dirtyScope, builder, new EmptyProgressIndicator(), myGate);
    return builder.getChanges();
}
Also used : EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) MockChangelistBuilder(com.intellij.testFramework.vcs.MockChangelistBuilder)

Aggregations

EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)2 MockChangelistBuilder (com.intellij.testFramework.vcs.MockChangelistBuilder)2 Change (com.intellij.openapi.vcs.changes.Change)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 MockChangeListManagerGate (com.intellij.testFramework.vcs.MockChangeListManagerGate)1 HashMap (java.util.HashMap)1