Mercurial > hg > mercurial
view mercurial-common/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/command/CommandSettings.java @ 883:39ff04730ccc
Report more vcs operation progress
Instead of setting progress in each operation, create HgRepo via
OpeationContext which adds progress to command settings.
author | Dmitry Neverov <dmitry.neverov@jetbrains.com> |
---|---|
date | Sun, 05 Oct 2014 11:15:34 +0200 |
parents | d746a9351572 |
children | 7bf4d943d5bb 0c6b0b5f68ea |
line wrap: on
line source
/* * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jetbrains.buildServer.buildTriggers.vcs.mercurial.command; import jetbrains.buildServer.buildTriggers.vcs.mercurial.MercurialProgress; import jetbrains.buildServer.buildTriggers.vcs.mercurial.OS; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.*; /** * @author dmitry.neverov */ public class CommandSettings { private int myTimeout = 3600; private final Set<String> myPrivateData = new HashSet<String>(); private boolean myCheckForFailure = true; private boolean myFailWhenStderrNotEmpty = false; private String myLogLevel = "debug"; private Map<String, String> myHgEnv = new HashMap<String, String>(); private int myLogOutputLimit = -1; private int myExceptionOutputLimit = 5000; private List<String> myGlobalArguments = new ArrayList<String>(0); private boolean myUseCommandlineViaFileWrapper = false; private MercurialProgress myProgress = MercurialProgress.NO_OP; public final int getMaxCommandLineSize() { return myUseCommandlineViaFileWrapper ? Integer.MAX_VALUE : OS.getMaxCommandLineSize(); } public boolean getUseCommandlineViaFileWrapper() { return myUseCommandlineViaFileWrapper; } @NotNull public CommandSettings setUseCommandlineViaFileWrapper(final boolean useCommandlineViaFileWrapper) { myUseCommandlineViaFileWrapper = useCommandlineViaFileWrapper; return this; } public CommandSettings setTimeout(int timeout) { myTimeout = timeout; return this; } @NotNull public List<String> getGlobalArguments() { return myGlobalArguments; } @NotNull public CommandSettings withGlobalArguments(@NotNull String... argz) { myGlobalArguments.addAll(Arrays.asList(argz)); return this; } public int getTimeout() { return myTimeout; } public CommandSettings setPrivateData(@NotNull Set<String> privateData) { myPrivateData.addAll(privateData); return this; } @NotNull public Set<String> getPrivateData() { return myPrivateData; } public CommandSettings setCheckForFailure(boolean checkForFailure) { myCheckForFailure = checkForFailure; return this; } public boolean isCheckForFailure() { return myCheckForFailure; } public CommandSettings setFailWhenStderrNotEmpty(boolean failWhenStderrNotEmpty) { myFailWhenStderrNotEmpty = failWhenStderrNotEmpty; return this; } public boolean isFailWithNonEmptyStderr() { return myFailWhenStderrNotEmpty; } public CommandSettings setLogLevel(String logLevel) { myLogLevel = logLevel; return this; } public String getLogLevel() { return myLogLevel; } public CommandSettings addHgEnv(@NotNull String param, @NotNull String value) { myHgEnv.put(param, value); return this; } public Map<String, String> getHgEnv() { return myHgEnv; } public int getLogOutputLimit() { return myLogOutputLimit; } public CommandSettings setLogOutputLimit(int logOutputLimit) { myLogOutputLimit = logOutputLimit; return this; } public int getExceptionOutputLimit() { return myExceptionOutputLimit; } public void setExceptionOutputLimit(int limit) { myExceptionOutputLimit = limit; } @Nullable public ProgressParser.ProgressConsumer getProgressConsumer() { if (myProgress == MercurialProgress.NO_OP) return null; return new ProgressParser.ProgressConsumer() { public void consume(float progress, @NotNull String stage) { myProgress.reportProgress(progress, stage); } }; } @NotNull public MercurialProgress getProgress() { return myProgress; } public void setProgress(@NotNull MercurialProgress progress) { myProgress = progress; } }