Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/RevlogStream.java @ 534:243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Mon, 04 Feb 2013 18:00:55 +0100 |
| parents | 0f6fa88e2162 |
| children | dd4f6311af52 |
comparison
equal
deleted
inserted
replaced
| 533:e6f72c9829a6 | 534:243202f1bda5 |
|---|---|
| 65 this.dataAccess = dap; | 65 this.dataAccess = dap; |
| 66 this.indexFile = indexFile; | 66 this.indexFile = indexFile; |
| 67 } | 67 } |
| 68 | 68 |
| 69 /*package*/ DataAccess getIndexStream() { | 69 /*package*/ DataAccess getIndexStream() { |
| 70 // TODO post 1.0 may supply a hint that I'll need really few bytes of data (perhaps, at some offset) | 70 // FIXME post 1.0 must supply a hint that I'll need really few bytes of data (perhaps, at some offset) |
| 71 // to avoid mmap files when only few bytes are to be read (i.e. #dataLength()) | 71 // to avoid mmap files when only few bytes are to be read (i.e. #dataLength()) |
| 72 return dataAccess.create(indexFile); | 72 return dataAccess.createReader(indexFile); |
| 73 } | 73 } |
| 74 | 74 |
| 75 /*package*/ DataAccess getDataStream() { | 75 /*package*/ DataAccess getDataStream() { |
| 76 return dataAccess.create(getDataFile()); | 76 return dataAccess.createReader(getDataFile()); |
| 77 } | |
| 78 | |
| 79 /*package*/ DataSerializer getIndexStreamWriter() { | |
| 80 return dataAccess.createWriter(indexFile, true); | |
| 81 } | |
| 82 | |
| 83 /*package*/ DataSerializer getDataStreamWriter() { | |
| 84 return dataAccess.createWriter(getDataFile(), true); | |
| 77 } | 85 } |
| 78 | 86 |
| 79 /** | 87 /** |
| 80 * Constructs file object that corresponds to .d revlog counterpart. | 88 * Constructs file object that corresponds to .d revlog counterpart. |
| 81 * Note, it's caller responsibility to ensure this file makes any sense (i.e. check {@link #inline} attribute) | 89 * Note, it's caller responsibility to ensure this file makes any sense (i.e. check {@link #inline} attribute) |
| 97 public HgInvalidControlFileException initWithDataFile(HgInvalidControlFileException ex) { | 105 public HgInvalidControlFileException initWithDataFile(HgInvalidControlFileException ex) { |
| 98 // exceptions are usually raised after read attepmt, hence inline shall be initialized | 106 // exceptions are usually raised after read attepmt, hence inline shall be initialized |
| 99 // although honest approach is to call #initOutline() first | 107 // although honest approach is to call #initOutline() first |
| 100 return ex.setFile(inline ? indexFile : getDataFile()); | 108 return ex.setFile(inline ? indexFile : getDataFile()); |
| 101 } | 109 } |
| 102 | 110 |
| 111 /*package-private*/String getDataFileName() { | |
| 112 // XXX a temporary solution to provide more info to fill in exceptions other than | |
| 113 // HgInvalidControlFileException (those benefit from initWith* methods above) | |
| 114 // | |
| 115 // Besides, since RevlogStream represents both revlogs with user data (those with WC representative and | |
| 116 // system data under store/data) and system-only revlogs (like changelog and manifest), there's no | |
| 117 // easy way to supply human-friendly name of the active file (independent from whether it's index of data) | |
| 118 return inline ? indexFile.getPath() : getDataFile().getPath(); | |
| 119 } | |
| 120 | |
| 121 public boolean isInlineData() { | |
| 122 initOutline(); | |
| 123 return inline; | |
| 124 } | |
| 103 | 125 |
| 104 public int revisionCount() { | 126 public int revisionCount() { |
| 105 initOutline(); | 127 initOutline(); |
| 106 return baseRevisions.length; | 128 return baseRevisions.length; |
| 107 } | 129 } |
