Mercurial > jhg
annotate src/com/tmate/hgkit/ll/LocalHgRepo.java @ 57:8b0d6f1bd6b4
Local status is back
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 17 Jan 2011 05:54:25 +0100 |
parents | 05829a70b30b |
children | 4cfc47bc14cc |
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; |
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
|
9 import java.io.FileInputStream; |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 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
|
11 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
|
12 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
|
13 import java.util.Arrays; |
57
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
14 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
|
15 import java.util.HashMap; |
18
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
16 import java.util.LinkedList; |
57
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
17 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
|
18 import java.util.TreeSet; |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
19 |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
20 import com.tmate.hgkit.fs.DataAccessProvider; |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
21 |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
22 /** |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
23 * @author artem |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
24 */ |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 public class LocalHgRepo extends HgRepository { |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
26 |
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
|
27 private File repoDir; // .hg folder |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 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
|
29 private final DataAccessProvider dataAccess; |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 public LocalHgRepo(String repositoryPath) { |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 setInvalid(true); |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 repoLocation = repositoryPath; |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
34 dataAccess = null; |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
35 } |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
36 |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
37 public LocalHgRepo(File repositoryRoot) throws IOException { |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
38 assert ".hg".equals(repositoryRoot.getName()) && repositoryRoot.isDirectory(); |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
39 setInvalid(false); |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
40 repoDir = repositoryRoot; |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
41 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
|
42 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
|
43 parseRequires(); |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 } |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
45 |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
46 @Override |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 public String getLocation() { |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 return repoLocation; |
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 } |
18
02ee376bee79
status operation against current working directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
15
diff
changeset
|
50 |
57
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
51 public void statusLocal(int baseRevision, StatusCollector.Inspector inspector) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
52 LinkedList<File> folders = new LinkedList<File>(); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
53 final File rootDir = repoDir.getParentFile(); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
54 folders.add(rootDir); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
55 final HgDirstate dirstate = loadDirstate(); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
56 final HgIgnore hgignore = loadIgnore(); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
57 TreeSet<String> knownEntries = dirstate.all(); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
58 final boolean isTipBase = baseRevision == TIP || baseRevision == getManifest().getRevisionCount(); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
59 StatusCollector.ManifestRevisionInspector collect = null; |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
60 Set<String> baseRevFiles = Collections.emptySet(); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
61 if (!isTipBase) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
62 collect = new StatusCollector.ManifestRevisionInspector(baseRevision, baseRevision); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
63 getManifest().walk(baseRevision, baseRevision, collect); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
64 baseRevFiles = new TreeSet<String>(collect.files(baseRevision)); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
65 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
66 do { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
67 File d = folders.removeFirst(); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
68 for (File f : d.listFiles()) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
69 if (f.isDirectory()) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
70 if (!".hg".equals(f.getName())) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
71 folders.addLast(f); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
72 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
73 } else { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
74 // FIXME path relative to rootDir - need more robust approach |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
75 String fname = normalize(f.getPath().substring(rootDir.getPath().length() + 1)); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
76 if (hgignore.isIgnored(fname)) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
77 inspector.ignored(fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
78 } else { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
79 if (knownEntries.remove(fname)) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
80 // modified, added, removed, clean |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
81 if (collect != null) { // need to check against base revision, not FS file |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
82 Nodeid nid1 = collect.nodeid(baseRevision, fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
83 String flags = collect.flags(baseRevision, fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
84 checkLocalStatusAgainstBaseRevision(baseRevFiles, nid1, flags, fname, f, dirstate, inspector); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
85 baseRevFiles.remove(fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
86 } else { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
87 checkLocalStatusAgainstFile(fname, f, dirstate, inspector); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
88 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
89 } else { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
90 inspector.unknown(fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
91 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
92 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
93 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
94 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
95 } while (!folders.isEmpty()); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
96 if (collect != null) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
97 for (String r : baseRevFiles) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
98 inspector.removed(r); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
99 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
100 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
101 for (String m : knownEntries) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
102 // removed from the repository and missing from working dir shall not be reported as 'deleted' |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
103 if (dirstate.checkRemoved(m) == null) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
104 inspector.missing(m); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
105 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
106 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
107 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
108 |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
109 private static void checkLocalStatusAgainstFile(String fname, File f, HgDirstate dirstate, StatusCollector.Inspector inspector) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
110 HgDirstate.Record r; |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
111 if ((r = dirstate.checkNormal(fname)) != null) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
112 // either clean or modified |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
113 if (f.lastModified() / 1000 == r.time && r.size == f.length()) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
114 inspector.clean(fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
115 } else { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
116 // FIXME check actual content to avoid false modified files |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
117 inspector.modified(fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
118 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
119 } else if ((r = dirstate.checkAdded(fname)) != null) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
120 if (r.name2 == null) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
121 inspector.added(fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
122 } else { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
123 inspector.copied(fname, r.name2); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
124 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
125 } else if ((r = dirstate.checkRemoved(fname)) != null) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
126 inspector.removed(fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
127 } else if ((r = dirstate.checkMerged(fname)) != null) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
128 inspector.modified(fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
129 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
130 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
131 |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
132 // XXX refactor checkLocalStatus methods in more OO way |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
133 private void checkLocalStatusAgainstBaseRevision(Set<String> baseRevNames, Nodeid nid1, String flags, String fname, File f, HgDirstate dirstate, StatusCollector.Inspector inspector) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
134 // fname is in the dirstate, either Normal, Added, Removed or Merged |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
135 HgDirstate.Record r; |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
136 if (nid1 == null) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
137 // normal: added? |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
138 // added: not known at the time of baseRevision, shall report |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
139 // merged: was not known, report as added? |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
140 if ((r = dirstate.checkAdded(fname)) != null) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
141 if (r.name2 != null && baseRevNames.contains(r.name2)) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
142 baseRevNames.remove(r.name2); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
143 inspector.copied(r.name2, fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
144 return; |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
145 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
146 // fall-through, report as added |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
147 } else if (dirstate.checkRemoved(fname) != null) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
148 // removed: removed file was not known at the time of baseRevision, and we should not report it as removed |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
149 return; |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
150 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
151 inspector.added(fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
152 } else { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
153 // was known; check whether clean or modified |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
154 // when added - seems to be the case of a file added once again, hence need to check if content is different |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
155 if ((r = dirstate.checkNormal(fname)) != null || (r = dirstate.checkMerged(fname)) != null || (r = dirstate.checkAdded(fname)) != null) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
156 // either clean or modified |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
157 HgDataFile fileNode = getFileNode(fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
158 final int lengthAtRevision = fileNode.length(nid1); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
159 if (r.size /* XXX File.length() ?! */ != lengthAtRevision || flags != todoGenerateFlags(fname /*java.io.File*/)) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
160 inspector.modified(fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
161 } else { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
162 // check actual content to see actual changes |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
163 // XXX consider adding HgDataDile.compare(File/byte[]/whatever) operation to optimize comparison |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
164 if (areTheSame(f, fileNode.content(nid1))) { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
165 inspector.clean(fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
166 } else { |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
167 inspector.modified(fname); |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
168 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
169 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
170 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
171 // only those left in idsMap after processing are reported as removed |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
172 } |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
173 |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
174 // TODO think over if content comparison may be done more effectively by e.g. calculating nodeid for a local file and comparing it with nodeid from manifest |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
175 // we don't need to tell exact difference, hash should be enough to detect difference, and it doesn't involve reading historical file content, and it's relatively |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
176 // cheap to calc hash on a file (no need to keep it completely in memory). OTOH, if I'm right that the next approach is used for nodeids: |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
177 // changeset nodeid + hash(actual content) => entry (Nodeid) in the next Manifest |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
178 // then it's sufficient to check parents from dirstate, and if they do not match parents from file's baseRevision (non matching parents means different nodeids). |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
179 // The question is whether original Hg treats this case (same content, different parents and hence nodeids) as 'modified' or 'clean' |
8b0d6f1bd6b4
Local status is back
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
55
diff
changeset
|
180 } |
22
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
181 |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
182 private static String todoGenerateFlags(String fname) { |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
183 // FIXME implement |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
184 return null; |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
185 } |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
186 private static boolean areTheSame(File f, byte[] data) { |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
187 try { |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
188 BufferedInputStream is = new BufferedInputStream(new FileInputStream(f)); |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
189 int i = 0; |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
190 while (i < data.length && data[i] == is.read()) { |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
191 i++; // increment only for successful match, otherwise won't tell last byte in data was the same as read from the stream |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
192 } |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
193 return i == data.length && is.read() == -1; // although data length is expected to be the same (see caller), check that we reached EOF, no more data left. |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
194 } catch (IOException ex) { |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
195 ex.printStackTrace(); // log warn |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
196 } |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
197 return false; |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
198 } |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
21
diff
changeset
|
199 |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
200 // 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
|
201 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
|
202 // 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
|
203 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
|
204 } |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
205 |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
206 // package-local, see comment for loadDirstate |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
207 public final HgIgnore loadIgnore() { |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
208 return new HgIgnore(this); |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
209 } |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
210 |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
211 /*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
|
212 return dataAccess; |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
213 } |
15
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
214 |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
215 /*package-local*/ File getRepositoryRoot() { |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
216 return repoDir; |
865bf07f381f
Basic hgignore handling
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
217 } |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
218 |
50
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
24
diff
changeset
|
219 @Override |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
24
diff
changeset
|
220 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
|
221 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
|
222 } |
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
24
diff
changeset
|
223 |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
224 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
|
225 |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
226 /** |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
227 * 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
|
228 */ |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
229 @Override |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
230 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
|
231 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
|
232 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
|
233 if (cached != null) { |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
234 return cached; |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
235 } |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
236 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
|
237 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
|
238 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
|
239 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
|
240 return s; |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
241 } |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
242 return null; |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
243 } |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
244 |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
245 @Override |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
246 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
|
247 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
|
248 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
|
249 RevlogStream content = resolve(storagePath); |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
250 // 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
|
251 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
|
252 } |
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
|
253 |
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
|
254 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
|
255 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
|
256 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
|
257 private boolean dotencode; |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
258 |
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
|
259 |
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
|
260 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
|
261 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
|
262 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
|
263 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
|
264 } |
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
|
265 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
|
266 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
|
267 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
|
268 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
|
269 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
|
270 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
|
271 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
|
272 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
|
273 } |
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
|
274 } 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
|
275 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
|
276 } |
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
|
277 } |
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
|
278 |
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
|
279 // 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
|
280 // 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
|
281 // 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
|
282 // 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
|
283 // @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
|
284 @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
|
285 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
|
286 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
|
287 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
|
288 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
|
289 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
|
290 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
|
291 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
|
292 } |
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
|
293 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
|
294 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
|
295 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
|
296 // 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
|
297 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
|
298 // 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 } 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
|
306 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
|
307 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
|
308 } 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
|
309 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
|
310 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
|
311 } 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
|
312 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
|
313 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
|
314 } 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
|
315 // 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
|
316 // 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
|
317 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
|
318 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
|
319 } 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
|
320 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
|
321 } |
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
|
322 } |
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
|
323 // 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
|
324 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
|
325 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
|
326 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
|
327 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
|
328 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
|
329 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
|
330 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
|
331 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
|
332 } |
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
|
333 // 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
|
334 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
|
335 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
|
336 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
|
337 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
|
338 } 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
|
339 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
|
340 } 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
|
341 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
|
342 } |
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
|
343 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
|
344 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
|
345 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
|
346 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
|
347 } |
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
|
348 } |
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
|
349 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
|
350 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
|
351 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
|
352 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
|
353 } |
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
|
354 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
|
355 } 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
|
356 } |
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
|
357 } |
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
|
358 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
|
359 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
|
360 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
|
361 } |
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
|
362 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
|
363 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
|
364 } |
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
|
365 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
|
366 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
|
367 } |
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
|
368 |
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
|
369 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
|
370 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
|
371 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
|
372 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
|
373 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
|
374 return buf; |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
375 } |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
376 |
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
|
377 // 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
|
378 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
|
379 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
|
380 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
|
381 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
|
382 } |
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
|
383 return path; |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
1
diff
changeset
|
384 } |
1
a3576694a4d1
Repository detection from local/specified directory
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
385 } |