Remove redundant constructor parameter

The repository can be retrieved from the context and does not have to be
passed through by every constructor
This commit is contained in:
René Pfeuffer
2020-05-12 15:45:58 +02:00
parent d1c6a33c67
commit d5d9690389
80 changed files with 308 additions and 425 deletions

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -44,13 +44,11 @@ public class AbstractSvnCommand
*
*
* @param context
* @param repository
* @param repositoryDirectory
*/
protected AbstractSvnCommand(SvnContext context, Repository repository)
protected AbstractSvnCommand(SvnContext context)
{
this.context = context;
this.repository = repository;
this.repository = context.getRepository();
}
//~--- methods --------------------------------------------------------------

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -37,7 +37,6 @@ import org.tmatesoft.svn.core.wc.SVNRevision;
import sonia.scm.repository.BlameLine;
import sonia.scm.repository.BlameResult;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Repository;
import sonia.scm.repository.SvnBlameHandler;
import sonia.scm.util.Util;
@@ -53,9 +52,9 @@ import java.util.List;
public class SvnBlameCommand extends AbstractSvnCommand implements BlameCommand
{
public SvnBlameCommand(SvnContext context, Repository repository)
public SvnBlameCommand(SvnContext context)
{
super(context, repository);
super(context);
}
@Override

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -37,7 +37,6 @@ import org.tmatesoft.svn.core.SVNProperty;
import org.tmatesoft.svn.core.io.SVNRepository;
import sonia.scm.repository.BrowserResult;
import sonia.scm.repository.FileObject;
import sonia.scm.repository.Repository;
import sonia.scm.repository.SubRepository;
import sonia.scm.repository.SvnUtil;
import sonia.scm.util.Util;
@@ -70,9 +69,9 @@ public class SvnBrowseCommand extends AbstractSvnCommand
private int resultCount = 0;
SvnBrowseCommand(SvnContext context, Repository repository)
SvnBrowseCommand(SvnContext context)
{
super(context, repository);
super(context);
}
@Override

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -32,7 +32,6 @@ import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.admin.SVNAdminClient;
import sonia.scm.repository.Repository;
import sonia.scm.repository.SvnUtil;
import sonia.scm.repository.api.BundleResponse;
@@ -52,9 +51,9 @@ public class SvnBundleCommand extends AbstractSvnCommand
implements BundleCommand
{
public SvnBundleCommand(SvnContext context, Repository repository)
public SvnBundleCommand(SvnContext context)
{
super(context, repository);
super(context);
}
private static void dump(SVNAdminClient adminClient, File repository,

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -35,7 +35,6 @@ import org.tmatesoft.svn.core.io.SVNRepository;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.admin.SVNLookClient;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Repository;
import sonia.scm.repository.SvnUtil;
import java.io.ByteArrayInputStream;
@@ -63,9 +62,9 @@ public class SvnCatCommand extends AbstractSvnCommand implements CatCommand
//~--- constructors ---------------------------------------------------------
SvnCatCommand(SvnContext context, Repository repository)
SvnCatCommand(SvnContext context)
{
super(context, repository);
super(context);
}
//~--- get methods ----------------------------------------------------------

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -37,7 +37,6 @@ import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNDiffClient;
import org.tmatesoft.svn.core.wc.SVNRevision;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Repository;
import sonia.scm.repository.SvnUtil;
import sonia.scm.repository.api.DiffCommandBuilder;
import sonia.scm.repository.api.DiffFormat;
@@ -57,8 +56,8 @@ public class SvnDiffCommand extends AbstractSvnCommand implements DiffCommand {
private static final Logger logger =
LoggerFactory.getLogger(SvnDiffCommand.class);
public SvnDiffCommand(SvnContext context, Repository repository) {
super(context, repository);
public SvnDiffCommand(SvnContext context) {
super(context);
}
@Override

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -37,7 +37,6 @@ import org.tmatesoft.svn.core.io.SVNRepository;
import sonia.scm.repository.Changeset;
import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Repository;
import sonia.scm.repository.SvnUtil;
import sonia.scm.util.Util;
@@ -57,9 +56,9 @@ public class SvnLogCommand extends AbstractSvnCommand implements LogCommand
private static final Logger logger =
LoggerFactory.getLogger(SvnLogCommand.class);
SvnLogCommand(SvnContext context, Repository repository)
SvnLogCommand(SvnContext context)
{
super(context, repository);
super(context);
}
//~--- get methods ----------------------------------------------------------

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import lombok.extern.slf4j.Slf4j;
@@ -32,7 +32,6 @@ import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.admin.SVNLookClient;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Modifications;
import sonia.scm.repository.Repository;
import sonia.scm.repository.SvnUtil;
import sonia.scm.util.Util;
@@ -41,8 +40,8 @@ import java.util.Collection;
@Slf4j
public class SvnModificationsCommand extends AbstractSvnCommand implements ModificationsCommand {
SvnModificationsCommand(SvnContext context, Repository repository) {
super(context, repository);
SvnModificationsCommand(SvnContext context) {
super(context);
}
@Override

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.apache.shiro.SecurityUtils;
@@ -46,9 +46,9 @@ public class SvnModifyCommand implements ModifyCommand {
private SvnWorkDirFactory workDirFactory;
private Repository repository;
SvnModifyCommand(SvnContext context, Repository repository, SvnWorkDirFactory workDirFactory) {
SvnModifyCommand(SvnContext context, SvnWorkDirFactory workDirFactory) {
this.context = context;
this.repository = repository;
this.repository = context.getRepository();
this.workDirFactory = workDirFactory;
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import com.google.common.collect.ImmutableSet;
@@ -45,7 +45,7 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
/** Field description */
//J-
public static final Set<Command> COMMANDS = ImmutableSet.of(
Command.BLAME, Command.BROWSE, Command.CAT, Command.DIFF,
Command.BLAME, Command.BROWSE, Command.CAT, Command.DIFF,
Command.LOG, Command.BUNDLE, Command.UNBUNDLE, Command.MODIFY
);
//J+
@@ -56,7 +56,6 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
SvnRepositoryServiceProvider(SvnRepositoryHandler handler,
Repository repository, SvnWorkDirFactory workdirFactory)
{
this.repository = repository;
this.context = new SvnContext(repository, handler.getDirectory(repository.getId()));
this.workDirFactory = workdirFactory;
}
@@ -86,7 +85,7 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public SvnBlameCommand getBlameCommand()
{
return new SvnBlameCommand(context, repository);
return new SvnBlameCommand(context);
}
/**
@@ -98,7 +97,7 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public SvnBrowseCommand getBrowseCommand()
{
return new SvnBrowseCommand(context, repository);
return new SvnBrowseCommand(context);
}
/**
@@ -110,7 +109,7 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public BundleCommand getBundleCommand()
{
return new SvnBundleCommand(context, repository);
return new SvnBundleCommand(context);
}
/**
@@ -122,7 +121,7 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public SvnCatCommand getCatCommand()
{
return new SvnCatCommand(context, repository);
return new SvnCatCommand(context);
}
/**
@@ -134,7 +133,7 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public SvnDiffCommand getDiffCommand()
{
return new SvnDiffCommand(context, repository);
return new SvnDiffCommand(context);
}
/**
@@ -146,15 +145,15 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public SvnLogCommand getLogCommand()
{
return new SvnLogCommand(context, repository);
return new SvnLogCommand(context);
}
public ModificationsCommand getModificationsCommand() {
return new SvnModificationsCommand(context, repository);
return new SvnModificationsCommand(context);
}
public ModifyCommand getModifyCommand() {
return new SvnModifyCommand(context, repository, workDirFactory);
return new SvnModifyCommand(context, workDirFactory);
}
/**
@@ -178,7 +177,7 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public UnbundleCommand getUnbundleCommand()
{
return new SvnUnbundleCommand(context, repository);
return new SvnUnbundleCommand(context);
}
//~--- fields ---------------------------------------------------------------
@@ -186,8 +185,5 @@ public class SvnRepositoryServiceProvider extends RepositoryServiceProvider
/** Field description */
private final SvnContext context;
/** Field description */
private final Repository repository;
private final SvnWorkDirFactory workDirFactory;
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -36,7 +36,6 @@ import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.admin.SVNAdminClient;
import sonia.scm.repository.Repository;
import sonia.scm.repository.SvnUtil;
import sonia.scm.repository.api.UnbundleResponse;
@@ -65,13 +64,12 @@ public class SvnUnbundleCommand extends AbstractSvnCommand
/**
* Constructs ...
*
* @param context
*
* @param context
* @param repository
*/
public SvnUnbundleCommand(SvnContext context, Repository repository)
public SvnUnbundleCommand(SvnContext context)
{
super(context, repository);
super(context);
}
//~--- methods --------------------------------------------------------------

View File

@@ -110,6 +110,6 @@ public class SvnBlameCommandTest extends AbstractSvnCommandTestBase
*/
private SvnBlameCommand createCommand()
{
return new SvnBlameCommand(createContext(), repository);
return new SvnBlameCommand(createContext());
}
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.junit.Test;
@@ -268,7 +268,7 @@ public class SvnBrowseCommandTest extends AbstractSvnCommandTestBase
*/
private SvnBrowseCommand createCommand()
{
return new SvnBrowseCommand(createContext(), repository);
return new SvnBrowseCommand(createContext());
}
//~--- get methods ----------------------------------------------------------

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -57,8 +57,7 @@ public class SvnBundleCommandTest extends AbstractSvnCommandTestBase
File file = temp.newFile();
ByteSink sink = Files.asByteSink(file);
BundleCommandRequest req = new BundleCommandRequest(sink);
BundleResponse res = new SvnBundleCommand(createContext(),
repository).bundle(req);
BundleResponse res = new SvnBundleCommand(createContext()).bundle(req);
assertThat(res, notNullValue());
assertThat(res.getChangesetCount(), is(5l));

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.hamcrest.BaseMatcher;
@@ -111,7 +111,7 @@ public class SvnCatCommandTest extends AbstractSvnCommandTestBase {
request.setPath("a.txt");
request.setRevision("1");
InputStream catResultStream = new SvnCatCommand(createContext(), repository).getCatResultStream(request);
InputStream catResultStream = new SvnCatCommand(createContext()).getCatResultStream(request);
assertEquals('a', catResultStream.read());
assertEquals('\n', catResultStream.read());
@@ -126,8 +126,7 @@ public class SvnCatCommandTest extends AbstractSvnCommandTestBase {
try
{
new SvnCatCommand(createContext(), repository).getCatResult(request,
baos);
new SvnCatCommand(createContext()).getCatResult(request, baos);
}
finally
{

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -136,7 +136,7 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
checkDate(c.getDate());
assertEquals("perfect", c.getAuthor().getName());
assertNull("douglas.adams@hitchhiker.com", c.getAuthor().getMail());
SvnModificationsCommand modificationsCommand = new SvnModificationsCommand(createContext(), repository);
SvnModificationsCommand modificationsCommand = new SvnModificationsCommand(createContext());
Modifications modifications = modificationsCommand.getModifications("3");
assertNotNull(modifications);
@@ -177,6 +177,6 @@ public class SvnLogCommandTest extends AbstractSvnCommandTestBase
*/
private SvnLogCommand createCommand()
{
return new SvnLogCommand(createContext(), repository);
return new SvnLogCommand(createContext());
}
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.apache.shiro.subject.Subject;
@@ -57,7 +57,7 @@ public class SvnModifyCommandTest extends AbstractSvnCommandTestBase {
public void initSvnModifyCommand() {
context = createContext();
workDirFactory = new SimpleSvnWorkDirFactory(new WorkdirProvider(context.getDirectory()));
svnModifyCommand = new SvnModifyCommand(context, createRepository(), workDirFactory);
svnModifyCommand = new SvnModifyCommand(context, workDirFactory);
}
@Before

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -57,13 +57,8 @@ public class SvnUnbundleCommandTest extends AbstractSvnCommandTestBase
File bundle = bundle();
SvnContext ctx = createEmptyContext();
//J-
UnbundleResponse res = new SvnUnbundleCommand(
ctx,
repository
).unbundle(
new UnbundleCommandRequest(
Files.asByteSource(bundle)
)
UnbundleResponse res = new SvnUnbundleCommand(ctx)
.unbundle(new UnbundleCommandRequest(Files.asByteSource(bundle))
);
//J+
@@ -81,13 +76,8 @@ public class SvnUnbundleCommandTest extends AbstractSvnCommandTestBase
File file = tempFolder.newFile();
//J-
new SvnBundleCommand(
createContext(),
repository
).bundle(
new BundleCommandRequest(
Files.asByteSink(file)
)
new SvnBundleCommand(createContext())
.bundle(new BundleCommandRequest(Files.asByteSink(file))
);
//J+