From 2a5fbeddf0768a8de8a4ab0bf34bba331bbaf484 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Fri, 29 Apr 2011 14:47:38 +0200 Subject: [PATCH] improve svn compatibility modus --- .../sonia/scm/repository/Compatibility.java | 105 ++++++++++++++++++ .../java/sonia/scm/repository/SvnConfig.java | 65 ++--------- .../scm/repository/SvnRepositoryHandler.java | 12 +- .../main/resources/sonia/scm/svn.config.js | 38 ++++--- 4 files changed, 143 insertions(+), 77 deletions(-) create mode 100644 plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/Compatibility.java diff --git a/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/Compatibility.java b/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/Compatibility.java new file mode 100644 index 0000000000..3ff8438725 --- /dev/null +++ b/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/Compatibility.java @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2010, Sebastian Sdorra + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * 3. Neither the name of SCM-Manager; nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * http://bitbucket.org/sdorra/scm-manager + * + */ + + + +package sonia.scm.repository; + +/** + * + * @author Sebastian Sdorra + */ +public enum Compatibility +{ + NONE(false, false, false), PRE14(true, true, true), PRE15(false, true, true), + PRE16(false, false, true); + + /** + * Field description + * + * @param pre14Compatible + * @param pre15Compatible + * @param pre16Compatible + */ + private Compatibility(boolean pre14Compatible, boolean pre15Compatible, + boolean pre16Compatible) + { + this.pre14Compatible = pre14Compatible; + this.pre15Compatible = pre15Compatible; + this.pre16Compatible = pre16Compatible; + } + + //~--- get methods ---------------------------------------------------------- + + /** + * Method description + * + * + * @return + */ + public boolean isPre14Compatible() + { + return pre14Compatible; + } + + /** + * Method description + * + * + * @return + */ + public boolean isPre15Compatible() + { + return pre15Compatible; + } + + /** + * Method description + * + * + * @return + */ + public boolean isPre16Compatible() + { + return pre16Compatible; + } + + //~--- fields --------------------------------------------------------------- + + /** Field description */ + private boolean pre14Compatible; + + /** Field description */ + private boolean pre15Compatible; + + /** Field description */ + private boolean pre16Compatible; +} diff --git a/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/SvnConfig.java b/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/SvnConfig.java index ace2cb3689..c8d65deed5 100644 --- a/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/SvnConfig.java +++ b/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/SvnConfig.java @@ -51,31 +51,14 @@ public class SvnConfig extends SimpleRepositoryConfig * * @return */ - public boolean isPre14Compatible() + public Compatibility getCompatibility() { - return pre14Compatible; - } + if (compatibility == null) + { + compatibility = Compatibility.NONE; + } - /** - * Method description - * - * - * @return - */ - public boolean isPre15Compatible() - { - return pre15Compatible; - } - - /** - * Method description - * - * - * @return - */ - public boolean isPre16Compatible() - { - return pre16Compatible; + return compatibility; } //~--- set methods ---------------------------------------------------------- @@ -84,43 +67,15 @@ public class SvnConfig extends SimpleRepositoryConfig * Method description * * - * @param pre14Compatible + * @param compatibility */ - public void setPre14Compatible(boolean pre14Compatible) + public void setCompatibility(Compatibility compatibility) { - this.pre14Compatible = pre14Compatible; - } - - /** - * Method description - * - * - * @param pre15Compatible - */ - public void setPre15Compatible(boolean pre15Compatible) - { - this.pre15Compatible = pre15Compatible; - } - - /** - * Method description - * - * - * @param pre16Compatible - */ - public void setPre16Compatible(boolean pre16Compatible) - { - this.pre16Compatible = pre16Compatible; + this.compatibility = compatibility; } //~--- fields --------------------------------------------------------------- /** Field description */ - private boolean pre14Compatible = false; - - /** Field description */ - private boolean pre15Compatible = false; - - /** Field description */ - private boolean pre16Compatible = false; + private Compatibility compatibility = Compatibility.NONE; } diff --git a/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/SvnRepositoryHandler.java b/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/SvnRepositoryHandler.java index b5f62c9928..182a0b951b 100644 --- a/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/SvnRepositoryHandler.java +++ b/plugins/scm-svn-plugin/src/main/java/sonia/scm/repository/SvnRepositoryHandler.java @@ -154,22 +154,24 @@ public class SvnRepositoryHandler protected void create(Repository repository, File directory) throws RepositoryException, IOException { + Compatibility comp = config.getCompatibility(); + if (logger.isDebugEnabled()) { StringBuilder log = new StringBuilder("create svn repository \""); log.append(directory.getName()).append("\": pre14Compatible="); - log.append(config.isPre14Compatible()).append(", pre15Compatible="); - log.append(config.isPre15Compatible()).append(", pre16Compatible="); - log.append(config.isPre16Compatible()); + log.append(comp.isPre14Compatible()).append(", pre15Compatible="); + log.append(comp.isPre15Compatible()).append(", pre16Compatible="); + log.append(comp.isPre16Compatible()); logger.debug(log.toString()); } try { SVNRepositoryFactory.createLocalRepository(directory, null, true, false, - config.isPre14Compatible(), config.isPre15Compatible(), - config.isPre16Compatible()); + comp.isPre14Compatible(), comp.isPre15Compatible(), + comp.isPre16Compatible()); } catch (SVNException ex) { diff --git a/plugins/scm-svn-plugin/src/main/resources/sonia/scm/svn.config.js b/plugins/scm-svn-plugin/src/main/resources/sonia/scm/svn.config.js index 9914de34b2..c599c65e22 100644 --- a/plugins/scm-svn-plugin/src/main/resources/sonia/scm/svn.config.js +++ b/plugins/scm-svn-plugin/src/main/resources/sonia/scm/svn.config.js @@ -37,6 +37,7 @@ Sonia.svn.ConfigPanel = Ext.extend(Sonia.config.SimpleConfigForm, { titleText: 'Subversion Settings', repositoryDirectoryText: 'Repository directory', // TODO i18n + noneCompatibility: 'No compatibility modus', pre14CompatibleText: 'Pre 1.4 Compatible', pre15CompatibleText: 'Pre 1.5 Compatible', pre16CompatibleText: 'Pre 1.6 Compatible', @@ -60,23 +61,26 @@ Sonia.svn.ConfigPanel = Ext.extend(Sonia.config.SimpleConfigForm, { helpText: this.repositoryDirectoryHelpText, allowBlank : false },{ - xtype: 'checkbox', - name: 'pre14Compatible', - fieldLabel: this.pre14CompatibleText, - helpText: this.pre14CompatibleHelpText, - inputValue: 'true' - },{ - xtype: 'checkbox', - name: 'pre15Compatible', - fieldLabel: this.pre15CompatibleText, - helpText: this.pre15CompatibleHelpText, - inputValue: 'true' - },{ - xtype: 'checkbox', - name: 'pre16Compatible', - fieldLabel: this.pre16CompatibleText, - helpText: this.pre16CompatibleHelpText, - inputValue: 'true' + xtype: 'radiogroup', + name: 'compatibility', + columns: 1, + items: [{ + boxLabel: this.noneCompatibility, + inputValue: 'NONE', + name: 'compatibility' + },{ + boxLabel: this.pre14CompatibleText, + inputValue: 'PRE14', + name: 'compatibility' + },{ + boxLabel: this.pre15CompatibleText, + inputValue: 'PRE15', + name: 'compatibility' + },{ + boxLabel: this.pre16CompatibleText, + inputValue: 'PRE16', + name: 'compatibility' + }] }] }