Mercurial > hg4j
comparison test/org/tmatesoft/hg/test/TestStorePath.java @ 83:a5275143664c
Complete path hash calculation of fncache requirement
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 25 Jan 2011 22:44:14 +0100 |
parents | |
children | 777ab7034c1b |
comparison
equal
deleted
inserted
replaced
82:7255c971dd66 | 83:a5275143664c |
---|---|
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.test; | |
18 | |
19 import org.tmatesoft.hg.internal.Internals; | |
20 import org.tmatesoft.hg.util.PathRewrite; | |
21 | |
22 /** | |
23 * | |
24 * @author Artem Tikhomirov | |
25 * @author TMate Software Ltd. | |
26 */ | |
27 public class TestStorePath { | |
28 | |
29 private PathRewrite storePathHelper; | |
30 | |
31 public static void main(String[] args) { | |
32 final TestStorePath test = new TestStorePath(); | |
33 test.testWindowsFilenames(); | |
34 test.testHashLongPath(); | |
35 } | |
36 | |
37 public TestStorePath() { | |
38 final Internals i = new Internals(); | |
39 i.setStorageConfig(1, 0x7); | |
40 storePathHelper = i.buildDataFilesHelper(); | |
41 } | |
42 | |
43 public void testWindowsFilenames() { | |
44 // see http://mercurial.selenic.com/wiki/fncacheRepoFormat#Encoding_of_Windows_reserved_names | |
45 String n1 = "aux.bla/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c"; | |
46 String r1 = "store/data/au~78.bla/bla.aux/pr~6e/_p_r_n/lpt/co~6d3/nu~6c/coma/foo._n_u_l/normal.c.i"; | |
47 report("Windows filenames are ", n1, r1); | |
48 } | |
49 | |
50 public void testHashLongPath() { | |
51 String n1 = "AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT"; | |
52 String r1 = "store/dh/au~78/second/x.prn/fourth/fi~3afth/sixth/seventh/eighth/nineth/tenth/loremia20419e358ddff1bf8751e38288aff1d7c32ec05.i"; | |
53 String n2 = "enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider"; | |
54 String r2 = "store/dh/enterpri/openesba/contrib-/corba-bc/netbeans/wsdlexte/src/main/java/org.net7018f27961fdf338a598a40c4683429e7ffb9743.i"; | |
55 String n3 = "AUX.THE-QUICK-BROWN-FOX-JU:MPS-OVER-THE-LAZY-DOG-THE-QUICK-BROWN-FOX-JUMPS-OVER-THE-LAZY-DOG.TXT"; | |
56 String r3 = "store/dh/au~78.the-quick-brown-fox-ju~3amps-over-the-lazy-dog-the-quick-brown-fox-jud4dcadd033000ab2b26eb66bae1906bcb15d4a70.i"; | |
57 // TODO segment[8] == [. ], segment[8] in the middle of windows reserved name or character (to see if ~xx is broken) | |
58 report("1", n1, r1); | |
59 report("2", n2, r2); | |
60 report("3", n3, r3); | |
61 } | |
62 | |
63 private void report(String msg, String name, String expected) { | |
64 String res = check(name, expected); | |
65 System.out.println(msg + (res == null ? "OK" : "WRONG:" + res)); | |
66 } | |
67 | |
68 private String check(String name, String expected) { | |
69 String result = storePathHelper.rewrite(name); | |
70 return expected.equals(result) ? null : result; | |
71 } | |
72 } |