git: use a more correct method to calculate number of updated files: IDEA-215906

It already exists to collect the UpdatedFiles.

GitOrigin-RevId: b8fc3917f84872e5ef5bf55948b1da260c6116e9
This commit is contained in:
Kirill Likhodedov
2019-07-02 06:52:16 +03:00
committed by intellij-monorepo-bot
parent 818660d1a7
commit c4fc27c44e
2 changed files with 14 additions and 2 deletions
@@ -80,6 +80,17 @@ public class MergeChangeCollector {
addAll(updatedFiles, FileGroup.REMOVED_FROM_REPOSITORY_ID, removed);
}
public int calcUpdatedFilesCount() throws VcsException {
String revisionsForDiff = getRevisionsForDiff();
if (revisionsForDiff == null) {
return 0;
}
Set<String> updated = new HashSet<>();
getChangedFilesExceptUnmerged(updated, updated, updated, revisionsForDiff);
return updated.size() + getUnmergedPaths().size();
}
/**
* Returns absolute paths to files which are currently unmerged, and also populates myUnmergedPaths with relative paths.
*/
@@ -33,8 +33,9 @@ import com.intellij.vcs.log.visible.VisiblePack
import com.intellij.vcs.log.visible.VisiblePackChangeListener
import com.intellij.vcs.log.visible.VisiblePackRefresherImpl
import com.intellij.vcs.log.visible.filters.VcsLogFilterObject
import git4idea.changes.GitChangeUtils
import git4idea.GitRevisionNumber
import git4idea.history.GitHistoryUtils
import git4idea.merge.MergeChangeCollector
import git4idea.repo.GitRepository
import org.jetbrains.annotations.CalledInAwt
import java.util.*
@@ -156,7 +157,7 @@ class GitUpdateInfoAsLog(private val project: Project,
private fun calcUpdatedFilesCount(): Int {
return calcCount { repository, range ->
GitChangeUtils.getDiffWithWorkingDir(project, repository.root, range.start.asString(), null, false, false).size
MergeChangeCollector(project, repository.root, GitRevisionNumber(range.start.asString())).calcUpdatedFilesCount()
}
}