~ubuntu-branches/ubuntu/saucy/statsvn/saucy

« back to all changes in this revision

Viewing changes to src/net/sf/statsvn/output/SvnConfigurationOptions.java

  • Committer: Bazaar Package Importer
  • Author(s): Vincent Fourmond
  • Date: 2008-06-28 15:53:07 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080628155307-sw2xqeigkk4zwlxm
Tags: 0.4.0.dfsg-1
* New upstream version (closes: #481799)
* Does not work with older statcvs, tightening up dependencies
* statsvn still complains about files with spaces within, but
  it does not seem to affect statistics anymore, so it 
  closes: #469937,#469938

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
import net.sf.statsvn.util.TaskLogger;
32
32
 
33
33
/**
34
 
 * Class for storing all command line parameters. The parameters are set by the {@link net.sf.statsvn.Main#main} method. Interested classes can read all
 
34
 * Class for storing all command line parameters. The parameters are set by the
 
35
 * {@link net.sf.statsvn.Main#main} method. Interested classes can read all
35
36
 * parameter values from here.
36
 
 *
 
37
 * 
37
38
 * @todo Should be moved to more appropriate package and made non-public
38
 
 *
 
39
 * 
39
40
 * @author jentzsch
40
41
 * @version $Id: ConfigurationOptions.java,v 1.17 2005/03/20 19:12:25 squig Exp $
41
42
 */
42
43
public final class SvnConfigurationOptions {
43
 
    private static final int DEFAULT_THRESHOLD_MS_FOR_CONCURRENCY = 2000;
 
44
        private static final int DEFAULT_THRESHOLD_MS_FOR_CONCURRENCY = 2000;
 
45
 
44
46
        private static final int DEFAULT_NUMBER_THREADS = 25;
 
47
 
45
48
        private static String cacheDir = "";
46
 
    private static final String DEFAULT_CACHE_DIR = System.getProperty("user.home") + FileUtils.getDirSeparator() + ".statsvn" + FileUtils.getDirSeparator();
47
 
    private static String svnUsername = null;
48
 
    private static String svnPassword = null;
49
 
    private static TaskLogger taskLogger = new JavaUtilTaskLogger();
50
 
    private static int numberSvnDiffThreads = DEFAULT_NUMBER_THREADS;
51
 
    private static long thresholdInMsToUseConcurrency = DEFAULT_THRESHOLD_MS_FOR_CONCURRENCY;
52
 
    private static boolean dump = false;
53
 
 
54
 
    /**
55
 
         * A utility class (only static methods) should be final and have
56
 
         * a private constructor.
 
49
 
 
50
        private static final String DEFAULT_CACHE_DIR = System.getProperty("user.home") + FileUtils.getDirSeparator() + ".statsvn" + FileUtils.getDirSeparator();
 
51
 
 
52
        private static String svnUsername = null;
 
53
 
 
54
        private static String svnPassword = null;
 
55
 
 
56
        private static TaskLogger taskLogger = new JavaUtilTaskLogger();
 
57
 
 
58
        private static int numberSvnDiffThreads = DEFAULT_NUMBER_THREADS;
 
59
 
 
60
        private static long thresholdInMsToUseConcurrency = DEFAULT_THRESHOLD_MS_FOR_CONCURRENCY;
 
61
 
 
62
        private static boolean dump = false;
 
63
 
 
64
        private static boolean anonymize = false;
 
65
 
 
66
        private static String tagsDirectory = "/tags/";
 
67
 
 
68
        // use the newer diff. will be overridden if this is not possible. 
 
69
        private static boolean useLegacyDiff = false;
 
70
 
 
71
        /**
 
72
         * A utility class (only static methods) should be final and have a private
 
73
         * constructor.
57
74
         */
58
75
        private SvnConfigurationOptions() {
59
76
        }
60
77
 
61
 
    /**
62
 
     * Returns the cacheDir.
63
 
     *
64
 
     * @return String output Directory
65
 
     */
66
 
    public static String getCacheDir() {
67
 
        return cacheDir;
68
 
    }
69
 
 
70
 
    /**
71
 
     * Sets the cacheDir.
72
 
     *
73
 
     * @param cacheDir
74
 
     *            The cacheDir to set
75
 
     * @throws ConfigurationException
76
 
     *             if the cache directory cannot be created
77
 
     */
78
 
    public static void setCacheDir(String cacheDir) throws ConfigurationException {
79
 
        if (!cacheDir.endsWith(FileUtils.getDirSeparator())) {
80
 
            cacheDir += FileUtils.getDefaultDirSeparator();
81
 
        }
82
 
        final File cDir = new File(cacheDir);
83
 
        if (!cDir.exists() && !cDir.mkdirs()) {
84
 
            throw new ConfigurationException("Can't create cache directory: " + cacheDir);
85
 
        }
86
 
        SvnConfigurationOptions.cacheDir = cacheDir;
87
 
    }
88
 
 
89
 
    /**
90
 
     * Sets the cacheDir to the DEFAULT_CACHE_DIR
91
 
     *
92
 
     * @throws ConfigurationException
93
 
     *             if the cache directory cannot be created
94
 
     */
95
 
    public static void setCacheDirToDefault() throws ConfigurationException {
96
 
        setCacheDir(DEFAULT_CACHE_DIR);
97
 
    }
98
 
 
99
 
    public static File getCheckedOutDirectoryAsFile() {
100
 
        return new File(FileUtils.getPathWithoutEndingSlash(ConfigurationOptions.getCheckedOutDirectory()) + FileUtils.getDirSeparator());
101
 
    }
 
78
        /**
 
79
         * Returns the cacheDir.
 
80
         * 
 
81
         * @return String output Directory
 
82
         */
 
83
        public static String getCacheDir() {
 
84
                return cacheDir;
 
85
        }
 
86
 
 
87
        /**
 
88
         * Sets the cacheDir.
 
89
         * 
 
90
         * @param cacheDir
 
91
         *            The cacheDir to set
 
92
         * @throws ConfigurationException
 
93
         *             if the cache directory cannot be created
 
94
         */
 
95
        public static void setCacheDir(String cacheDir) throws ConfigurationException {
 
96
                if (!cacheDir.endsWith(FileUtils.getDirSeparator())) {
 
97
                        cacheDir += FileUtils.getDefaultDirSeparator();
 
98
                }
 
99
                final File cDir = new File(cacheDir);
 
100
                if (!cDir.exists() && !cDir.mkdirs()) {
 
101
                        throw new ConfigurationException("Can't create cache directory: " + cacheDir);
 
102
                }
 
103
                SvnConfigurationOptions.cacheDir = cacheDir;
 
104
        }
 
105
 
 
106
        /**
 
107
         * Sets the cacheDir to the DEFAULT_CACHE_DIR
 
108
         * 
 
109
         * @throws ConfigurationException
 
110
         *             if the cache directory cannot be created
 
111
         */
 
112
        public static void setCacheDirToDefault() throws ConfigurationException {
 
113
                setCacheDir(DEFAULT_CACHE_DIR);
 
114
        }
 
115
 
 
116
        public static File getCheckedOutDirectoryAsFile() {
 
117
                return new File(FileUtils.getPathWithoutEndingSlash(ConfigurationOptions.getCheckedOutDirectory()) + FileUtils.getDirSeparator());
 
118
        }
102
119
 
103
120
        /**
104
121
         * @return Returns the svnPassword.
108
125
        }
109
126
 
110
127
        /**
111
 
         * @param svnPassword The svnPassword to set.
 
128
         * @param svnPassword
 
129
         *            The svnPassword to set.
112
130
         */
113
131
        public static void setSvnPassword(final String svnPassword) {
114
132
                SvnConfigurationOptions.svnPassword = svnPassword;
122
140
        }
123
141
 
124
142
        /**
125
 
         * @param svnUsername The svnUsername to set.
 
143
         * @param svnUsername
 
144
         *            The svnUsername to set.
126
145
         */
127
146
        public static void setSvnUsername(final String svnUsername) {
128
147
                SvnConfigurationOptions.svnUsername = svnUsername;
136
155
        }
137
156
 
138
157
        /**
139
 
         * @param taskLogger the taskLogger to set
 
158
         * @param taskLogger
 
159
         *            the taskLogger to set
140
160
         */
141
161
        public static void setTaskLogger(final TaskLogger taskLogger) {
142
162
                SvnConfigurationOptions.taskLogger = taskLogger;
150
170
        }
151
171
 
152
172
        /**
153
 
         * @param numberSvnDiffThreads the numberSvnDiffThreads to set
 
173
         * @param numberSvnDiffThreads
 
174
         *            the numberSvnDiffThreads to set
154
175
         */
155
 
        public static void setNumberSvnDiffThreads(int numberSvnDiffThreads) {
 
176
        public static void setNumberSvnDiffThreads(final int numberSvnDiffThreads) {
156
177
                SvnConfigurationOptions.numberSvnDiffThreads = numberSvnDiffThreads;
157
178
        }
158
179
 
164
185
        }
165
186
 
166
187
        /**
167
 
         * @param thresholdInMsToUseConcurrency the thresholdInMsToUseConcurrency to set
 
188
         * @param thresholdInMsToUseConcurrency
 
189
         *            the thresholdInMsToUseConcurrency to set
168
190
         */
169
 
        public static void setThresholdInMsToUseConcurrency(long thresholdToUseConcurrency) {
 
191
        public static void setThresholdInMsToUseConcurrency(final long thresholdToUseConcurrency) {
170
192
                SvnConfigurationOptions.thresholdInMsToUseConcurrency = thresholdToUseConcurrency;
171
193
        }
172
 
        
 
194
 
173
195
        public static void setDumpContent(final boolean dumpContent) {
174
196
                dump = dumpContent;
175
197
        }
176
 
        
 
198
 
177
199
        public static boolean isDumpContent() {
178
200
                return dump;
179
201
        }
 
202
 
 
203
        public static void setAnonymize(final boolean bAnon) {
 
204
                anonymize = bAnon;
 
205
        }
 
206
 
 
207
        public static boolean isAnonymize() {
 
208
                return anonymize;
 
209
        }
 
210
 
 
211
        /**
 
212
         * Following request 1692245, add option -tags-dir to the command line.
 
213
         */
 
214
        public static void setTagsDirectory(final String tagsDir) {
 
215
                if (tagsDir != null) {
 
216
                        tagsDirectory = tagsDir.replace('\\', '/');
 
217
                        if (!tagsDirectory.endsWith("/")) {
 
218
                                tagsDirectory = tagsDir + "/";
 
219
                        }
 
220
                }
 
221
        }
 
222
 
 
223
        /**
 
224
         * Following request 1692245, add option -tags-dir to the command line.
 
225
         */
 
226
        public static String getTagsDirectory() {
 
227
                return tagsDirectory;
 
228
        }
 
229
 
 
230
        /**
 
231
         * Should we use a one diff per-file-per-revision or should we use the newer one diff per-revision?
 
232
         * 
 
233
         * @return true if legacy diff should be used. 
 
234
         */
 
235
        public static boolean isLegacyDiff() {
 
236
                return useLegacyDiff;
 
237
        }
 
238
 
 
239
        /**
 
240
         * Should we use a one diff per-file-per-revision or should we use the newer one diff per-revision?
 
241
         * 
 
242
         * @param isLegacy true if the legacy diff should be used.  
 
243
         */
 
244
        public static void setLegacyDiff(final boolean isLegacy) {
 
245
                useLegacyDiff = isLegacy;
 
246
        }
 
247
 
180
248
}