Mercurial > hg4j
annotate src/com/tmate/hgkit/ll/LocalHgRepo.java @ 58:4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 17 Jan 2011 23:01:19 +0100 |
parents | 8b0d6f1bd6b4 |
children | b771e94a4f7c |
rev | line source |
---|---|
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
1 /* |
20
11cfabe692b3
Status operation for two repository revisions (no local dir involved)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
18
diff
changeset
|
2 * Copyright (c) 2010, 2011 Artem Tikhomirov |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 */ |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 package com.tmate.hgkit.ll; |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 |
22
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
6 import java.io.BufferedInputStream; |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
7 import java.io.BufferedReader; |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 import java.io.File; |
58
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
57
diff
changeset
|
9 import java.io.FileFilter; |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
10 import java.io.FileInputStream; |
58
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
57
diff
changeset
|
11 import java.io.FilenameFilter; |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 import java.io.IOException; |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
13 import java.io.InputStreamReader; |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
14 import java.lang.ref.SoftReference; |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
15 import java.util.Arrays; |
57
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
16 import java.util.Collections; |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
17 import java.util.HashMap; |
18
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
18 import java.util.LinkedList; |
57
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
19 import java.util.Set; |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
20 import java.util.TreeSet; |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
22 import com.tmate.hgkit.fs.DataAccessProvider; |
58
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
57
diff
changeset
|
23 import com.tmate.hgkit.fs.FileWalker; |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
24 |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 /** |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 * @author artem |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
27 */ |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 public class LocalHgRepo extends HgRepository { |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
29 |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
30 private File repoDir; // .hg folder |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 private final String repoLocation; |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
32 private final DataAccessProvider dataAccess; |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
34 public LocalHgRepo(String repositoryPath) { |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 setInvalid(true); |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 repoLocation = repositoryPath; |
58
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
57
diff
changeset
|
37 dataAccess = null; |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 } |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 public LocalHgRepo(File repositoryRoot) throws IOException { |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 assert ".hg".equals(repositoryRoot.getName()) && repositoryRoot.isDirectory(); |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 setInvalid(false); |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 repoDir = repositoryRoot; |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 repoLocation = repositoryRoot.getParentFile().getCanonicalPath(); |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
45 dataAccess = new DataAccessProvider(); |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
46 parseRequires(); |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 } |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 @Override |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
50 public String getLocation() { |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 return repoLocation; |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 } |
18
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
53 |
58
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
57
diff
changeset
|
54 public FileWalker createWorkingDirWalker() { |
4cfc47bc14cc
Status against local working dir extracted into distinct class. Iterating over local files extracted for ease of os-dependant patching
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
57
diff
changeset
|
55 return new FileWalker(repoDir.getParentFile()); |
57
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
56 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
57 |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
58 // XXX package-local, unless there are cases when required from outside (guess, working dir/revision walkers may hide dirstate access and no public visibility needed) |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
59 public final HgDirstate loadDirstate() { |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
60 // XXX may cache in SoftReference if creation is expensive |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
61 return new HgDirstate(this, new File(repoDir, "dirstate")); |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
62 } |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
63 |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
64 // package-local, see comment for loadDirstate |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
65 public final HgIgnore loadIgnore() { |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
66 return new HgIgnore(this); |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
67 } |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
68 |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
69 /*package-local*/ DataAccessProvider getDataAccess() { |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
70 return dataAccess; |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
71 } |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
72 |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
73 /*package-local*/ File getRepositoryRoot() { |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
74 return repoDir; |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
75 } |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
76 |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
24
diff
changeset
|
77 @Override |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
24
diff
changeset
|
78 protected HgTags createTags() { |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
24
diff
changeset
|
79 return new HgTags(); |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
24
diff
changeset
|
80 } |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
24
diff
changeset
|
81 |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
82 private final HashMap<String, SoftReference<RevlogStream>> streamsCache = new HashMap<String, SoftReference<RevlogStream>>(); |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
83 |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
84 /** |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
85 * path - repository storage path (i.e. one usually with .i or .d) |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
86 */ |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
87 @Override |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
88 protected RevlogStream resolve(String path) { |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
89 final SoftReference<RevlogStream> ref = streamsCache.get(path); |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
90 RevlogStream cached = ref == null ? null : ref.get(); |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
91 if (cached != null) { |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
92 return cached; |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
93 } |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
94 File f = new File(repoDir, path); |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
95 if (f.exists()) { |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
96 RevlogStream s = new RevlogStream(dataAccess, f); |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
97 streamsCache.put(path, new SoftReference<RevlogStream>(s)); |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
98 return s; |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
99 } |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
100 return null; |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
101 } |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
102 |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
103 @Override |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
104 public HgDataFile getFileNode(String path) { |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
105 String nPath = normalize(path); |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
106 String storagePath = toStoragePath(nPath, true); |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
107 RevlogStream content = resolve(storagePath); |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
108 // XXX no content when no file? or HgDataFile.exists() to detect that? How about files that were removed in previous releases? |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
109 return new HgDataFile(this, nPath, content); |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
110 } |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
111 |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
112 private boolean revlogv1; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
113 private boolean store; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
114 private boolean fncache; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
115 private boolean dotencode; |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
116 |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
117 |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
118 private void parseRequires() { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
119 File requiresFile = new File(repoDir, "requires"); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
120 if (!requiresFile.exists()) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
121 return; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
122 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
123 try { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
124 BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(requiresFile))); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
125 String line; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
126 while ((line = br.readLine()) != null) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
127 revlogv1 |= "revlogv1".equals(line); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
128 store |= "store".equals(line); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
129 fncache |= "fncache".equals(line); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
130 dotencode |= "dotencode".equals(line); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
131 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
132 } catch (IOException ex) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
133 ex.printStackTrace(); // FIXME log |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
134 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
135 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
136 |
9
d6d2a630f4a6
Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
137 // FIXME document what path argument is, whether it includes .i or .d, and whether it's 'normalized' (slashes) or not. |
d6d2a630f4a6
Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
138 // since .hg/store keeps both .i files and files without extension (e.g. fncache), guees, for data == false |
d6d2a630f4a6
Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
139 // we shall assume path has extension |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
140 // FIXME much more to be done, see store.py:_hybridencode |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
141 // @see http://mercurial.selenic.com/wiki/CaseFoldingPlan |
9
d6d2a630f4a6
Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
142 @Override |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
143 protected String toStoragePath(String path, boolean data) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
144 path = normalize(path); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
145 final String STR_STORE = "store/"; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
146 final String STR_DATA = "data/"; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
147 final String STR_DH = "dh/"; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
148 if (!data) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
149 return this.store ? STR_STORE + path : path; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
150 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
151 path = path.replace(".hg/", ".hg.hg/").replace(".i/", ".i.hg/").replace(".d/", ".d.hg/"); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
152 StringBuilder sb = new StringBuilder(path.length() << 1); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
153 if (store || fncache) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
154 // encodefilename |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
155 final String reservedChars = "\\:*?\"<>|"; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
156 // in fact, \\ is unlikely to match, ever - we've replaced all of them already, above. Just regards to store.py |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
157 int x; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
158 char[] hexByte = new char[2]; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
159 for (int i = 0; i < path.length(); i++) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
160 final char ch = path.charAt(i); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
161 if (ch >= 'a' && ch <= 'z') { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
162 sb.append(ch); // POIRAE |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
163 } else if (ch >= 'A' && ch <= 'Z') { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
164 sb.append('_'); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
165 sb.append(Character.toLowerCase(ch)); // Perhaps, (char) (((int) ch) + 32)? Even better, |= 0x20? |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
166 } else if ( (x = reservedChars.indexOf(ch)) != -1) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
167 sb.append('~'); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
168 sb.append(toHexByte(reservedChars.charAt(x), hexByte)); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
169 } else if ((ch >= '~' /*126*/ && ch <= 255) || ch < ' ' /*32*/) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
170 sb.append('~'); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
171 sb.append(toHexByte(ch, hexByte)); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
172 } else if (ch == '_') { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
173 // note, encoding from store.py:_buildencodefun and :_build_lower_encodefun |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
174 // differ in the way they process '_' (latter doesn't escape it) |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
175 sb.append('_'); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
176 sb.append('_'); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
177 } else { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
178 sb.append(ch); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
179 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
180 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
181 // auxencode |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
182 if (fncache) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
183 x = 0; // last segment start |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
184 final TreeSet<String> windowsReservedFilenames = new TreeSet<String>(); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
185 windowsReservedFilenames.addAll(Arrays.asList("con prn aux nul com1 com2 com3 com4 com5 com6 com7 com8 com9 lpt1 lpt2 lpt3 lpt4 lpt5 lpt6 lpt7 lpt8 lpt9".split(" "))); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
186 do { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
187 int i = sb.indexOf("/", x); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
188 if (i == -1) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
189 i = sb.length(); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
190 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
191 // windows reserved filenames are at least of length 3 |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
192 if (i - x >= 3) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
193 boolean found = false; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
194 if (i-x == 3) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
195 found = windowsReservedFilenames.contains(sb.subSequence(x, i)); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
196 } else if (sb.charAt(x+3) == '.') { // implicit i-x > 3 |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
197 found = windowsReservedFilenames.contains(sb.subSequence(x, x+3)); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
198 } else if (i-x > 4 && sb.charAt(x+4) == '.') { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
199 found = windowsReservedFilenames.contains(sb.subSequence(x, x+4)); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
200 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
201 if (found) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
202 sb.setCharAt(x, '~'); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
203 sb.insert(x+1, toHexByte(sb.charAt(x+2), hexByte)); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
204 i += 2; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
205 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
206 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
207 if (dotencode && (sb.charAt(x) == '.' || sb.charAt(x) == ' ')) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
208 sb.insert(x+1, toHexByte(sb.charAt(x), hexByte)); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
209 sb.setCharAt(x, '~'); // setChar *after* charAt/insert to get ~2e, not ~7e for '.' |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
210 i += 2; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
211 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
212 x = i+1; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
213 } while (x < sb.length()); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
214 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
215 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
216 final int MAX_PATH_LEN_IN_HGSTORE = 120; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
217 if (fncache && (sb.length() + STR_DATA.length() > MAX_PATH_LEN_IN_HGSTORE)) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
218 throw HgRepository.notImplemented(); // FIXME digest and fncache use |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
219 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
220 if (this.store) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
221 sb.insert(0, STR_STORE + STR_DATA); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
222 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
223 sb.append(".i"); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
224 return sb.toString(); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
225 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
226 |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
227 private static char[] toHexByte(int ch, char[] buf) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
228 assert buf.length > 1; |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
229 final String hexDigits = "0123456789abcdef"; |
9
d6d2a630f4a6
Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
230 buf[0] = hexDigits.charAt((ch & 0x00F0) >>> 4); |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
231 buf[1] = hexDigits.charAt(ch & 0x0F); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
232 return buf; |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
233 } |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
234 |
9
d6d2a630f4a6
Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
8
diff
changeset
|
235 // TODO handle . and .. (although unlikely to face them from GUI client) |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
236 private static String normalize(String path) { |
8
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
237 path = path.replace('\\', '/').replace("//", "/"); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
238 if (path.startsWith("/")) { |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
239 path = path.substring(1); |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
240 } |
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
241 return path; |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
242 } |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
243 } |