Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCM-1011] Consider interactive flag for SvnExeScmProvider #181

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ ScmProviderRepository makeProviderScmRepository(File path)
throws ScmRepositoryException, UnknownRepositoryStructure;

/**
* Sets the interactive mode.
* Sets the interactive mode, which by default (i.e. if not called) is assumed to be {@code true} by providers.
* As providers are usually singletons, this affects every usage of this provider.
*
* @param interactive either {@code true} in case user may be prompted for information, otherwise {@code false}
* @since 2.0.0-M2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
<configuration>
<version>1.1.0</version>
<version>2.1.0</version>
<models>
<model>src/main/mdo/svn-settings.mdo</model>
</models>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<type>boolean</type>
<defaultValue>true</defaultValue>
<description><![CDATA[
Switch off if you do not like to use <code>--non-interactive</code> e.g. on Leopard (see SCM-402).
Switch off if you do not like to use <code>--non-interactive</code> e.g. on Leopard (see SCM-402) when used with non-interactive SVN provider.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can safely drop "e.g. on Leopard (see SCM-402)"

]]></description>
</field>
<field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@
@Singleton
@Named("svn")
public class SvnExeScmProvider extends AbstractSvnScmProvider {
private boolean interactive;

@Override
public void setInteractive(boolean interactive) {
this.interactive = interactive;
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -85,15 +92,15 @@ protected SvnCommand getChangeLogCommand() {
*/
@Override
protected SvnCommand getCheckInCommand() {
return new SvnCheckInCommand();
return new SvnCheckInCommand(interactive);
}

/**
* {@inheritDoc}
*/
@Override
protected SvnCommand getCheckOutCommand() {
return new SvnCheckOutCommand();
return new SvnCheckOutCommand(interactive);
}

/**
Expand Down Expand Up @@ -149,7 +156,7 @@ protected SvnCommand getUntagCommand() {
*/
@Override
protected SvnCommand getUpdateCommand() {
return new SvnUpdateCommand();
return new SvnUpdateCommand(interactive);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,21 @@ public static void addTarget(Commandline cl, List<File> files) throws IOExceptio
targets.deleteOnExit();
}

/**
* Shortcut for {@link #getBaseSvnCommandLine(File, SvnScmProviderRepository, boolean)} with the last argument being {@code false}.
* Although usually the interactive mode defaults to {@code true} the SVN provider always assumed non-interactive in the past.
* @param workingDirectory
* @param repository
* @return
* @deprecated Use {@link #getBaseSvnCommandLine(File, SvnScmProviderRepository, boolean)} instead
*/
@Deprecated
public static Commandline getBaseSvnCommandLine(File workingDirectory, SvnScmProviderRepository repository) {
return getBaseSvnCommandLine(workingDirectory, repository, false);
}

public static Commandline getBaseSvnCommandLine(
File workingDirectory, SvnScmProviderRepository repository, boolean interactive) {
Commandline cl = new Commandline();

cl.setExecutable("svn");
Expand Down Expand Up @@ -112,7 +126,7 @@ public static Commandline getBaseSvnCommandLine(File workingDirectory, SvnScmPro
cl.createArg().setValue("--no-auth-cache");
}

if (SvnUtil.getSettings().isUseNonInteractive()) {
if (!interactive && SvnUtil.getSettings().isUseNonInteractive()) {
cl.createArg().setValue("--non-interactive");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
*
*/
public class SvnCheckInCommand extends AbstractCheckInCommand implements SvnCommand {
private final boolean interactive;

public SvnCheckInCommand(boolean interactive) {
this.interactive = interactive;
}

/** {@inheritDoc} */
protected CheckInScmResult executeCheckInCommand(
ScmProviderRepository repo, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException {
Expand Down Expand Up @@ -104,7 +110,13 @@ protected CheckInScmResult executeCheckInCommand(

public static Commandline createCommandLine(
kwin marked this conversation as resolved.
Show resolved Hide resolved
SvnScmProviderRepository repository, ScmFileSet fileSet, File messageFile) throws ScmException {
Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(fileSet.getBasedir(), repository);
return createCommandLine(repository, fileSet, messageFile, true);
}

public static Commandline createCommandLine(
SvnScmProviderRepository repository, ScmFileSet fileSet, File messageFile, boolean interactive)
throws ScmException {
Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(fileSet.getBasedir(), repository, interactive);

cl.createArg().setValue("commit");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
*
*/
public class SvnCheckOutCommand extends AbstractCheckOutCommand implements SvnCommand {
private final boolean interactive;

public SvnCheckOutCommand(boolean interactive) {
this.interactive = interactive;
}

/**
* {@inheritDoc}
*/
Expand All @@ -66,7 +72,7 @@ protected CheckOutScmResult executeCheckOutCommand(

url = SvnCommandUtils.fixUrl(url, repository.getUser());

Commandline cl = createCommandLine(repository, fileSet.getBasedir(), version, url, recursive);
Commandline cl = createCommandLine(repository, fileSet.getBasedir(), version, url, recursive, interactive);

SvnCheckOutConsumer consumer = new SvnCheckOutConsumer(fileSet.getBasedir());

Expand Down Expand Up @@ -132,7 +138,29 @@ public static Commandline createCommandLine(
ScmVersion version,
String url,
boolean recursive) {
Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory.getParentFile(), repository);
return createCommandLine(repository, workingDirectory, version, url, recursive, true);
}
/**
* Create SVN check out command line.
*
* @param repository not null
* @param workingDirectory not null
* @param version not null
* @param url not null
* @param recursive <code>true</code> if recursive check out is wanted, <code>false</code> otherwise.
* @param interactive <code>true</code> if executed in interactive mode, <code>false</code> otherwise.
* @return the SVN command line for the SVN check out.
* @since 2.1.0
*/
public static Commandline createCommandLine(
SvnScmProviderRepository repository,
File workingDirectory,
ScmVersion version,
String url,
boolean recursive,
boolean interactive) {
Commandline cl =
SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory.getParentFile(), repository, interactive);

cl.createArg().setValue("checkout");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
*
*/
public class SvnUpdateCommand extends AbstractUpdateCommand implements SvnCommand {
private final boolean interactive;

public SvnUpdateCommand(boolean interactive) {
this.interactive = interactive;
}

/** {@inheritDoc} */
protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version)
throws ScmException {
Expand Down Expand Up @@ -92,9 +98,13 @@ protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repo, ScmFi
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------

public static Commandline createCommandLine(
SvnScmProviderRepository repository, File workingDirectory, ScmVersion version) {
return createCommandLine(repository, workingDirectory, version, true);
}

public static Commandline createCommandLine(
SvnScmProviderRepository repository, File workingDirectory, ScmVersion version, boolean interactive) {
Settings settings = SvnUtil.getSettings();

String workingDir = workingDirectory.getAbsolutePath();
Expand All @@ -109,7 +119,7 @@ public static Commandline createCommandLine(
version = null;
}

Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository);
Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository, interactive);

if (version == null || SvnTagBranchUtils.isRevisionSpecifier(version)) {
cl.createArg().setValue("update");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ private void testCommandLine(String scmUrl, String commandLine) throws Exception

SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();

Commandline cl =
SvnCheckInCommand.createCommandLine(svnRepository, new ScmFileSet(workingDirectory), messageFile);
Commandline cl = SvnCheckInCommand.createCommandLine(
svnRepository, new ScmFileSet(workingDirectory), messageFile, false);

assertCommandLine(commandLine, workingDirectory, cl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private void testCommandLine(ScmManager scmManager, String scmUrl, String revisi
SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();

Commandline cl = SvnCheckOutCommand.createCommandLine(
svnRepository, workingDirectory, new ScmRevision(revision), svnRepository.getUrl(), recursive);
svnRepository, workingDirectory, new ScmRevision(revision), svnRepository.getUrl(), recursive, false);

assertCommandLine(commandLine, workingDirectory.getParentFile(), cl);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ private void testCommandLine(String scmUrl, ScmVersion version, String commandLi

private void testCommandLine(String scmUrl, ScmVersion version, String commandLine, File workingDirectory)
throws Exception {
Commandline cl = SvnUpdateCommand.createCommandLine(getSvnRepository(scmUrl), workingDirectory, version);
Commandline cl = SvnUpdateCommand.createCommandLine(getSvnRepository(scmUrl), workingDirectory, version, false);

assertCommandLine(commandLine, workingDirectory, cl);
}
Expand Down