comparison src/org/tmatesoft/hg/internal/RequiresFile.java @ 74:6f1b88693d48

Complete refactoring to org.tmatesoft
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 24 Jan 2011 03:14:45 +0100
parents
children a3a2e5deb320
comparison
equal deleted inserted replaced
73:0d279bcc4442 74:6f1b88693d48
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@svnkit.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 ? 1 : 0;
57 flags += fncache ? 2 : 0;
58 flags += dotencode ? 4 : 0;
59 repoImpl.setStorageConfig(revlogv1 ? 1 : 0, flags);
60 } catch (IOException ex) {
61 ex.printStackTrace(); // FIXME log
62 }
63 }
64 }