comparison src/org/tmatesoft/hg/internal/Internals.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 a5275143664c
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 static org.tmatesoft.hg.internal.RequiresFile.DOTENCODE;
20 import static org.tmatesoft.hg.internal.RequiresFile.FNCACHE;
21 import static org.tmatesoft.hg.internal.RequiresFile.STORE;
22
23 import org.tmatesoft.hg.util.PathRewrite;
24
25 /**
26 * Fields/members that shall not be visible
27 *
28 * @author Artem Tikhomirov
29 * @author TMate Software Ltd.
30 */
31 public class Internals {
32
33 private int revlogVersion = 0;
34 private int requiresFlags = 0;
35
36 void setStorageConfig(int version, int flags) {
37 revlogVersion = version;
38 requiresFlags = flags;
39 }
40
41 // XXX perhaps, should keep both fields right here, not in the HgRepository
42 public PathRewrite buildDataFilesHelper() {
43 return new StoragePathHelper((requiresFlags & STORE) != 0, (requiresFlags & FNCACHE) != 0, (requiresFlags & DOTENCODE) != 0);
44 }
45
46 public PathRewrite buildRepositoryFilesHelper() {
47 if ((requiresFlags & STORE) != 0) {
48 return new PathRewrite() {
49 public String rewrite(String path) {
50 return "store/" + path;
51 }
52 };
53 } else {
54 return new PathRewrite() {
55 public String rewrite(String path) {
56 //no-op
57 return path;
58 }
59 };
60 }
61 }
62 }