Skip to content

Commit b621a7e

Browse files
committed
[SCM-1011] Consider interactive flag for SvnExeScmProvider
1 parent de504e3 commit b621a7e

File tree

11 files changed

+88
-17
lines changed

11 files changed

+88
-17
lines changed

maven-scm-api/src/main/java/org/apache/maven/scm/provider/ScmProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ ScmProviderRepository makeProviderScmRepository(File path)
7070
throws ScmRepositoryException, UnknownRepositoryStructure;
7171

7272
/**
73-
* Sets the interactive mode.
73+
* Sets the interactive mode, which by default (i.e. if not called) is assumed to be true by providers.
7474
*
75-
* @param interactive either {@code true} in case user may be prompted for information, otherwise {@code false}
75+
* @param interactive either {@code true} in case user may be prompted for information, otherwise {@code false}.
7676
* @since 2.0.0-M2
7777
*/
7878
default void setInteractive(boolean interactive) {}

maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<groupId>org.codehaus.modello</groupId>
6060
<artifactId>modello-maven-plugin</artifactId>
6161
<configuration>
62-
<version>1.1.0</version>
62+
<version>2.1.0</version>
6363
<models>
6464
<model>src/main/mdo/svn-settings.mdo</model>
6565
</models>

maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/mdo/svn-settings.mdo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<type>boolean</type>
7171
<defaultValue>true</defaultValue>
7272
<description><![CDATA[
73-
Switch off if you do not like to use <code>--non-interactive</code> e.g. on Leopard (see SCM-402).
73+
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.
7474
]]></description>
7575
</field>
7676
<field>

maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/SvnExeScmProvider.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@
5656
@Singleton
5757
@Named("svn")
5858
public class SvnExeScmProvider extends AbstractSvnScmProvider {
59+
private boolean interactive;
60+
61+
@Override
62+
public void setInteractive(boolean interactive) {
63+
this.interactive = interactive;
64+
}
65+
5966
/**
6067
* {@inheritDoc}
6168
*/
@@ -85,15 +92,15 @@ protected SvnCommand getChangeLogCommand() {
8592
*/
8693
@Override
8794
protected SvnCommand getCheckInCommand() {
88-
return new SvnCheckInCommand();
95+
return new SvnCheckInCommand(interactive);
8996
}
9097

9198
/**
9299
* {@inheritDoc}
93100
*/
94101
@Override
95102
protected SvnCommand getCheckOutCommand() {
96-
return new SvnCheckOutCommand();
103+
return new SvnCheckOutCommand(interactive);
97104
}
98105

99106
/**
@@ -149,7 +156,7 @@ protected SvnCommand getUntagCommand() {
149156
*/
150157
@Override
151158
protected SvnCommand getUpdateCommand() {
152-
return new SvnUpdateCommand();
159+
return new SvnUpdateCommand(interactive);
153160
}
154161

155162
/**

maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/SvnCommandLineUtils.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,21 @@ public static void addTarget(Commandline cl, List<File> files) throws IOExceptio
7171
targets.deleteOnExit();
7272
}
7373

74+
/**
75+
* Shortcut for {@link #getBaseSvnCommandLine(File, SvnScmProviderRepository, boolean)} with the last argument being {@code false}.
76+
* Although usually the interactive mode defaults to {@code true} the SVN provider always assumed non-interactive in the past.
77+
* @param workingDirectory
78+
* @param repository
79+
* @return
80+
* @deprecated Use {@link #getBaseSvnCommandLine(File, SvnScmProviderRepository, boolean)} instead
81+
*/
82+
@Deprecated
7483
public static Commandline getBaseSvnCommandLine(File workingDirectory, SvnScmProviderRepository repository) {
84+
return getBaseSvnCommandLine(workingDirectory, repository, false);
85+
}
86+
87+
public static Commandline getBaseSvnCommandLine(
88+
File workingDirectory, SvnScmProviderRepository repository, boolean interactive) {
7589
Commandline cl = new Commandline();
7690

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

115-
if (SvnUtil.getSettings().isUseNonInteractive()) {
129+
if (!interactive && SvnUtil.getSettings().isUseNonInteractive()) {
116130
cl.createArg().setValue("--non-interactive");
117131
}
118132

maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInCommand.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
*
4444
*/
4545
public class SvnCheckInCommand extends AbstractCheckInCommand implements SvnCommand {
46+
private final boolean interactive;
47+
48+
public SvnCheckInCommand(boolean interactive) {
49+
this.interactive = interactive;
50+
}
51+
4652
/** {@inheritDoc} */
4753
protected CheckInScmResult executeCheckInCommand(
4854
ScmProviderRepository repo, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException {
@@ -104,7 +110,13 @@ protected CheckInScmResult executeCheckInCommand(
104110

105111
public static Commandline createCommandLine(
106112
SvnScmProviderRepository repository, ScmFileSet fileSet, File messageFile) throws ScmException {
107-
Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(fileSet.getBasedir(), repository);
113+
return createCommandLine(repository, fileSet, messageFile, true);
114+
}
115+
116+
public static Commandline createCommandLine(
117+
SvnScmProviderRepository repository, ScmFileSet fileSet, File messageFile, boolean interactive)
118+
throws ScmException {
119+
Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(fileSet.getBasedir(), repository, interactive);
108120

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

maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutCommand.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
*
4747
*/
4848
public class SvnCheckOutCommand extends AbstractCheckOutCommand implements SvnCommand {
49+
private final boolean interactive;
50+
51+
public SvnCheckOutCommand(boolean interactive) {
52+
this.interactive = interactive;
53+
}
54+
4955
/**
5056
* {@inheritDoc}
5157
*/
@@ -66,7 +72,7 @@ protected CheckOutScmResult executeCheckOutCommand(
6672

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

69-
Commandline cl = createCommandLine(repository, fileSet.getBasedir(), version, url, recursive);
75+
Commandline cl = createCommandLine(repository, fileSet.getBasedir(), version, url, recursive, interactive);
7076

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

@@ -132,7 +138,29 @@ public static Commandline createCommandLine(
132138
ScmVersion version,
133139
String url,
134140
boolean recursive) {
135-
Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory.getParentFile(), repository);
141+
return createCommandLine(repository, workingDirectory, version, url, recursive, true);
142+
}
143+
/**
144+
* Create SVN check out command line.
145+
*
146+
* @param repository not null
147+
* @param workingDirectory not null
148+
* @param version not null
149+
* @param url not null
150+
* @param recursive <code>true</code> if recursive check out is wanted, <code>false</code> otherwise.
151+
* @param interactive <code>true</code> if executed in interactive mode, <code>false</code> otherwise.
152+
* @return the SVN command line for the SVN check out.
153+
* @since 2.1.0
154+
*/
155+
public static Commandline createCommandLine(
156+
SvnScmProviderRepository repository,
157+
File workingDirectory,
158+
ScmVersion version,
159+
String url,
160+
boolean recursive,
161+
boolean interactive) {
162+
Commandline cl =
163+
SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory.getParentFile(), repository, interactive);
136164

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

maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommand.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848
*
4949
*/
5050
public class SvnUpdateCommand extends AbstractUpdateCommand implements SvnCommand {
51+
private final boolean interactive;
52+
53+
public SvnUpdateCommand(boolean interactive) {
54+
this.interactive = interactive;
55+
}
56+
5157
/** {@inheritDoc} */
5258
protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion version)
5359
throws ScmException {
@@ -92,9 +98,13 @@ protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repo, ScmFi
9298
// ----------------------------------------------------------------------
9399
//
94100
// ----------------------------------------------------------------------
95-
96101
public static Commandline createCommandLine(
97102
SvnScmProviderRepository repository, File workingDirectory, ScmVersion version) {
103+
return createCommandLine(repository, workingDirectory, version, true);
104+
}
105+
106+
public static Commandline createCommandLine(
107+
SvnScmProviderRepository repository, File workingDirectory, ScmVersion version, boolean interactive) {
98108
Settings settings = SvnUtil.getSettings();
99109

100110
String workingDir = workingDirectory.getAbsolutePath();
@@ -109,7 +119,7 @@ public static Commandline createCommandLine(
109119
version = null;
110120
}
111121

112-
Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository);
122+
Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository, interactive);
113123

114124
if (version == null || SvnTagBranchUtils.isRevisionSpecifier(version)) {
115125
cl.createArg().setValue("update");

maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkin/SvnCheckInCommandTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ private void testCommandLine(String scmUrl, String commandLine) throws Exception
100100

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

103-
Commandline cl =
104-
SvnCheckInCommand.createCommandLine(svnRepository, new ScmFileSet(workingDirectory), messageFile);
103+
Commandline cl = SvnCheckInCommand.createCommandLine(
104+
svnRepository, new ScmFileSet(workingDirectory), messageFile, false);
105105

106106
assertCommandLine(commandLine, workingDirectory, cl);
107107
}

maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/checkout/SvnCheckOutCommandTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ private void testCommandLine(ScmManager scmManager, String scmUrl, String revisi
108108
SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
109109

110110
Commandline cl = SvnCheckOutCommand.createCommandLine(
111-
svnRepository, workingDirectory, new ScmRevision(revision), svnRepository.getUrl(), recursive);
111+
svnRepository, workingDirectory, new ScmRevision(revision), svnRepository.getUrl(), recursive, false);
112112

113113
assertCommandLine(commandLine, workingDirectory.getParentFile(), cl);
114114
}

maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/update/SvnUpdateCommandTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ private void testCommandLine(String scmUrl, ScmVersion version, String commandLi
197197

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

202202
assertCommandLine(commandLine, workingDirectory, cl);
203203
}

0 commit comments

Comments
 (0)