Search in sources :

Example 1 with Whitespace

use of com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace in project gerrit by GerritCodeReview.

the class Schema_115 method toWhitespace.

private static Whitespace toWhitespace(String v) {
    Preconditions.checkNotNull(v);
    if (v.isEmpty()) {
        return Whitespace.IGNORE_NONE;
    }
    Whitespace r = PatchListKey.WHITESPACE_TYPES.inverse().get(v.charAt(0));
    if (r == null) {
        throw new IllegalArgumentException("Cannot find Whitespace type for: " + v);
    }
    return r;
}
Also used : Whitespace(com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace)

Example 2 with Whitespace

use of com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace in project gerrit by GerritCodeReview.

the class PatchListCacheImpl method getDiffSummary.

@Override
public DiffSummary getDiffSummary(Change change, PatchSet patchSet) throws PatchListNotAvailableException {
    Project.NameKey project = change.getProject();
    ObjectId b = ObjectId.fromString(patchSet.getRevision().get());
    Whitespace ws = Whitespace.IGNORE_NONE;
    return getDiffSummary(DiffSummaryKey.fromPatchListKey(PatchListKey.againstDefaultBase(b, ws)), project);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) ObjectId(org.eclipse.jgit.lib.ObjectId) Whitespace(com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace)

Example 3 with Whitespace

use of com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace in project gerrit by GerritCodeReview.

the class PatchListCacheImpl method get.

private PatchList get(Change change, PatchSet patchSet, Integer parentNum) throws PatchListNotAvailableException {
    Project.NameKey project = change.getProject();
    if (patchSet.getRevision() == null) {
        throw new PatchListNotAvailableException("revision is null for " + patchSet.getId());
    }
    ObjectId b = ObjectId.fromString(patchSet.getRevision().get());
    Whitespace ws = Whitespace.IGNORE_NONE;
    if (parentNum != null) {
        return get(PatchListKey.againstParentNum(parentNum, b, ws), project);
    }
    return get(PatchListKey.againstDefaultBase(b, ws), project);
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) ObjectId(org.eclipse.jgit.lib.ObjectId) Whitespace(com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace)

Example 4 with Whitespace

use of com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace in project gerrit by GerritCodeReview.

the class DiffOperationsImpl method getModifiedFiles.

private ImmutableMap<String, FileDiffOutput> getModifiedFiles(DiffParameters diffParams, DiffOptions diffOptions) throws DiffNotAvailableException {
    try {
        Project.NameKey project = diffParams.project();
        ObjectId newCommit = diffParams.newCommit();
        ObjectId oldCommit = diffParams.baseCommit();
        ComparisonType cmp = diffParams.comparisonType();
        ImmutableList<ModifiedFile> modifiedFiles = modifiedFilesCache.get(createModifiedFilesKey(project, oldCommit, newCommit));
        List<FileDiffCacheKey> fileCacheKeys = new ArrayList<>();
        fileCacheKeys.add(createFileDiffCacheKey(project, oldCommit, newCommit, COMMIT_MSG, DEFAULT_DIFF_ALGORITHM, /* useTimeout= */
        true, /* whitespace= */
        null));
        if (cmp.isAgainstAutoMerge() || isMergeAgainstParent(cmp, project, newCommit)) {
            fileCacheKeys.add(createFileDiffCacheKey(project, oldCommit, newCommit, MERGE_LIST, DEFAULT_DIFF_ALGORITHM, /* useTimeout= */
            true, /*whitespace = */
            null));
        }
        if (diffParams.skipFiles() == null) {
            modifiedFiles.stream().map(entity -> createFileDiffCacheKey(project, oldCommit, newCommit, entity.newPath().isPresent() ? entity.newPath().get() : entity.oldPath().get(), DEFAULT_DIFF_ALGORITHM, /* useTimeout= */
            true, /* whitespace= */
            null)).forEach(fileCacheKeys::add);
        }
        return getModifiedFilesForKeys(fileCacheKeys, diffOptions);
    } catch (IOException e) {
        throw new DiffNotAvailableException(e);
    }
}
Also used : Patch(com.google.gerrit.entities.Patch) Module(com.google.inject.Module) ModifiedFilesCache(com.google.gerrit.server.patch.diff.ModifiedFilesCache) Whitespace(com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace) DiffAlgorithm(com.google.gerrit.server.patch.gitfilediff.GitFileDiffCacheImpl.DiffAlgorithm) Inject(com.google.inject.Inject) FileDiffCache(com.google.gerrit.server.patch.filediff.FileDiffCache) MERGE_LIST(com.google.gerrit.entities.Patch.MERGE_LIST) ImmutableCollection(com.google.common.collect.ImmutableCollection) Function(java.util.function.Function) ArrayList(java.util.ArrayList) RevWalk(org.eclipse.jgit.revwalk.RevWalk) Config(org.eclipse.jgit.lib.Config) ChangeType(com.google.gerrit.entities.Patch.ChangeType) ImmutableList(com.google.common.collect.ImmutableList) FileDiffOutput(com.google.gerrit.server.patch.filediff.FileDiffOutput) Map(java.util.Map) ModifiedFilesCacheKey(com.google.gerrit.server.patch.diff.ModifiedFilesCacheKey) GitModifiedFilesCacheImpl(com.google.gerrit.server.patch.gitdiff.GitModifiedFilesCacheImpl) DiffPreferencesInfo(com.google.gerrit.extensions.client.DiffPreferencesInfo) ImmutableMap(com.google.common.collect.ImmutableMap) ModifiedFile(com.google.gerrit.server.patch.gitdiff.ModifiedFile) DisabledOutputStream(org.eclipse.jgit.util.io.DisabledOutputStream) FileDiffCacheKey(com.google.gerrit.server.patch.filediff.FileDiffCacheKey) FileDiffCacheImpl(com.google.gerrit.server.patch.filediff.FileDiffCacheImpl) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) COMMIT_MSG(com.google.gerrit.entities.Patch.COMMIT_MSG) CacheModule(com.google.gerrit.server.cache.CacheModule) GitFileDiffCacheImpl(com.google.gerrit.server.patch.gitfilediff.GitFileDiffCacheImpl) ObjectId(org.eclipse.jgit.lib.ObjectId) List(java.util.List) Nullable(com.google.gerrit.common.Nullable) DiffFormatter(org.eclipse.jgit.diff.DiffFormatter) AutoValue(com.google.auto.value.AutoValue) Project(com.google.gerrit.entities.Project) Optional(java.util.Optional) DiffEntry(org.eclipse.jgit.diff.DiffEntry) ModifiedFilesCacheImpl(com.google.gerrit.server.patch.diff.ModifiedFilesCacheImpl) ObjectReader(org.eclipse.jgit.lib.ObjectReader) FluentLogger(com.google.common.flogger.FluentLogger) Singleton(com.google.inject.Singleton) ObjectId(org.eclipse.jgit.lib.ObjectId) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Project(com.google.gerrit.entities.Project) FileDiffCacheKey(com.google.gerrit.server.patch.filediff.FileDiffCacheKey) ModifiedFile(com.google.gerrit.server.patch.gitdiff.ModifiedFile)

Aggregations

Whitespace (com.google.gerrit.extensions.client.DiffPreferencesInfo.Whitespace)4 ObjectId (org.eclipse.jgit.lib.ObjectId)3 Project (com.google.gerrit.reviewdb.client.Project)2 AutoValue (com.google.auto.value.AutoValue)1 ImmutableCollection (com.google.common.collect.ImmutableCollection)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 FluentLogger (com.google.common.flogger.FluentLogger)1 Nullable (com.google.gerrit.common.Nullable)1 Patch (com.google.gerrit.entities.Patch)1 COMMIT_MSG (com.google.gerrit.entities.Patch.COMMIT_MSG)1 ChangeType (com.google.gerrit.entities.Patch.ChangeType)1 MERGE_LIST (com.google.gerrit.entities.Patch.MERGE_LIST)1 Project (com.google.gerrit.entities.Project)1 DiffPreferencesInfo (com.google.gerrit.extensions.client.DiffPreferencesInfo)1 CacheModule (com.google.gerrit.server.cache.CacheModule)1 ModifiedFilesCache (com.google.gerrit.server.patch.diff.ModifiedFilesCache)1 ModifiedFilesCacheImpl (com.google.gerrit.server.patch.diff.ModifiedFilesCacheImpl)1 ModifiedFilesCacheKey (com.google.gerrit.server.patch.diff.ModifiedFilesCacheKey)1 FileDiffCache (com.google.gerrit.server.patch.filediff.FileDiffCache)1