Mercurial > hg4j
comparison src/org/tmatesoft/hg/core/HgCloneCommand.java @ 190:9b99d27aeddc
More debug printouts
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 14 Apr 2011 02:48:06 +0200 |
parents | 44a34baabea0 |
children | 706bcc7cfee4 |
comparison
equal
deleted
inserted
replaced
189:e9d275fb0bc0 | 190:9b99d27aeddc |
---|---|
107 // 1. process changelog, memorize nodeids to index | 107 // 1. process changelog, memorize nodeids to index |
108 // 2. process manifest, using map from step 3, collect manifest nodeids | 108 // 2. process manifest, using map from step 3, collect manifest nodeids |
109 // 3. process every file, using map from 3, and consult set from step 4 to ensure repo is correct | 109 // 3. process every file, using map from 3, and consult set from step 4 to ensure repo is correct |
110 private static class WriteDownMate implements HgBundle.Inspector { | 110 private static class WriteDownMate implements HgBundle.Inspector { |
111 private final File hgDir; | 111 private final File hgDir; |
112 private final PathRewrite storagePathHelper; | |
112 private FileOutputStream indexFile; | 113 private FileOutputStream indexFile; |
113 private final PathRewrite storagePathHelper; | 114 private String filename; // human-readable name of the file being written, for log/exception purposes |
114 | 115 |
115 private final TreeMap<Nodeid, Integer> changelogIndexes = new TreeMap<Nodeid, Integer>(); | 116 private final TreeMap<Nodeid, Integer> changelogIndexes = new TreeMap<Nodeid, Integer>(); |
116 private boolean collectChangelogIndexes = false; | 117 private boolean collectChangelogIndexes = false; |
117 | 118 |
118 private int base = -1; | 119 private int base = -1; |
150 public void changelogStart() { | 151 public void changelogStart() { |
151 try { | 152 try { |
152 base = -1; | 153 base = -1; |
153 offset = 0; | 154 offset = 0; |
154 revisionSequence.clear(); | 155 revisionSequence.clear(); |
155 indexFile = new FileOutputStream(new File(hgDir, "store/00changelog.i")); | 156 indexFile = new FileOutputStream(new File(hgDir, filename = "store/00changelog.i")); |
156 collectChangelogIndexes = true; | 157 collectChangelogIndexes = true; |
157 } catch (IOException ex) { | 158 } catch (IOException ex) { |
158 throw new HgBadStateException(ex); | 159 throw new HgBadStateException(ex); |
159 } | 160 } |
160 } | 161 } |
166 prevRevContent = null; | 167 prevRevContent = null; |
167 } | 168 } |
168 collectChangelogIndexes = false; | 169 collectChangelogIndexes = false; |
169 indexFile.close(); | 170 indexFile.close(); |
170 indexFile = null; | 171 indexFile = null; |
172 filename = null; | |
171 } catch (IOException ex) { | 173 } catch (IOException ex) { |
172 throw new HgBadStateException(ex); | 174 throw new HgBadStateException(ex); |
173 } | 175 } |
174 } | 176 } |
175 | 177 |
176 public void manifestStart() { | 178 public void manifestStart() { |
177 try { | 179 try { |
178 base = -1; | 180 base = -1; |
179 offset = 0; | 181 offset = 0; |
180 revisionSequence.clear(); | 182 revisionSequence.clear(); |
181 indexFile = new FileOutputStream(new File(hgDir, "store/00manifest.i")); | 183 indexFile = new FileOutputStream(new File(hgDir, filename = "store/00manifest.i")); |
182 } catch (IOException ex) { | 184 } catch (IOException ex) { |
183 throw new HgBadStateException(ex); | 185 throw new HgBadStateException(ex); |
184 } | 186 } |
185 } | 187 } |
186 | 188 |
190 prevRevContent.done(); | 192 prevRevContent.done(); |
191 prevRevContent = null; | 193 prevRevContent = null; |
192 } | 194 } |
193 indexFile.close(); | 195 indexFile.close(); |
194 indexFile = null; | 196 indexFile = null; |
197 filename = null; | |
195 } catch (IOException ex) { | 198 } catch (IOException ex) { |
196 throw new HgBadStateException(ex); | 199 throw new HgBadStateException(ex); |
197 } | 200 } |
198 } | 201 } |
199 | 202 |
202 base = -1; | 205 base = -1; |
203 offset = 0; | 206 offset = 0; |
204 revisionSequence.clear(); | 207 revisionSequence.clear(); |
205 fncacheFiles.add("data/" + name + ".i"); // FIXME this is pure guess, | 208 fncacheFiles.add("data/" + name + ".i"); // FIXME this is pure guess, |
206 // need to investigate more how filenames are kept in fncache | 209 // need to investigate more how filenames are kept in fncache |
207 File file = new File(hgDir, storagePathHelper.rewrite(name)); | 210 File file = new File(hgDir, filename = storagePathHelper.rewrite(name)); |
208 file.getParentFile().mkdirs(); | 211 file.getParentFile().mkdirs(); |
209 indexFile = new FileOutputStream(file); | 212 indexFile = new FileOutputStream(file); |
210 } catch (IOException ex) { | 213 } catch (IOException ex) { |
211 throw new HgBadStateException(ex); | 214 throw new HgBadStateException(ex); |
212 } | 215 } |
218 prevRevContent.done(); | 221 prevRevContent.done(); |
219 prevRevContent = null; | 222 prevRevContent = null; |
220 } | 223 } |
221 indexFile.close(); | 224 indexFile.close(); |
222 indexFile = null; | 225 indexFile = null; |
226 filename = null; | |
223 } catch (IOException ex) { | 227 } catch (IOException ex) { |
224 throw new HgBadStateException(ex); | 228 throw new HgBadStateException(ex); |
225 } | 229 } |
226 } | 230 } |
227 | 231 |
233 if (revisionSequence.get(i).equals(p)) { | 237 if (revisionSequence.get(i).equals(p)) { |
234 return i; | 238 return i; |
235 } | 239 } |
236 } | 240 } |
237 } | 241 } |
238 throw new HgBadStateException(String.format("Can't find index of %s", p.shortNotation())); | 242 throw new HgBadStateException(String.format("Can't find index of %s for file %s", p.shortNotation(), filename)); |
239 } | 243 } |
240 | 244 |
241 public boolean element(GroupElement ge) { | 245 public boolean element(GroupElement ge) { |
242 try { | 246 try { |
243 assert indexFile != null; | 247 assert indexFile != null; |
250 } | 254 } |
251 byte[] content = ge.apply(prevRevContent); | 255 byte[] content = ge.apply(prevRevContent); |
252 byte[] calculated = dh.sha1(p1, p2, content).asBinary(); | 256 byte[] calculated = dh.sha1(p1, p2, content).asBinary(); |
253 final Nodeid node = ge.node(); | 257 final Nodeid node = ge.node(); |
254 if (!node.equalsTo(calculated)) { | 258 if (!node.equalsTo(calculated)) { |
255 throw new HgBadStateException("Checksum failed"); | 259 throw new HgBadStateException(String.format("Checksum failed: expected %s, calculated %s. File %s", node, calculated, filename)); |
256 } | 260 } |
257 final int link; | 261 final int link; |
258 if (collectChangelogIndexes) { | 262 if (collectChangelogIndexes) { |
259 changelogIndexes.put(node, revisionSequence.size()); | 263 changelogIndexes.put(node, revisionSequence.size()); |
260 link = revisionSequence.size(); | 264 link = revisionSequence.size(); |
261 } else { | 265 } else { |
262 Integer csRev = changelogIndexes.get(ge.cset()); | 266 Integer csRev = changelogIndexes.get(ge.cset()); |
263 if (csRev == null) { | 267 if (csRev == null) { |
264 throw new HgBadStateException(String.format("Changelog doesn't contain revision %s", ge.cset().shortNotation())); | 268 throw new HgBadStateException(String.format("Changelog doesn't contain revision %s of %s", ge.cset().shortNotation(), filename)); |
265 } | 269 } |
266 link = csRev.intValue(); | 270 link = csRev.intValue(); |
267 } | 271 } |
268 final int p1Rev = knownRevision(p1), p2Rev = knownRevision(p2); | 272 final int p1Rev = knownRevision(p1), p2Rev = knownRevision(p2); |
269 DataAccess patchContent = ge.rawData(); | 273 DataAccess patchContent = ge.rawData(); |