Mercurial > hg4j
annotate test/org/tmatesoft/hg/test/TestStorePath.java @ 599:55b7987c1796
Do not instantiate intermediate arrays
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Fri, 03 May 2013 15:29:26 +0200 |
parents | b3c16d1aede0 |
children | 4a0bab2c6da1 |
rev | line source |
---|---|
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
411
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
2 * Copyright (c) 2011-2012 TMate Software Ltd |
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
14 * the terms of a license other than GNU General Public License |
102
a3a2e5deb320
Updated contact address to support@hg4j.com
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
101
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.test; |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
19 import static org.tmatesoft.hg.internal.RequiresFile.*; |
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
20 |
411
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
21 import java.util.HashMap; |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
22 import java.util.Map; |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
23 |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
83
diff
changeset
|
24 import junit.framework.Assert; |
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
83
diff
changeset
|
25 |
292
a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
26 import org.hamcrest.CoreMatchers; |
411
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
27 import org.junit.Before; |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
83
diff
changeset
|
28 import org.junit.Rule; |
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
83
diff
changeset
|
29 import org.junit.Test; |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
30 import org.tmatesoft.hg.core.SessionContext; |
389
82bec80bb1a4
Missing cons args
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
346
diff
changeset
|
31 import org.tmatesoft.hg.internal.BasicSessionContext; |
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 import org.tmatesoft.hg.internal.Internals; |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
33 import org.tmatesoft.hg.internal.RepoInitializer; |
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 import org.tmatesoft.hg.util.PathRewrite; |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 /** |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 * |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 * @author Artem Tikhomirov |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 * @author TMate Software Ltd. |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 */ |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 public class TestStorePath { |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
83
diff
changeset
|
43 @Rule |
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
83
diff
changeset
|
44 public ErrorCollectorExt errorCollector = new ErrorCollectorExt(); |
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
83
diff
changeset
|
45 |
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 private PathRewrite storePathHelper; |
411
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
47 private final Map<String, Object> propertyOverrides = new HashMap<String, Object>(); |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
48 |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
49 private final SessionContext sessionCtx; |
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
50 private final RepoInitializer repoInit; |
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
83
diff
changeset
|
52 public static void main(String[] args) throws Throwable { |
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 final TestStorePath test = new TestStorePath(); |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 test.testWindowsFilenames(); |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 test.testHashLongPath(); |
411
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
56 test.testSuffixReplacement(); |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
83
diff
changeset
|
57 test.errorCollector.verify(); |
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
58 } |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
59 |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
60 public TestStorePath() { |
411
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
61 propertyOverrides.put("hg.consolelog.debug", true); |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
62 sessionCtx = new BasicSessionContext(propertyOverrides, null); |
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
63 repoInit = new RepoInitializer().setRequires(STORE + FNCACHE + DOTENCODE); |
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
64 storePathHelper = repoInit.buildDataFilesHelper(sessionCtx); |
411
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
65 } |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
66 |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
67 @Before |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
68 public void setup() { |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
69 // just in case there are leftovers from #testNationalChars() and another test builds a helper |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
70 propertyOverrides.clear(); |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
71 propertyOverrides.put("hg.consolelog.debug", true); |
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
72 } |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
73 |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
83
diff
changeset
|
74 @Test |
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
75 public void testWindowsFilenames() { |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
76 // see http://mercurial.selenic.com/wiki/fncacheRepoFormat#Encoding_of_Windows_reserved_names |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
77 String n1 = "aux.bla/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c"; |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
78 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"; |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
83
diff
changeset
|
79 Assert.assertEquals("Windows filenames are ", r1, storePathHelper.rewrite(n1)); |
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
80 } |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
81 |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
83
diff
changeset
|
82 @Test |
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
83 public void testHashLongPath() { |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
84 String n1 = "AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT"; |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
85 String r1 = "store/dh/au~78/second/x.prn/fourth/fi~3afth/sixth/seventh/eighth/nineth/tenth/loremia20419e358ddff1bf8751e38288aff1d7c32ec05.i"; |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
86 String n2 = "enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider"; |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
87 String r2 = "store/dh/enterpri/openesba/contrib-/corba-bc/netbeans/wsdlexte/src/main/java/org.net7018f27961fdf338a598a40c4683429e7ffb9743.i"; |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
88 String n3 = "AUX.THE-QUICK-BROWN-FOX-JU:MPS-OVER-THE-LAZY-DOG-THE-QUICK-BROWN-FOX-JUMPS-OVER-THE-LAZY-DOG.TXT"; |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
89 String r3 = "store/dh/au~78.the-quick-brown-fox-ju~3amps-over-the-lazy-dog-the-quick-brown-fox-jud4dcadd033000ab2b26eb66bae1906bcb15d4a70.i"; |
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
90 // TODO segment[8] == [. ], segment[8] in the middle of windows reserved name or character (to see if ~xx is broken) |
292
a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
91 errorCollector.checkThat(storePathHelper.rewrite(n1), CoreMatchers.<CharSequence>equalTo(r1)); |
a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
92 errorCollector.checkThat(storePathHelper.rewrite(n2), CoreMatchers.<CharSequence>equalTo(r2)); |
a415fe296a50
Refactor PathRewrite to accept any char sequence, not only string
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
93 errorCollector.checkThat(storePathHelper.rewrite(n3), CoreMatchers.<CharSequence>equalTo(r3)); |
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
94 } |
346
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
95 |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
96 @Test |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
97 public void testIndexFileExtensionIsPartOfTheName() { |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
98 // with "data/" and ".i" 121 chars |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
99 String n1 = "src/jgit/main/org.eclipse.jgit.packaging/org.eclipse.jgit.junit.feature/.settings/org.eclipse.core.resources.prefs"; |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
100 String r1 = "store/dh/src/jgit/main/org.ecli/org.ecli/~2esetti/org.eclipse.core.resources.prefs.ie1f4f9eed1009d220cd5afa6e01e7d9a06c02201.i"; |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
101 // with "data/" and ".i" 122 chars |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
102 String n2 = "src/jgit/main/org.eclipse.jgit.packaging/org.eclipse.jgit.source.feature/.settings/org.eclipse.core.resources.prefs"; |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
103 String r2 = "store/dh/src/jgit/main/org.ecli/org.ecli/~2esetti/org.eclipse.core.resources.prefs.i5193ab724f0225178fa949738444c4aac05e5e00.i"; |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
104 // |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
105 // with "data/" and ".i" just 118 chars, use as sanity that it's not mangled |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
106 String n3 = "src/jgit/main/org.eclipse.jgit.packaging/org.eclipse.jgit.updatesite/.settings/org.eclipse.core.resources.prefs"; |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
107 String r3 = "store/data/src/jgit/main/org.eclipse.jgit.packaging/org.eclipse.jgit.updatesite/~2esettings/org.eclipse.core.resources.prefs.i"; |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
108 errorCollector.checkThat(storePathHelper.rewrite(n1), CoreMatchers.<CharSequence>equalTo(r1)); |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
109 errorCollector.checkThat(storePathHelper.rewrite(n2), CoreMatchers.<CharSequence>equalTo(r2)); |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
110 errorCollector.checkThat(storePathHelper.rewrite(n3), CoreMatchers.<CharSequence>equalTo(r3)); |
6d2c6b2469fc
Issue 18: Invalid storage path for certain long names
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
292
diff
changeset
|
111 } |
411
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
112 |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
113 @Test |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
114 public void testSuffixReplacement() { |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
115 String s1 = "aaa/bbb.hg/ccc.i/ddd.hg/xx.i"; |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
116 String s2 = "bbb.d/aa.hg/bbb.hg/yy.d"; |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
117 String r1 = s1.replace(".hg/", ".hg.hg/").replace(".i/", ".i.hg/").replace(".d/", ".d.hg/"); |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
118 String r2 = s2.replace(".hg/", ".hg.hg/").replace(".i/", ".i.hg/").replace(".d/", ".d.hg/"); |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
119 errorCollector.checkThat(storePathHelper.rewrite(s1), CoreMatchers.<CharSequence>equalTo("store/data/" + r1 + ".i")); |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
120 errorCollector.checkThat(storePathHelper.rewrite(s2), CoreMatchers.<CharSequence>equalTo("store/data/" + r2 + ".i")); |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
121 } |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
122 |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
123 @Test |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
124 public void testNationalChars() { |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
125 String s = "Привет.txt"; |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
126 // |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
127 propertyOverrides.put(Internals.CFG_PROPERTY_FS_FILENAME_ENCODING, "cp1251"); |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
128 PathRewrite sph = repoInit.buildDataFilesHelper(sessionCtx); |
411
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
129 errorCollector.checkThat(sph.rewrite(s), CoreMatchers.<CharSequence>equalTo("store/data/~cf~f0~e8~e2~e5~f2.txt.i")); |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
130 // |
412
63c5a9d7ca3f
Follow-up for Issue 29: unify path translation for manifest and dirstate
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
411
diff
changeset
|
131 propertyOverrides.put(Internals.CFG_PROPERTY_FS_FILENAME_ENCODING, "UTF8"); |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
132 sph = repoInit.buildDataFilesHelper(sessionCtx); |
411
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
133 errorCollector.checkThat(sph.rewrite(s), CoreMatchers.<CharSequence>equalTo("store/data/~d0~9f~d1~80~d0~b8~d0~b2~d0~b5~d1~82.txt.i")); |
464b4404e75d
Issue 29: Bad storage path translation - translate Unicode chars to filesystem encoding
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
389
diff
changeset
|
134 } |
83
a5275143664c
Complete path hash calculation of fncache requirement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
135 } |