Mercurial > hg4j
annotate src/org/tmatesoft/hg/repo/HgDirstate.java @ 284:7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> | 
|---|---|
| date | Sat, 03 Sep 2011 13:12:13 +0200 | 
| parents | 35125450c804 | 
| children | 8faad08c709b | 
| rev | line source | 
|---|---|
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
1 /* | 
| 
74
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
2 * Copyright (c) 2010-2011 TMate Software Ltd | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
3 * | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
4 * This program is free software; you can redistribute it and/or modify | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
5 * it under the terms of the GNU General Public License as published by | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
6 * the Free Software Foundation; version 2 of the License. | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
7 * | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
8 * This program is distributed in the hope that it will be useful, | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
11 * GNU General Public License for more details. | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
12 * | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
13 * For information on how to redistribute this software under | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
14 * the terms of a license other than GNU General Public License | 
| 
102
 
a3a2e5deb320
Updated contact address to support@hg4j.com
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
93 
diff
changeset
 | 
15 * contact TMate Software at support@hg4j.com | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
16 */ | 
| 
74
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
17 package org.tmatesoft.hg.repo; | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
18 | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
19 import static org.tmatesoft.hg.core.Nodeid.NULL; | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
20 | 
| 
252
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
21 import java.io.BufferedReader; | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
22 import java.io.File; | 
| 
252
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
23 import java.io.FileReader; | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
24 import java.io.IOException; | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
25 import java.util.Collections; | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
26 import java.util.LinkedHashMap; | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
27 import java.util.Map; | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
28 import java.util.TreeSet; | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
29 | 
| 
231
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
30 import org.tmatesoft.hg.core.HgBadStateException; | 
| 
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
31 import org.tmatesoft.hg.core.Nodeid; | 
| 
74
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
32 import org.tmatesoft.hg.internal.DataAccess; | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
33 import org.tmatesoft.hg.util.Pair; | 
| 
141
 
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
102 
diff
changeset
 | 
34 import org.tmatesoft.hg.util.Path; | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
35 import org.tmatesoft.hg.util.PathPool; | 
| 
74
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
36 | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
37 | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
38 /** | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
39 * @see http://mercurial.selenic.com/wiki/DirState | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
40 * @see http://mercurial.selenic.com/wiki/FileFormats#dirstate | 
| 
74
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
41 * | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
42 * @author Artem Tikhomirov | 
| 
 
6f1b88693d48
Complete refactoring to org.tmatesoft
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
59 
diff
changeset
 | 
43 * @author TMate Software Ltd. | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
44 */ | 
| 
252
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
45 class HgDirstate /* XXX RepoChangeListener */{ | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
46 | 
| 
252
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
47 private final HgRepository repo; | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
48 private final File dirstateFile; | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
49 private final PathPool pathPool; | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
50 private Map<Path, Record> normal; | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
51 private Map<Path, Record> added; | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
52 private Map<Path, Record> removed; | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
53 private Map<Path, Record> merged; | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
54 private Pair<Nodeid, Nodeid> parents; | 
| 
252
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
55 private String currentBranch; | 
| 
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
56 | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
57 public HgDirstate(HgRepository hgRepo, File dirstate, PathPool pathPool) { | 
| 
252
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
58 repo = hgRepo; | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
59 dirstateFile = dirstate; // XXX decide whether file names shall be kept local to reader (see #branches()) or passed from outside | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
60 this.pathPool = pathPool; | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
61 } | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
62 | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
63 private void read() { | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
64 normal = added = removed = merged = Collections.<Path, Record>emptyMap(); | 
| 
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: 
18 
diff
changeset
 | 
65 if (dirstateFile == null || !dirstateFile.exists()) { | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
66 return; | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
67 } | 
| 
252
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
68 DataAccess da = repo.getDataAccess().create(dirstateFile); | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
69 if (da.isEmpty()) { | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
70 return; | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
71 } | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
72 // not sure linked is really needed here, just for ease of debug | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
73 normal = new LinkedHashMap<Path, Record>(); | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
74 added = new LinkedHashMap<Path, Record>(); | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
75 removed = new LinkedHashMap<Path, Record>(); | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
76 merged = new LinkedHashMap<Path, Record>(); | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
77 try { | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
78 parents = internalReadParents(da); | 
| 
227
 
0fd10e5016dd
IOException on empty repository with 40-byte dirstate
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
141 
diff
changeset
 | 
79 // hg init; hg up produces an empty repository where dirstate has parents (40 bytes) only | 
| 
 
0fd10e5016dd
IOException on empty repository with 40-byte dirstate
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
141 
diff
changeset
 | 
80 while (!da.isEmpty()) { | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
81 final byte state = da.readByte(); | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
82 final int fmode = da.readInt(); | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
83 final int size = da.readInt(); | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
84 final int time = da.readInt(); | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
85 final int nameLen = da.readInt(); | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
86 String fn1 = null, fn2 = null; | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
87 byte[] name = new byte[nameLen]; | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
88 da.readBytes(name, 0, nameLen); | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
89 for (int i = 0; i < nameLen; i++) { | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
90 if (name[i] == 0) { | 
| 
11
 
d46773d89a19
Boundary error in dirstate entry, explicit encoding to face troubles (if any) asap.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
10 
diff
changeset
 | 
91 fn1 = new String(name, 0, i, "UTF-8"); // XXX unclear from documentation what encoding is used there | 
| 
 
d46773d89a19
Boundary error in dirstate entry, explicit encoding to face troubles (if any) asap.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
10 
diff
changeset
 | 
92 fn2 = new String(name, i+1, nameLen - i - 1, "UTF-8"); // need to check with different system codepages | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
93 break; | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
94 } | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
95 } | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
96 if (fn1 == null) { | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
97 fn1 = new String(name); | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
98 } | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
99 Record r = new Record(fmode, size, time, pathPool.path(fn1), fn2 == null ? null : pathPool.path(fn2)); | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
100 if (state == 'n') { | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
101 normal.put(r.name1, r); | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
102 } else if (state == 'a') { | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
103 added.put(r.name1, r); | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
104 } else if (state == 'r') { | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
105 removed.put(r.name1, r); | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
106 } else if (state == 'm') { | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
107 merged.put(r.name1, r); | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
108 } else { | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
109 // FIXME log error? | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
110 } | 
| 
227
 
0fd10e5016dd
IOException on empty repository with 40-byte dirstate
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
141 
diff
changeset
 | 
111 } | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
112 } catch (IOException ex) { | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
113 ex.printStackTrace(); // FIXME log error, clean dirstate? | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
114 } finally { | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
115 da.done(); | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
116 } | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
117 } | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
118 | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
119 private static Pair<Nodeid, Nodeid> internalReadParents(DataAccess da) throws IOException { | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
120 byte[] parents = new byte[40]; | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
121 da.readBytes(parents, 0, 40); | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
122 Nodeid n1 = Nodeid.fromBinary(parents, 0); | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
123 Nodeid n2 = Nodeid.fromBinary(parents, 20); | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
124 parents = null; | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
125 return new Pair<Nodeid, Nodeid>(n1, n2); | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
126 } | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
127 | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
128 /** | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
129 * @return array of length 2 with working copy parents, non null. | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
130 */ | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
131 public Pair<Nodeid,Nodeid> parents() { | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
132 if (parents == null) { | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
133 parents = readParents(repo, dirstateFile); | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
134 } | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
135 return parents; | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
136 } | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
137 | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
138 /** | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
139 * @return pair of parents, both {@link Nodeid#NULL} if dirstate is not available | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
140 */ | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
141 public static Pair<Nodeid, Nodeid> readParents(HgRepository repo, File dirstateFile) { | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
142 // do not read whole dirstate if all we need is WC parent information | 
| 
231
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
143 if (dirstateFile == null || !dirstateFile.exists()) { | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
144 return new Pair<Nodeid,Nodeid>(NULL, NULL); | 
| 
231
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
145 } | 
| 
252
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
146 DataAccess da = repo.getDataAccess().create(dirstateFile); | 
| 
231
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
147 if (da.isEmpty()) { | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
148 return new Pair<Nodeid,Nodeid>(NULL, NULL); | 
| 
231
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
149 } | 
| 
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
150 try { | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
151 return internalReadParents(da); | 
| 
231
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
152 } catch (IOException ex) { | 
| 
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
153 throw new HgBadStateException(ex); // XXX in fact, our exception is not the best solution here. | 
| 
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
154 } finally { | 
| 
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
155 da.done(); | 
| 
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
156 } | 
| 
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
157 } | 
| 
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
158 | 
| 
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
159 /** | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
160 * XXX is it really proper place for the method? | 
| 
252
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
161 * @return branch associated with the working directory | 
| 
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
162 */ | 
| 
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
163 public String branch() { | 
| 
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
164 if (currentBranch == null) { | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
165 currentBranch = readBranch(repo); | 
| 
252
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
166 } | 
| 
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
167 return currentBranch; | 
| 
 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
231 
diff
changeset
 | 
168 } | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
169 | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
170 /** | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
171 * XXX is it really proper place for the method? | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
172 * @return branch associated with the working directory | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
173 */ | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
174 public static String readBranch(HgRepository repo) { | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
175 String branch = HgRepository.DEFAULT_BRANCH_NAME; | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
176 File branchFile = new File(repo.getRepositoryRoot(), "branch"); | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
177 if (branchFile.exists()) { | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
178 try { | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
179 BufferedReader r = new BufferedReader(new FileReader(branchFile)); | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
180 String b = r.readLine(); | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
181 if (b != null) { | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
182 b = b.trim().intern(); | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
183 } | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
184 branch = b == null || b.length() == 0 ? HgRepository.DEFAULT_BRANCH_NAME : b; | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
185 r.close(); | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
186 } catch (IOException ex) { | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
187 ex.printStackTrace(); // XXX log verbose debug, exception might be legal here (i.e. FileNotFound) | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
188 // IGNORE | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
189 } | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
190 } | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
191 return branch; | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
192 } | 
| 
231
 
1792b37650f2
Introduced access to conflict resolution information (merge state)
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
227 
diff
changeset
 | 
193 | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
194 // new, modifiable collection | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
195 /*package-local*/ TreeSet<Path> all() { | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
196 read(); | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
197 TreeSet<Path> rv = new TreeSet<Path>(); | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
198 @SuppressWarnings("unchecked") | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
199 Map<Path, Record>[] all = new Map[] { normal, added, removed, merged }; | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
200 for (int i = 0; i < all.length; i++) { | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
201 for (Record r : all[i].values()) { | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
202 rv.add(r.name1); | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
203 } | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
204 } | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
205 return rv; | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
206 } | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
207 | 
| 
141
 
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
102 
diff
changeset
 | 
208 /*package-local*/ Record checkNormal(Path fname) { | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
209 return normal.get(fname); | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
210 } | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
211 | 
| 
141
 
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
102 
diff
changeset
 | 
212 /*package-local*/ Record checkAdded(Path fname) { | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
213 return added.get(fname); | 
| 
141
 
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
102 
diff
changeset
 | 
214 } | 
| 
 
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
102 
diff
changeset
 | 
215 /*package-local*/ Record checkRemoved(Path fname) { | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
216 return removed.get(fname); | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
217 } | 
| 
141
 
8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
102 
diff
changeset
 | 
218 /*package-local*/ Record checkMerged(Path fname) { | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
219 return merged.get(fname); | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
220 } | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
221 | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
222 | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
223 | 
| 
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
224 | 
| 
93
 
d55d4eedfc57
Switch to Path instead of String in filenames returned by various status operations
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
74 
diff
changeset
 | 
225 /*package-local*/ void dump() { | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
226 read(); | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
227 @SuppressWarnings("unchecked") | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
228 Map<Path, Record>[] all = new Map[] { normal, added, removed, merged }; | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
229 char[] x = new char[] {'n', 'a', 'r', 'm' }; | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
230 for (int i = 0; i < all.length; i++) { | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
231 for (Record r : all[i].values()) { | 
| 
14
 
442dc6ee647b
Show correct time
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
12 
diff
changeset
 | 
232 System.out.printf("%c %3o%6d %30tc\t\t%s", x[i], r.mode, r.size, (long) r.time * 1000, r.name1); | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
233 if (r.name2 != null) { | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
234 System.out.printf(" --> %s", r.name2); | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
235 } | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
236 System.out.println(); | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
237 } | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
238 System.out.println(); | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
239 } | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
240 } | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
241 | 
| 
18
 
02ee376bee79
status operation against current working directory
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
14 
diff
changeset
 | 
242 /*package-local*/ static class Record { | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
243 final int mode; | 
| 
280
 
35125450c804
Erroneous and slow status for working copies based on non-tip revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
252 
diff
changeset
 | 
244 // it seems Dirstate keeps local file size (i.e. that with any filters already applied). | 
| 
 
35125450c804
Erroneous and slow status for working copies based on non-tip revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
252 
diff
changeset
 | 
245 // Thus, can't compare directly to HgDataFile.length() | 
| 
 
35125450c804
Erroneous and slow status for working copies based on non-tip revision
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
252 
diff
changeset
 | 
246 final int size; | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
247 final int time; | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
248 final Path name1; | 
| 
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
249 final Path name2; | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
250 | 
| 
284
 
7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents: 
280 
diff
changeset
 | 
251 public Record(int fmode, int fsize, int ftime, Path name1, Path name2) { | 
| 
10
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
252 mode = fmode; | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
253 size = fsize; | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
254 time = ftime; | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
255 this.name1 = name1; | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
256 this.name2 = name2; | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
257 | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
258 } | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
259 } | 
| 
 
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
 
Artem Tikhomirov <tikhomirov.artem@gmail.com> 
parents:  
diff
changeset
 | 
260 } | 
