comparison hg4j/src/main/java/org/tmatesoft/hg/internal/RequiresFile.java @ 213:6ec4af642ba8 gradle

Project uses Gradle for build - actual changes
author Alexander Kitaev <kitaev@gmail.com>
date Tue, 10 May 2011 10:52:53 +0200
parents
children
comparison
equal deleted inserted replaced
212:edb2e2829352 213:6ec4af642ba8
1 /*
2 * Copyright (c) 2011 TMate Software Ltd
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * For information on how to redistribute this software under
14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com
16 */
17 package org.tmatesoft.hg.internal;
18
19 import java.io.BufferedReader;
20 import java.io.File;
21 import java.io.FileInputStream;
22 import java.io.IOException;
23 import java.io.InputStreamReader;
24
25 /**
26 *
27 * @author Artem Tikhomirov
28 * @author TMate Software Ltd.
29 */
30 public class RequiresFile {
31 public static final int STORE = 1;
32 public static final int FNCACHE = 2;
33 public static final int DOTENCODE = 4;
34
35 public RequiresFile() {
36 }
37
38 public void parse(Internals repoImpl, File requiresFile) {
39 if (!requiresFile.exists()) {
40 return;
41 }
42 try {
43 boolean revlogv1 = false;
44 boolean store = false;
45 boolean fncache = false;
46 boolean dotencode = false;
47 BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(requiresFile)));
48 String line;
49 while ((line = br.readLine()) != null) {
50 revlogv1 |= "revlogv1".equals(line);
51 store |= "store".equals(line);
52 fncache |= "fncache".equals(line);
53 dotencode |= "dotencode".equals(line);
54 }
55 int flags = 0;
56 flags += store ? STORE : 0;
57 flags += fncache ? FNCACHE : 0;
58 flags += dotencode ? DOTENCODE : 0;
59 repoImpl.setStorageConfig(revlogv1 ? 1 : 0, flags);
60 } catch (IOException ex) {
61 ex.printStackTrace(); // FIXME log
62 }
63 }
64 }