comparison src/org/tmatesoft/hg/internal/StoragePathHelper.java @ 292:a415fe296a50

Refactor PathRewrite to accept any char sequence, not only string
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 14 Sep 2011 02:16:19 +0200
parents bb1d02f9eff6
children 6d2c6b2469fc
comparison
equal deleted inserted replaced
291:1483e57541ef 292:a415fe296a50
41 } 41 }
42 42
43 // FIXME document what path argument is, whether it includes .i or .d, and whether it's 'normalized' (slashes) or not. 43 // FIXME document what path argument is, whether it includes .i or .d, and whether it's 'normalized' (slashes) or not.
44 // since .hg/store keeps both .i files and files without extension (e.g. fncache), guees, for data == false 44 // since .hg/store keeps both .i files and files without extension (e.g. fncache), guees, for data == false
45 // we shall assume path has extension 45 // we shall assume path has extension
46 public String rewrite(String path) { 46 public CharSequence rewrite(CharSequence p) {
47 final String STR_STORE = "store/"; 47 final String STR_STORE = "store/";
48 final String STR_DATA = "data/"; 48 final String STR_DATA = "data/";
49 final String STR_DH = "dh/"; 49 final String STR_DH = "dh/";
50 final String reservedChars = "\\:*?\"<>|"; 50 final String reservedChars = "\\:*?\"<>|";
51 char[] hexByte = new char[2]; 51 char[] hexByte = new char[2];
52 52
53 String path = p.toString();
53 path = path.replace(".hg/", ".hg.hg/").replace(".i/", ".i.hg/").replace(".d/", ".d.hg/"); 54 path = path.replace(".hg/", ".hg.hg/").replace(".i/", ".i.hg/").replace(".d/", ".d.hg/");
54 StringBuilder sb = new StringBuilder(path.length() << 1); 55 StringBuilder sb = new StringBuilder(path.length() << 1);
55 if (store || fncache) { 56 if (store || fncache) {
56 // encodefilename 57 // encodefilename
57 for (int i = 0; i < path.length(); i++) { 58 for (int i = 0; i < path.length(); i++) {