comparison src/org/tmatesoft/hg/repo/HgDirstate.java @ 421:fdd7d756dea0 v0.8.5

Allow IOException from DataAccess methods for subclasses with non-trivial implementations, to avoid exception dumps when inapropriate
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 22 Mar 2012 23:09:11 +0100
parents 528b6780a8bd
children 9c9c442b5f2e
comparison
equal deleted inserted replaced
420:6c22bdc0bdfd 421:fdd7d756dea0
85 } 85 }
86 if (dirstateFile == null || !dirstateFile.exists()) { 86 if (dirstateFile == null || !dirstateFile.exists()) {
87 return; 87 return;
88 } 88 }
89 DataAccess da = repo.getDataAccess().create(dirstateFile); 89 DataAccess da = repo.getDataAccess().create(dirstateFile);
90 if (da.isEmpty()) {
91 return;
92 }
93 // not sure linked is really needed here, just for ease of debug
94 normal = new LinkedHashMap<Path, Record>();
95 added = new LinkedHashMap<Path, Record>();
96 removed = new LinkedHashMap<Path, Record>();
97 merged = new LinkedHashMap<Path, Record>();
98 try { 90 try {
91 if (da.isEmpty()) {
92 return;
93 }
94 // not sure linked is really needed here, just for ease of debug
95 normal = new LinkedHashMap<Path, Record>();
96 added = new LinkedHashMap<Path, Record>();
97 removed = new LinkedHashMap<Path, Record>();
98 merged = new LinkedHashMap<Path, Record>();
99
99 parents = internalReadParents(da); 100 parents = internalReadParents(da);
100 // hg init; hg up produces an empty repository where dirstate has parents (40 bytes) only 101 // hg init; hg up produces an empty repository where dirstate has parents (40 bytes) only
101 while (!da.isEmpty()) { 102 while (!da.isEmpty()) {
102 final byte state = da.readByte(); 103 final byte state = da.readByte();
103 final int fmode = da.readInt(); 104 final int fmode = da.readInt();
177 // do not read whole dirstate if all we need is WC parent information 178 // do not read whole dirstate if all we need is WC parent information
178 if (dirstateFile == null || !dirstateFile.exists()) { 179 if (dirstateFile == null || !dirstateFile.exists()) {
179 return new Pair<Nodeid,Nodeid>(NULL, NULL); 180 return new Pair<Nodeid,Nodeid>(NULL, NULL);
180 } 181 }
181 DataAccess da = repo.getDataAccess().create(dirstateFile); 182 DataAccess da = repo.getDataAccess().create(dirstateFile);
182 if (da.isEmpty()) {
183 return new Pair<Nodeid,Nodeid>(NULL, NULL);
184 }
185 try { 183 try {
184 if (da.isEmpty()) {
185 return new Pair<Nodeid,Nodeid>(NULL, NULL);
186 }
186 return internalReadParents(da); 187 return internalReadParents(da);
187 } catch (IOException ex) { 188 } catch (IOException ex) {
188 throw new HgInvalidControlFileException("Error reading working copy parents from dirstate", ex, dirstateFile); 189 throw new HgInvalidControlFileException("Error reading working copy parents from dirstate", ex, dirstateFile);
189 } finally { 190 } finally {
190 da.done(); 191 da.done();