comparison src/com/tmate/hgkit/ll/LocalHgRepo.java @ 9:d6d2a630f4a6

Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 25 Dec 2010 04:45:59 +0100
parents a78c980749e3
children 382cfe9463db
comparison
equal deleted inserted replaced
8:a78c980749e3 9:d6d2a630f4a6
92 } catch (IOException ex) { 92 } catch (IOException ex) {
93 ex.printStackTrace(); // FIXME log 93 ex.printStackTrace(); // FIXME log
94 } 94 }
95 } 95 }
96 96
97 // FIXME document what path argument is, whether it includes .i or .d, and whether it's 'normalized' (slashes) or not.
98 // since .hg/store keeps both .i files and files without extension (e.g. fncache), guees, for data == false
99 // we shall assume path has extension
97 // FIXME much more to be done, see store.py:_hybridencode 100 // FIXME much more to be done, see store.py:_hybridencode
98 // @see http://mercurial.selenic.com/wiki/CaseFoldingPlan 101 // @see http://mercurial.selenic.com/wiki/CaseFoldingPlan
102 @Override
99 protected String toStoragePath(String path, boolean data) { 103 protected String toStoragePath(String path, boolean data) {
100 path = normalize(path); 104 path = normalize(path);
101 final String STR_STORE = "store/"; 105 final String STR_STORE = "store/";
102 final String STR_DATA = "data/"; 106 final String STR_DATA = "data/";
103 final String STR_DH = "dh/"; 107 final String STR_DH = "dh/";
181 } 185 }
182 186
183 private static char[] toHexByte(int ch, char[] buf) { 187 private static char[] toHexByte(int ch, char[] buf) {
184 assert buf.length > 1; 188 assert buf.length > 1;
185 final String hexDigits = "0123456789abcdef"; 189 final String hexDigits = "0123456789abcdef";
186 buf[0] = hexDigits.charAt((ch & 0x00F0) >> 4); 190 buf[0] = hexDigits.charAt((ch & 0x00F0) >>> 4);
187 buf[1] = hexDigits.charAt(ch & 0x0F); 191 buf[1] = hexDigits.charAt(ch & 0x0F);
188 return buf; 192 return buf;
189 } 193 }
190 194
195 // TODO handle . and .. (although unlikely to face them from GUI client)
191 private static String normalize(String path) { 196 private static String normalize(String path) {
192 path = path.replace('\\', '/').replace("//", "/"); 197 path = path.replace('\\', '/').replace("//", "/");
193 if (path.startsWith("/")) { 198 if (path.startsWith("/")) {
194 path = path.substring(1); 199 path = path.substring(1);
195 } 200 }