comparison src/org/tmatesoft/hg/internal/RevlogStream.java @ 621:99ad1e3a4e4d

RevlogStream: be aware of existence (not HgDataFile), facilitate use of an added HgDataFile over a commit; Rollback: be more sensitive about file changes (file size is not enough: write/rollback leaves it intact); tests
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 18 May 2013 22:23:57 +0200
parents 65c01508f002
children 6526d8adbc0f
comparison
equal deleted inserted replaced
620:272ecffccc8a 621:99ad1e3a4e4d
83 public RevlogStream(Internals hgRepo, File indexFile) { 83 public RevlogStream(Internals hgRepo, File indexFile) {
84 repo = hgRepo; 84 repo = hgRepo;
85 this.indexFile = indexFile; 85 this.indexFile = indexFile;
86 changeTracker = repo.getRevlogTracker(indexFile); 86 changeTracker = repo.getRevlogTracker(indexFile);
87 } 87 }
88
89 public boolean exists() {
90 return indexFile.exists();
91 }
88 92
89 /** 93 /**
90 * @param shortRead pass <code>true</code> to indicate intention to read few revisions only (as opposed to reading most of/complete revlog) 94 * @param shortRead pass <code>true</code> to indicate intention to read few revisions only (as opposed to reading most of/complete revlog)
91 * @return never <code>null</code>, empty {@link DataAccess} if no stream is available 95 * @return never <code>null</code>, empty {@link DataAccess} if no stream is available
92 */ 96 */
406 // baseRevisionIndex MAY be == to baseRevisions.length, it's when new revision is based on itself 410 // baseRevisionIndex MAY be == to baseRevisions.length, it's when new revision is based on itself
407 throw new HgInvalidControlFileException(String.format("Base revision index %d doesn't fit [0..%d] range", baseRevisionIndex, baseRevisions.length), null, indexFile); 411 throw new HgInvalidControlFileException(String.format("Base revision index %d doesn't fit [0..%d] range", baseRevisionIndex, baseRevisions.length), null, indexFile);
408 } 412 }
409 assert revision != null; 413 assert revision != null;
410 assert !revision.isNull(); 414 assert !revision.isNull();
415 // next effort doesn't seem to be of any value at least in case of regular commit
416 // as the next call to #initOutline would recognize the file change and reload complete revlog anyway
417 // OTOH, there might be transaction strategy that doesn't update the file until its completion,
418 // while it's handy to know new revisions meanwhile.
411 int[] baseRevisionsCopy = new int[baseRevisions.length + 1]; 419 int[] baseRevisionsCopy = new int[baseRevisions.length + 1];
412 System.arraycopy(baseRevisions, 0, baseRevisionsCopy, 0, baseRevisions.length); 420 System.arraycopy(baseRevisions, 0, baseRevisionsCopy, 0, baseRevisions.length);
413 baseRevisionsCopy[baseRevisions.length] = baseRevisionIndex; 421 baseRevisionsCopy[baseRevisions.length] = baseRevisionIndex;
414 baseRevisions = baseRevisionsCopy; 422 baseRevisions = baseRevisionsCopy;
415 if (inline && indexRecordOffset != null) { 423 if (inline && indexRecordOffset != null) {