Mercurial > hg4j
annotate src/com/tmate/hgkit/ll/LocalHgRepo.java @ 66:52dc3f4cfc76
Primitive test suite in org.tmatesoft
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> | 
|---|---|
| date | Fri, 21 Jan 2011 18:20:05 +0100 | 
| parents | 19e9e220bf68 | 
| children | 
| rev | line source | 
|---|---|
| 10 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
9diff
changeset | 1 /* | 
| 20 
11cfabe692b3
Status operation for two repository revisions (no local dir involved)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
18diff
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 | 
| 8 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 6 import java.io.BufferedReader; | 
| 1 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 7 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: 
3diff
changeset | 8 import java.io.FileInputStream; | 
| 1 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 9 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: 
3diff
changeset | 10 import java.io.InputStreamReader; | 
| 3 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 11 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: 
3diff
changeset | 12 import java.util.Arrays; | 
| 3 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 13 import java.util.HashMap; | 
| 8 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 14 import java.util.TreeSet; | 
| 1 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 15 | 
| 64 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 16 import org.tmatesoft.hg.core.Path; | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 17 import org.tmatesoft.hg.util.PathRewrite; | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 18 | 
| 10 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
9diff
changeset | 19 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: 
57diff
changeset | 20 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: 
9diff
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: 
3diff
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: 
9diff
changeset | 29 private final DataAccessProvider dataAccess; | 
| 64 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 30 private final PathRewrite normalizePath = new PathRewrite() { | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 31 | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 32 public String rewrite(String path) { | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 33 return normalize(path); | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 34 } | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 35 }; | 
| 1 
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(String repositoryPath) { | 
| 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 38 setInvalid(true); | 
| 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 39 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: 
57diff
changeset | 40 dataAccess = null; | 
| 1 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 41 } | 
| 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 42 | 
| 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 43 public LocalHgRepo(File repositoryRoot) throws IOException { | 
| 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 44 assert ".hg".equals(repositoryRoot.getName()) && repositoryRoot.isDirectory(); | 
| 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 45 setInvalid(false); | 
| 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 46 repoDir = repositoryRoot; | 
| 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 47 repoLocation = repositoryRoot.getParentFile().getCanonicalPath(); | 
| 10 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
9diff
changeset | 48 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: 
3diff
changeset | 49 parseRequires(); | 
| 1 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 50 } | 
| 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 51 | 
| 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 52 @Override | 
| 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 53 public String getLocation() { | 
| 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 54 return repoLocation; | 
| 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 55 } | 
| 18 
02ee376bee79
status operation against current working directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
15diff
changeset | 56 | 
| 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: 
57diff
changeset | 57 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: 
57diff
changeset | 58 return new FileWalker(repoDir.getParentFile()); | 
| 57 
8b0d6f1bd6b4
Local status is back
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
55diff
changeset | 59 } | 
| 
8b0d6f1bd6b4
Local status is back
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
55diff
changeset | 60 | 
| 10 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
9diff
changeset | 61 // 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) | 
| 59 
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
58diff
changeset | 62 final HgDirstate loadDirstate() { | 
| 
b771e94a4f7c
Introduce Internals to keep LocalHgRepo casts and alike in a single place. WCSC optionally to reuse SC data
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
58diff
changeset | 63 return new HgDirstate(getDataAccess(), new File(repoDir, "dirstate")); | 
| 10 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
9diff
changeset | 64 } | 
| 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
9diff
changeset | 65 | 
| 15 
865bf07f381f
Basic hgignore handling
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
10diff
changeset | 66 // package-local, see comment for loadDirstate | 
| 
865bf07f381f
Basic hgignore handling
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
10diff
changeset | 67 public final HgIgnore loadIgnore() { | 
| 
865bf07f381f
Basic hgignore handling
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
10diff
changeset | 68 return new HgIgnore(this); | 
| 
865bf07f381f
Basic hgignore handling
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
10diff
changeset | 69 } | 
| 
865bf07f381f
Basic hgignore handling
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
10diff
changeset | 70 | 
| 10 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
9diff
changeset | 71 /*package-local*/ DataAccessProvider getDataAccess() { | 
| 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
9diff
changeset | 72 return dataAccess; | 
| 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
9diff
changeset | 73 } | 
| 15 
865bf07f381f
Basic hgignore handling
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
10diff
changeset | 74 | 
| 
865bf07f381f
Basic hgignore handling
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
10diff
changeset | 75 /*package-local*/ File getRepositoryRoot() { | 
| 
865bf07f381f
Basic hgignore handling
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
10diff
changeset | 76 return repoDir; | 
| 
865bf07f381f
Basic hgignore handling
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
10diff
changeset | 77 } | 
| 10 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
9diff
changeset | 78 | 
| 50 
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
24diff
changeset | 79 @Override | 
| 
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
24diff
changeset | 80 protected HgTags createTags() { | 
| 
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
24diff
changeset | 81 return new HgTags(); | 
| 
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
24diff
changeset | 82 } | 
| 
f1db8610da62
Log to consult (placeholder, for now) class to find out associated tags
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
24diff
changeset | 83 | 
| 3 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 84 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: 
1diff
changeset | 85 | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 86 /** | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 87 * 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: 
1diff
changeset | 88 */ | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 89 @Override | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 90 protected RevlogStream resolve(String path) { | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 91 final SoftReference<RevlogStream> ref = streamsCache.get(path); | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 92 RevlogStream cached = ref == null ? null : ref.get(); | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 93 if (cached != null) { | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 94 return cached; | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 95 } | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 96 File f = new File(repoDir, path); | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 97 if (f.exists()) { | 
| 10 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
9diff
changeset | 98 RevlogStream s = new RevlogStream(dataAccess, f); | 
| 3 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 99 streamsCache.put(path, new SoftReference<RevlogStream>(s)); | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 100 return s; | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 101 } | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 102 return null; | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 103 } | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 104 | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 105 @Override | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 106 public HgDataFile getFileNode(String path) { | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 107 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: 
3diff
changeset | 108 String storagePath = toStoragePath(nPath, true); | 
| 3 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 109 RevlogStream content = resolve(storagePath); | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 110 // 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: 
1diff
changeset | 111 return new HgDataFile(this, nPath, content); | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 112 } | 
| 8 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 113 | 
| 64 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 114 @Override | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 115 public HgDataFile getFileNode(Path path) { | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 116 return getFileNode(path.toString()); | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 117 } | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 118 | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 119 @Override | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 120 public PathRewrite getPathHelper() { | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 121 return normalizePath; | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 122 } | 
| 
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
59diff
changeset | 123 | 
| 8 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 124 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: 
3diff
changeset | 125 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: 
3diff
changeset | 126 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: 
3diff
changeset | 127 private boolean dotencode; | 
| 3 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 128 | 
| 8 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 129 | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 130 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: 
3diff
changeset | 131 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: 
3diff
changeset | 132 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: 
3diff
changeset | 133 return; | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 134 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 135 try { | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 136 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: 
3diff
changeset | 137 String line; | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 138 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: 
3diff
changeset | 139 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: 
3diff
changeset | 140 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: 
3diff
changeset | 141 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: 
3diff
changeset | 142 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: 
3diff
changeset | 143 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 144 } 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: 
3diff
changeset | 145 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: 
3diff
changeset | 146 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 147 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 148 | 
| 9 
d6d2a630f4a6
Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
8diff
changeset | 149 // 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: 
8diff
changeset | 150 // 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: 
8diff
changeset | 151 // we shall assume path has extension | 
| 3 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 152 // 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: 
3diff
changeset | 153 // @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: 
8diff
changeset | 154 @Override | 
| 8 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 155 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: 
3diff
changeset | 156 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: 
3diff
changeset | 157 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: 
3diff
changeset | 158 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: 
3diff
changeset | 159 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: 
3diff
changeset | 160 if (!data) { | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 161 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: 
3diff
changeset | 162 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 163 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: 
3diff
changeset | 164 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: 
3diff
changeset | 165 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: 
3diff
changeset | 166 // encodefilename | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 167 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: 
3diff
changeset | 168 // 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: 
3diff
changeset | 169 int x; | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 170 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: 
3diff
changeset | 171 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: 
3diff
changeset | 172 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: 
3diff
changeset | 173 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: 
3diff
changeset | 174 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: 
3diff
changeset | 175 } 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: 
3diff
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: 
3diff
changeset | 177 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: 
3diff
changeset | 178 } 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: 
3diff
changeset | 179 sb.append('~'); | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 180 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: 
3diff
changeset | 181 } 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: 
3diff
changeset | 182 sb.append('~'); | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 183 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: 
3diff
changeset | 184 } 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: 
3diff
changeset | 185 // 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: 
3diff
changeset | 186 // 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: 
3diff
changeset | 187 sb.append('_'); | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 188 sb.append('_'); | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 189 } else { | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 190 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: 
3diff
changeset | 191 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 192 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 193 // auxencode | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 194 if (fncache) { | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 195 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: 
3diff
changeset | 196 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: 
3diff
changeset | 197 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: 
3diff
changeset | 198 do { | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 199 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: 
3diff
changeset | 200 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: 
3diff
changeset | 201 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: 
3diff
changeset | 202 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 203 // 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: 
3diff
changeset | 204 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: 
3diff
changeset | 205 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: 
3diff
changeset | 206 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: 
3diff
changeset | 207 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: 
3diff
changeset | 208 } 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: 
3diff
changeset | 209 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: 
3diff
changeset | 210 } 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: 
3diff
changeset | 211 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: 
3diff
changeset | 212 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 213 if (found) { | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 214 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: 
3diff
changeset | 215 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: 
3diff
changeset | 216 i += 2; | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 217 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 218 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 219 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: 
3diff
changeset | 220 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: 
3diff
changeset | 221 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: 
3diff
changeset | 222 i += 2; | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 223 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 224 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: 
3diff
changeset | 225 } 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: 
3diff
changeset | 226 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 227 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 228 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: 
3diff
changeset | 229 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: 
3diff
changeset | 230 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: 
3diff
changeset | 231 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 232 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: 
3diff
changeset | 233 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: 
3diff
changeset | 234 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 235 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: 
3diff
changeset | 236 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: 
3diff
changeset | 237 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 238 | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 239 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: 
3diff
changeset | 240 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: 
3diff
changeset | 241 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: 
8diff
changeset | 242 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: 
3diff
changeset | 243 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: 
3diff
changeset | 244 return buf; | 
| 3 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 245 } | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 246 | 
| 9 
d6d2a630f4a6
Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
8diff
changeset | 247 // 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: 
1diff
changeset | 248 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: 
3diff
changeset | 249 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: 
3diff
changeset | 250 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: 
3diff
changeset | 251 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: 
3diff
changeset | 252 } | 
| 
a78c980749e3
Filename mangling according to requires options of the store (fncache incomplete for long names)
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 253 return path; | 
| 3 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
1diff
changeset | 254 } | 
| 1 
a3576694a4d1
Repository detection from local/specified directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 255 } | 
