kitaev@213: /* kitaev@213: * Copyright (c) 2011 TMate Software Ltd kitaev@213: * kitaev@213: * This program is free software; you can redistribute it and/or modify kitaev@213: * it under the terms of the GNU General Public License as published by kitaev@213: * the Free Software Foundation; version 2 of the License. kitaev@213: * kitaev@213: * This program is distributed in the hope that it will be useful, kitaev@213: * but WITHOUT ANY WARRANTY; without even the implied warranty of kitaev@213: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the kitaev@213: * GNU General Public License for more details. kitaev@213: * kitaev@213: * For information on how to redistribute this software under kitaev@213: * the terms of a license other than GNU General Public License kitaev@213: * contact TMate Software at support@hg4j.com kitaev@213: */ kitaev@213: package org.tmatesoft.hg.internal; kitaev@213: kitaev@213: import java.io.BufferedReader; kitaev@213: import java.io.File; kitaev@213: import java.io.FileInputStream; kitaev@213: import java.io.IOException; kitaev@213: import java.io.InputStreamReader; kitaev@213: kitaev@213: /** kitaev@213: * kitaev@213: * @author Artem Tikhomirov kitaev@213: * @author TMate Software Ltd. kitaev@213: */ kitaev@213: public class RequiresFile { kitaev@213: public static final int STORE = 1; kitaev@213: public static final int FNCACHE = 2; kitaev@213: public static final int DOTENCODE = 4; kitaev@213: kitaev@213: public RequiresFile() { kitaev@213: } kitaev@213: kitaev@213: public void parse(Internals repoImpl, File requiresFile) { kitaev@213: if (!requiresFile.exists()) { kitaev@213: return; kitaev@213: } kitaev@213: try { kitaev@213: boolean revlogv1 = false; kitaev@213: boolean store = false; kitaev@213: boolean fncache = false; kitaev@213: boolean dotencode = false; kitaev@213: BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(requiresFile))); kitaev@213: String line; kitaev@213: while ((line = br.readLine()) != null) { kitaev@213: revlogv1 |= "revlogv1".equals(line); kitaev@213: store |= "store".equals(line); kitaev@213: fncache |= "fncache".equals(line); kitaev@213: dotencode |= "dotencode".equals(line); kitaev@213: } kitaev@213: int flags = 0; kitaev@213: flags += store ? STORE : 0; kitaev@213: flags += fncache ? FNCACHE : 0; kitaev@213: flags += dotencode ? DOTENCODE : 0; kitaev@213: repoImpl.setStorageConfig(revlogv1 ? 1 : 0, flags); kitaev@213: } catch (IOException ex) { kitaev@213: ex.printStackTrace(); // FIXME log kitaev@213: } kitaev@213: } kitaev@213: }