Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgManifest.java @ 424:6437d261048a
Deprecated code removed
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 28 Mar 2012 15:42:15 +0200 |
parents | 9c9c442b5f2e |
children | 48f993aa2f41 |
comparison
equal
deleted
inserted
replaced
423:9c9c442b5f2e | 424:6437d261048a |
---|---|
335 | 335 |
336 @Callback | 336 @Callback |
337 public interface Inspector { | 337 public interface Inspector { |
338 boolean begin(int mainfestRevision, Nodeid nid, int changelogRevision); | 338 boolean begin(int mainfestRevision, Nodeid nid, int changelogRevision); |
339 /** | 339 /** |
340 * @deprecated switch to {@link HgManifest.Inspector2#next(Nodeid, Path, HgManifest.Flags)} | |
341 */ | |
342 @Deprecated | |
343 boolean next(Nodeid nid, String fname, String flags); | |
344 boolean end(int manifestRevision); | |
345 } | |
346 | |
347 @Experimental(reason="Explore Path alternative for filenames and enum for flags") | |
348 @Callback | |
349 public interface Inspector2 extends Inspector { | |
350 /** | |
351 * @param nid file revision | 340 * @param nid file revision |
352 * @param fname file name | 341 * @param fname file name |
353 * @param flags one of {@link HgManifest.Flags} constants, not <code>null</code> | 342 * @param flags one of {@link HgManifest.Flags} constants, not <code>null</code> |
354 * @return <code>true</code> to continue iteration, <code>false</code> to stop | 343 * @return <code>true</code> to continue iteration, <code>false</code> to stop |
355 */ | 344 */ |
356 boolean next(Nodeid nid, Path fname, Flags flags); | 345 boolean next(Nodeid nid, Path fname, Flags flags); |
357 } | 346 boolean end(int manifestRevision); |
358 | 347 } |
348 | |
359 /** | 349 /** |
360 * When Pool uses Strings directly, | 350 * When Pool uses Strings directly, |
361 * ManifestParser creates new String instance with new char[] value, and does byte->char conversion. | 351 * ManifestParser creates new String instance with new char[] value, and does byte->char conversion. |
362 * For cpython repo, walk(0..10k), there are over 16 million filenames, of them only 3020 unique. | 352 * For cpython repo, walk(0..10k), there are over 16 million filenames, of them only 3020 unique. |
363 * This means there are 15.9 million useless char[] instances and byte->char conversions | 353 * This means there are 15.9 million useless char[] instances and byte->char conversions |
427 } | 417 } |
428 } | 418 } |
429 | 419 |
430 private static class ManifestParser implements RevlogStream.Inspector, Lifecycle { | 420 private static class ManifestParser implements RevlogStream.Inspector, Lifecycle { |
431 private final Inspector inspector; | 421 private final Inspector inspector; |
432 private final Inspector2 inspector2; | |
433 private Pool2<Nodeid> nodeidPool, thisRevPool; | 422 private Pool2<Nodeid> nodeidPool, thisRevPool; |
434 private final Pool2<PathProxy> fnamePool; | 423 private final Pool2<PathProxy> fnamePool; |
435 private byte[] nodeidLookupBuffer = new byte[20]; // get reassigned each time new Nodeid is added to pool | 424 private byte[] nodeidLookupBuffer = new byte[20]; // get reassigned each time new Nodeid is added to pool |
436 private final ProgressSupport progressHelper; | 425 private final ProgressSupport progressHelper; |
437 private IterateControlMediator iterateControl; | 426 private IterateControlMediator iterateControl; |
438 private final EncodingHelper encHelper; | 427 private final EncodingHelper encHelper; |
439 | 428 |
440 public ManifestParser(Inspector delegate, EncodingHelper eh) { | 429 public ManifestParser(Inspector delegate, EncodingHelper eh) { |
441 assert delegate != null; | 430 assert delegate != null; |
442 inspector = delegate; | 431 inspector = delegate; |
443 inspector2 = delegate instanceof Inspector2 ? (Inspector2) delegate : null; | |
444 encHelper = eh; | 432 encHelper = eh; |
445 nodeidPool = new Pool2<Nodeid>(); | 433 nodeidPool = new Pool2<Nodeid>(); |
446 fnamePool = new Pool2<PathProxy>(); | 434 fnamePool = new Pool2<PathProxy>(); |
447 thisRevPool = new Pool2<Nodeid>(); | 435 thisRevPool = new Pool2<Nodeid>(); |
448 progressHelper = ProgressSupport.Factory.get(delegate); | 436 progressHelper = ProgressSupport.Factory.get(delegate); |
491 // for cpython 0..10k, there are 4361062 flag checks, and there's only 1 unique flag | 479 // for cpython 0..10k, there are 4361062 flag checks, and there's only 1 unique flag |
492 flags = Flags.parse(data, x + nodeidLen, i-x-nodeidLen); | 480 flags = Flags.parse(data, x + nodeidLen, i-x-nodeidLen); |
493 } else { | 481 } else { |
494 flags = Flags.RegularFile; | 482 flags = Flags.RegularFile; |
495 } | 483 } |
496 boolean good2go; | 484 boolean good2go = inspector.next(nid, fname, flags); |
497 if (inspector2 == null) { | |
498 String flagString = flags == Flags.RegularFile ? null : flags.nativeString(); | |
499 good2go = inspector.next(nid, fname.toString(), flagString); | |
500 } else { | |
501 good2go = inspector2.next(nid, fname, flags); | |
502 } | |
503 if (!good2go) { | 485 if (!good2go) { |
504 iterateControl.stop(); | 486 iterateControl.stop(); |
505 return; | 487 return; |
506 } | 488 } |
507 } | 489 } |