annotate src/org/tmatesoft/hg/internal/RevlogStream.java @ 295:981f9f50bb6c

Issue 11: Error log facility. SessionContext to share common facilities
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 16 Sep 2011 05:35:32 +0200
parents b11f6a08f748
children e7ca6f16d074
rev   line source
10
382cfe9463db Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 9
diff changeset
1 /*
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
2 * Copyright (c) 2010-2011 TMate Software Ltd
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
3 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
4 * This program is free software; you can redistribute it and/or modify
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
5 * it under the terms of the GNU General Public License as published by
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
6 * the Free Software Foundation; version 2 of the License.
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
7 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
8 * This program is distributed in the hope that it will be useful,
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
11 * GNU General Public License for more details.
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
12 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
13 * For information on how to redistribute this software under
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
14 * the terms of a license other than GNU General Public License
102
a3a2e5deb320 Updated contact address to support@hg4j.com
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 88
diff changeset
15 * contact TMate Software at support@hg4j.com
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
17 package org.tmatesoft.hg.internal;
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
19 import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
20 import static org.tmatesoft.hg.repo.HgRepository.TIP;
5
fc265ddeab26 File content and non-effective, although working, patch application
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
21
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
22 import java.io.File;
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
23 import java.io.IOException;
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
24 import java.util.ArrayList;
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
25 import java.util.List;
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
26 import java.util.zip.Inflater;
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27
158
b413b16d10a5 Integer offsets and file length explictly, rather than casts throughout code. Inflater may benefit from total length hint, but shall calculate it by its own if needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 157
diff changeset
28 import org.tmatesoft.hg.core.HgBadStateException;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
29 import org.tmatesoft.hg.core.Nodeid;
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
30 import org.tmatesoft.hg.repo.HgRepository;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
31
10
382cfe9463db Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 9
diff changeset
32
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
33 /**
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
34 * ? Single RevlogStream per file per repository with accessor to record access session (e.g. with back/forward operations),
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
35 * or numerous RevlogStream with separate representation of the underlying data (cached, lazy ChunkStream)?
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
36 *
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
37 * @see http://mercurial.selenic.com/wiki/Revlog
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
38 * @see http://mercurial.selenic.com/wiki/RevlogNG
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
39 *
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
40 * @author Artem Tikhomirov
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 52
diff changeset
41 * @author TMate Software Ltd.
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42 */
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
43 public class RevlogStream {
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
44
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
45 /*
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
46 * makes sense for index with inline data only - actual offset of the record in the .i file (record entry + revision * record size))
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
47 *
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
48 * long[] in fact (there are 8-bytes field in the revlog)
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
49 * However, (a) DataAccess currently doesn't operate with long seek/length
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
50 * and, of greater significance, (b) files with inlined data are designated for smaller files,
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
51 * guess, about 130 Kb, and offset there won't ever break int capacity
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
52 */
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
53 private int[] indexRecordOffset;
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
54 private int[] baseRevisions;
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
55 private boolean inline = false;
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
56 private final File indexFile;
10
382cfe9463db Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 9
diff changeset
57 private final DataAccessProvider dataAccess;
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
58
10
382cfe9463db Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 9
diff changeset
59 // if we need anything else from HgRepo, might replace DAP parameter with HgRepo and query it for DAP.
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
60 public RevlogStream(DataAccessProvider dap, File indexFile) {
10
382cfe9463db Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 9
diff changeset
61 this.dataAccess = dap;
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
62 this.indexFile = indexFile;
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
63 }
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
64
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
65 /*package*/ DataAccess getIndexStream() {
280
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 264
diff changeset
66 // XXX may supply a hint that I'll need really few bytes of data (perhaps, at some offset)
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 264
diff changeset
67 // to avoid mmap files when only few bytes are to be read (i.e. #dataLength())
10
382cfe9463db Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 9
diff changeset
68 return dataAccess.create(indexFile);
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
69 }
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
70
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
71 /*package*/ DataAccess getDataStream() {
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
72 final String indexName = indexFile.getName();
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
73 File dataFile = new File(indexFile.getParentFile(), indexName.substring(0, indexName.length() - 1) + "d");
10
382cfe9463db Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 9
diff changeset
74 return dataAccess.create(dataFile);
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
75 }
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
76
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
77 public int revisionCount() {
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
78 initOutline();
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
79 return baseRevisions.length;
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
80 }
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
81
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 288
diff changeset
82 /**
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 288
diff changeset
83 * @throws HgBadStateException if internal read operation failed
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 288
diff changeset
84 */
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
85 public int dataLength(int revision) {
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
86 // XXX in fact, use of iterate() instead of this implementation may be quite reasonable.
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
87 //
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
88 final int indexSize = revisionCount();
280
35125450c804 Erroneous and slow status for working copies based on non-tip revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 264
diff changeset
89 DataAccess daIndex = getIndexStream();
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
90 if (revision == TIP) {
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
91 revision = indexSize - 1;
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
92 }
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
93 try {
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
94 int recordOffset = getIndexOffsetInt(revision);
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
95 daIndex.seek(recordOffset + 12); // 6+2+4
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
96 int actualLen = daIndex.readInt();
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
97 return actualLen;
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
98 } catch (IOException ex) {
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
99 ex.printStackTrace(); // log error. FIXME better handling
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 288
diff changeset
100 throw new HgBadStateException(ex);
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
101 } finally {
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
102 daIndex.done();
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
103 }
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
104 }
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
105
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 288
diff changeset
106 /**
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 288
diff changeset
107 * @throws HgBadStateException if internal read operation failed
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 288
diff changeset
108 */
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
109 public byte[] nodeid(int revision) {
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
110 final int indexSize = revisionCount();
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
111 if (revision == TIP) {
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
112 revision = indexSize - 1;
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
113 }
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
114 if (revision < 0 || revision >= indexSize) {
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
115 throw new IllegalArgumentException(Integer.toString(revision));
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
116 }
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
117 DataAccess daIndex = getIndexStream();
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
118 try {
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
119 int recordOffset = getIndexOffsetInt(revision);
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
120 daIndex.seek(recordOffset + 32);
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
121 byte[] rv = new byte[20];
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
122 daIndex.readBytes(rv, 0, 20);
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
123 return rv;
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
124 } catch (IOException ex) {
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
125 ex.printStackTrace();
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 288
diff changeset
126 throw new HgBadStateException();
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
127 } finally {
88
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
128 daIndex.done();
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
129 }
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
130 }
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 288
diff changeset
131
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 288
diff changeset
132 /**
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 288
diff changeset
133 * Get link field from the index record.
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 288
diff changeset
134 * @throws HgBadStateException if internal read operation failed
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 288
diff changeset
135 */
88
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
136 public int linkRevision(int revision) {
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
137 final int last = revisionCount() - 1;
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
138 if (revision == TIP) {
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
139 revision = last;
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
140 }
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
141 if (revision < 0 || revision > last) {
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
142 throw new IllegalArgumentException(Integer.toString(revision));
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
143 }
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
144 DataAccess daIndex = getIndexStream();
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
145 try {
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
146 int recordOffset = getIndexOffsetInt(revision);
88
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
147 daIndex.seek(recordOffset + 20);
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
148 int linkRev = daIndex.readInt();
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
149 return linkRev;
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
150 } catch (IOException ex) {
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
151 ex.printStackTrace();
295
981f9f50bb6c Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 288
diff changeset
152 throw new HgBadStateException();
88
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
153 } finally {
61eedab3eb3e Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 80
diff changeset
154 daIndex.done();
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
155 }
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
156 }
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
157
49
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 44
diff changeset
158 // Perhaps, RevlogStream should be limited to use of plain int revisions for access,
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 44
diff changeset
159 // while Nodeids should be kept on the level up, in Revlog. Guess, Revlog better keep
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 44
diff changeset
160 // map of nodeids, and once this comes true, we may get rid of this method.
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
161 // Unlike its counterpart, {@link Revlog#getLocalRevisionNumber()}, doesn't fail with exception if node not found,
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
162 /**
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
163 * @return integer in [0..revisionCount()) or {@link HgRepository#BAD_REVISION} if not found
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
164 */
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
165 public int findLocalRevisionNumber(Nodeid nodeid) {
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
166 // XXX this one may be implemented with iterate() once there's mechanism to stop iterations
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
167 final int indexSize = revisionCount();
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
168 DataAccess daIndex = getIndexStream();
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
169 try {
24
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
170 byte[] nodeidBuf = new byte[20];
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
171 for (int i = 0; i < indexSize; i++) {
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
172 daIndex.skip(8);
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
173 int compressedLen = daIndex.readInt();
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
174 daIndex.skip(20);
24
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
175 daIndex.readBytes(nodeidBuf, 0, 20);
d4fdd1845b3f Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 22
diff changeset
176 if (nodeid.equalsTo(nodeidBuf)) {
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
177 return i;
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
178 }
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
179 daIndex.skip(inline ? 12 + compressedLen : 12);
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
180 }
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
181 } catch (IOException ex) {
243
0e01f9182e16 External cache Nodeid<->int added, Revlog.RevisionMap
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 242
diff changeset
182 ex.printStackTrace(); // log error. FIXME better handling. Perhaps, shall return BAD_REVISION here as well?
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
183 throw new IllegalStateException(ex);
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
184 } finally {
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
185 daIndex.done();
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
186 }
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
187 return BAD_REVISION;
22
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
188 }
603806cd2dc6 Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 10
diff changeset
189
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
190
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
191 private final int REVLOGV1_RECORD_SIZE = 64;
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
192
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
193 // should be possible to use TIP, ALL, or -1, -2, -n notation of Hg
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
194 // ? boolean needsNodeid
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
195 public void iterate(int start, int end, boolean needData, Inspector inspector) {
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
196 initOutline();
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
197 final int indexSize = revisionCount();
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
198 if (indexSize == 0) {
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
199 return;
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
200 }
5
fc265ddeab26 File content and non-effective, although working, patch application
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
201 if (end == TIP) {
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
202 end = indexSize - 1;
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
203 }
5
fc265ddeab26 File content and non-effective, although working, patch application
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
204 if (start == TIP) {
fc265ddeab26 File content and non-effective, although working, patch application
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
205 start = indexSize - 1;
fc265ddeab26 File content and non-effective, although working, patch application
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
206 }
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
207 if (start < 0 || start >= indexSize) {
157
d5268ca7715b Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 53 102
diff changeset
208 throw new IllegalArgumentException(String.format("Bad left range boundary %d in [0..%d]", start, indexSize-1));
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
209 }
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
210 if (end < start || end >= indexSize) {
157
d5268ca7715b Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 53 102
diff changeset
211 throw new IllegalArgumentException(String.format("Bad right range boundary %d in [0..%d]", end, indexSize-1));
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
212 }
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
213 // XXX may cache [start .. end] from index with a single read (pre-read)
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
214
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
215 ReaderN1 r = new ReaderN1(needData, inspector);
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
216 try {
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
217 r.start(end - start + 1);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
218 r.range(start, end);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
219 } catch (IOException ex) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
220 throw new HgBadStateException(ex); // FIXME need better handling
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
221 } finally {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
222 r.finish();
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
223 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
224 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
225
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
226 /**
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
227 * Effective alternative to {@link #iterate(int, int, boolean, Inspector) batch read}, when only few selected
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
228 * revisions are of interest.
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
229 * @param sortedRevisions revisions to walk, in ascending order.
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
230 * @param needData whether inspector needs access to header only
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
231 * @param inspector callback to process entries
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
232 */
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
233 public void iterate(int[] sortedRevisions, boolean needData, Inspector inspector) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
234 final int indexSize = revisionCount();
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
235 if (indexSize == 0 || sortedRevisions.length == 0) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
236 return;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
237 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
238 if (sortedRevisions[0] > indexSize || sortedRevisions[sortedRevisions.length - 1] > indexSize) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
239 throw new IllegalArgumentException(String.format("Can't iterate [%d, %d] in range [0..%d]", sortedRevisions[0], sortedRevisions[sortedRevisions.length - 1], indexSize));
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
240 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
241
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
242 ReaderN1 r = new ReaderN1(needData, inspector);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
243 try {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
244 r.start(sortedRevisions.length);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
245 for (int i = 0; i < sortedRevisions.length; ) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
246 int x = i;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
247 i++;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
248 while (i < sortedRevisions.length) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
249 if (sortedRevisions[i] == sortedRevisions[i-1] + 1) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
250 i++;
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
251 } else {
217
e39cf474ef94 Experimental support to mix-in start and end events for inspectors. Additionally, Lifecycle may serve as iteration control
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
252 break;
e39cf474ef94 Experimental support to mix-in start and end events for inspectors. Additionally, Lifecycle may serve as iteration control
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
253 }
e39cf474ef94 Experimental support to mix-in start and end events for inspectors. Additionally, Lifecycle may serve as iteration control
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
254 }
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
255 // commitRevisions[x..i-1] are sequential
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
256 if (!r.range(sortedRevisions[x], sortedRevisions[i-1])) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
257 return;
51
9429c7bd1920 Try DataAccess to reach revision data instead of plain byte arrays
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
258 }
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
259 }
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
260 } catch (IOException ex) {
158
b413b16d10a5 Integer offsets and file length explictly, rather than casts throughout code. Inflater may benefit from total length hint, but shall calculate it by its own if needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 157
diff changeset
261 throw new HgBadStateException(ex); // FIXME need better handling
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
262 } finally {
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
263 r.finish();
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
264 }
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
265 }
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
266
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
267 private int getBaseRevision(int revision) {
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
268 return baseRevisions[revision];
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
269 }
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
270
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
271 /**
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
272 * @return offset of the revision's record in the index (.i) stream
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
273 */
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
274 private int getIndexOffsetInt(int revision) {
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
275 return inline ? indexRecordOffset[revision] : revision * REVLOGV1_RECORD_SIZE;
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
276 }
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
277
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
278 private void initOutline() {
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
279 if (baseRevisions != null && baseRevisions.length > 0) {
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
280 return;
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
281 }
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
282 DataAccess da = getIndexStream();
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
283 try {
202
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 198
diff changeset
284 if (da.isEmpty()) {
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 198
diff changeset
285 // do not fail with exception if stream is empty, it's likely intentional
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 198
diff changeset
286 baseRevisions = new int[0];
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 198
diff changeset
287 return;
706bcc7cfee4 Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 198
diff changeset
288 }
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
289 int versionField = da.readInt();
170
71ddbf8603e8 Initial clone: populate given directory from a bundle. Everything but remote server access is there, albeit prototype code style
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 158
diff changeset
290 da.readInt(); // just to skip next 4 bytes of offset + flags
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
291 final int INLINEDATA = 1 << 16;
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
292 inline = (versionField & INLINEDATA) != 0;
288
b11f6a08f748 Avoid boxing int values and list resizes on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
293 IntVector resBases, resOffsets = null;
b11f6a08f748 Avoid boxing int values and list resizes on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
294 int entryCountGuess = da.length() / REVLOGV1_RECORD_SIZE;
b11f6a08f748 Avoid boxing int values and list resizes on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
295 if (inline) {
b11f6a08f748 Avoid boxing int values and list resizes on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
296 entryCountGuess >>>= 2; // pure guess, assume useful data takes 3/4 of total space
b11f6a08f748 Avoid boxing int values and list resizes on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
297 resOffsets = new IntVector(entryCountGuess, 5000);
b11f6a08f748 Avoid boxing int values and list resizes on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
298 }
b11f6a08f748 Avoid boxing int values and list resizes on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
299 resBases = new IntVector(entryCountGuess, 5000);
b11f6a08f748 Avoid boxing int values and list resizes on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
300
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
301 long offset = 0; // first offset is always 0, thus Hg uses it for other purposes
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
302 while(true) {
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
303 int compressedLen = da.readInt();
5
fc265ddeab26 File content and non-effective, although working, patch application
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
304 // 8+4 = 12 bytes total read here
49
26e3eeaa3962 branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 44
diff changeset
305 @SuppressWarnings("unused")
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
306 int actualLen = da.readInt();
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
307 int baseRevision = da.readInt();
5
fc265ddeab26 File content and non-effective, although working, patch application
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 4
diff changeset
308 // 12 + 8 = 20 bytes read here
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
309 // int linkRevision = di.readInt();
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
310 // int parent1Revision = di.readInt();
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
311 // int parent2Revision = di.readInt();
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
312 // byte[] nodeid = new byte[32];
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
313 resBases.add(baseRevision);
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
314 if (inline) {
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
315 int o = (int) offset;
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
316 if (o != offset) {
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
317 // just in case, can't happen, ever, unless HG (or some other bad tool) produces index file
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
318 // with inlined data of size greater than 2 Gb.
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
319 throw new HgBadStateException("Data too big, offset didn't fit to sizeof(int)");
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
320 }
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
321 resOffsets.add(o + REVLOGV1_RECORD_SIZE * resOffsets.size());
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
322 da.skip(3*4 + 32 + compressedLen); // Check: 44 (skip) + 20 (read) = 64 (total RevlogNG record size)
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
323 } else {
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
324 da.skip(3*4 + 32);
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
325 }
10
382cfe9463db Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 9
diff changeset
326 if (da.isEmpty()) {
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
327 // fine, done then
288
b11f6a08f748 Avoid boxing int values and list resizes on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
328 baseRevisions = resBases.toArray(true);
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
329 if (inline) {
288
b11f6a08f748 Avoid boxing int values and list resizes on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 280
diff changeset
330 indexRecordOffset = resOffsets.toArray(true);
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
331 }
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
332 break;
10
382cfe9463db Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 9
diff changeset
333 } else {
382cfe9463db Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 9
diff changeset
334 // start reading next record
382cfe9463db Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 9
diff changeset
335 long l = da.readLong();
382cfe9463db Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 9
diff changeset
336 offset = l >>> 16;
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
337 }
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
338 }
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
339 } catch (IOException ex) {
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
340 ex.printStackTrace(); // log error
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
341 // too bad, no outline then, but don't fail with NPE
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
342 baseRevisions = new int[0];
9
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
343 } finally {
d6d2a630f4a6 Access to underlaying file data wrapped into own Access object, implemented with FileChannel and ByteBuffer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 6
diff changeset
344 da.done();
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
345 }
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
346 }
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
347
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
348 /**
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
349 * operation with single file open/close and multiple diverse reads.
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
350 * XXX initOutline might need similar extraction to keen N1 format knowledge
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
351 */
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
352 class ReaderN1 {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
353 private final Inspector inspector;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
354 private final boolean needData;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
355 private DataAccess daIndex = null, daData = null;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
356 private Lifecycle.BasicCallback cb = null;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
357 private int lastRevisionRead = BAD_REVISION;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
358 private DataAccess lastUserData;
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
359 // next are to track two major bottlenecks - patch application and actual time spent in inspector
264
6bb5e7ed051a Optimize memory usage (reduce number of objects instantiated) when pooling file names and nodeids during manifest parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 263
diff changeset
360 // private long applyTime, inspectorTime; // TIMING
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
361
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
362
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
363 public ReaderN1(boolean needData, Inspector insp) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
364 assert insp != null;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
365 this.needData = needData;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
366 inspector = insp;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
367 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
368
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
369 public void start(int totalWork) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
370 daIndex = getIndexStream();
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
371 if (needData && !inline) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
372 daData = getDataStream();
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
373 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
374 if (inspector instanceof Lifecycle) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
375 cb = new Lifecycle.BasicCallback();
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
376 ((Lifecycle) inspector).start(totalWork, cb, cb);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
377 }
264
6bb5e7ed051a Optimize memory usage (reduce number of objects instantiated) when pooling file names and nodeids during manifest parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 263
diff changeset
378 // applyTime = inspectorTime = 0; // TIMING
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
379 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
380
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
381 public void finish() {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
382 if (lastUserData != null) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
383 lastUserData.done();
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
384 lastUserData = null;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
385 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
386 if (inspector instanceof Lifecycle) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
387 ((Lifecycle) inspector).finish(cb);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
388 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
389 daIndex.done();
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
390 if (daData != null) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
391 daData.done();
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
392 }
264
6bb5e7ed051a Optimize memory usage (reduce number of objects instantiated) when pooling file names and nodeids during manifest parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 263
diff changeset
393 // System.out.printf("applyTime:%d ms, inspectorTime: %d ms\n", applyTime, inspectorTime); // TIMING
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
394 }
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
395
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
396 public boolean range(int start, int end) throws IOException {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
397 byte[] nodeidBuf = new byte[20];
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
398 int i;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
399 boolean extraReadsToBaseRev = false; // to indicate we read revision prior to start. XXX not sure can't do without
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
400 // it (i.e. replace with i >= start)
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
401 if (needData && (i = getBaseRevision(start)) < start) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
402 // if lastRevisionRead in [baseRevision(start), start) can reuse lastUserData
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
403 // doesn't make sense to reuse if lastRevisionRead == start (too much to change in the cycle below).
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
404 if (lastRevisionRead != BAD_REVISION && i <= lastRevisionRead && lastRevisionRead < start) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
405 i = lastRevisionRead + 1; // start with first not-yet-read revision
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
406 extraReadsToBaseRev = i < start;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
407 } else {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
408 if (lastUserData != null) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
409 lastUserData.done();
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
410 lastUserData = null;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
411 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
412 extraReadsToBaseRev = true;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
413 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
414 } else {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
415 // don't need to clean lastUserData as it's always null when !needData
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
416 i = start;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
417 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
418
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
419 daIndex.seek(getIndexOffsetInt(i));
258
e5776067b3b8 Reduce number of objects instantiated on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 243
diff changeset
420 //
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
421 // reuse some instances
258
e5776067b3b8 Reduce number of objects instantiated on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 243
diff changeset
422 final ArrayList<PatchRecord> patches = new ArrayList<PatchRecord>();
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
423 final Inflater inflater = new Inflater();
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
424 // can share buffer between instances of InflaterDataAccess as I never read any two of them in parallel
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
425 final byte[] inflaterBuffer = new byte[1024];
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
426 //
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
427
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
428 for (; i <= end; i++ ) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
429 if (inline && needData) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
430 // inspector reading data (though FilterDataAccess) may have affected index position
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
431 daIndex.seek(getIndexOffsetInt(i));
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
432 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
433 long l = daIndex.readLong(); // 0
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
434 long offset = i == 0 ? 0 : (l >>> 16);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
435 @SuppressWarnings("unused")
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
436 int flags = (int) (l & 0X0FFFF);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
437 int compressedLen = daIndex.readInt(); // +8
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
438 int actualLen = daIndex.readInt(); // +12
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
439 int baseRevision = daIndex.readInt(); // +16
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
440 int linkRevision = daIndex.readInt(); // +20
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
441 int parent1Revision = daIndex.readInt();
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
442 int parent2Revision = daIndex.readInt();
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
443 // Hg has 32 bytes here, uses 20 for nodeid, and keeps 12 last bytes empty
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
444 daIndex.readBytes(nodeidBuf, 0, 20); // +32
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
445 daIndex.skip(12);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
446 DataAccess userDataAccess = null;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
447 if (needData) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
448 int streamOffset;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
449 DataAccess streamDataAccess;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
450 if (inline) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
451 streamDataAccess = daIndex;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
452 streamOffset = getIndexOffsetInt(i) + REVLOGV1_RECORD_SIZE; // don't need to do seek as it's actual position in the index stream
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
453 } else {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
454 streamOffset = (int) offset;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
455 streamDataAccess = daData;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
456 daData.seek(streamOffset);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
457 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
458 final boolean patchToPrevious = baseRevision != i; // the only way I found to tell if it's a patch
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
459 if (streamDataAccess.isEmpty()) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
460 userDataAccess = new DataAccess(); // empty
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
461 } else {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
462 final byte firstByte = streamDataAccess.readByte();
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
463 if (firstByte == 0x78 /* 'x' */) {
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
464 inflater.reset();
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
465 userDataAccess = new InflaterDataAccess(streamDataAccess, streamOffset, compressedLen, patchToPrevious ? -1 : actualLen, inflater, inflaterBuffer);
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
466 } else if (firstByte == 0x75 /* 'u' */) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
467 userDataAccess = new FilterDataAccess(streamDataAccess, streamOffset+1, compressedLen-1);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
468 } else {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
469 // XXX Python impl in fact throws exception when there's not 'x', 'u' or '0'
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
470 // but I don't see reason not to return data as is
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
471 userDataAccess = new FilterDataAccess(streamDataAccess, streamOffset, compressedLen);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
472 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
473 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
474 // XXX
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
475 if (patchToPrevious) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
476 // this is a patch
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
477 patches.clear(); // won't hurt to ensure there are no leftovers, even if we already cleaned
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
478 while (!userDataAccess.isEmpty()) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
479 PatchRecord pr = PatchRecord.read(userDataAccess);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
480 // System.out.printf("PatchRecord:%d %d %d\n", pr.start, pr.end, pr.len);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
481 patches.add(pr);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
482 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
483 userDataAccess.done();
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
484 //
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
485 // it shall be reset at the end of prev iteration, when it got assigned from userDataAccess
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
486 // however, actual userDataAccess and lastUserData may share Inflater object, which needs to be reset
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
487 // Alternatively, userDataAccess.done() above may be responsible to reset Inflater (if it's InflaterDataAccess)
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
488 lastUserData.reset();
264
6bb5e7ed051a Optimize memory usage (reduce number of objects instantiated) when pooling file names and nodeids during manifest parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 263
diff changeset
489 // final long startMeasuring = System.currentTimeMillis(); // TIMING
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
490 byte[] userData = apply(lastUserData, actualLen, patches);
264
6bb5e7ed051a Optimize memory usage (reduce number of objects instantiated) when pooling file names and nodeids during manifest parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 263
diff changeset
491 // applyTime += (System.currentTimeMillis() - startMeasuring); // TIMING
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
492 patches.clear(); // do not keep any reference, allow PatchRecord to be gc'd
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
493 userDataAccess = new ByteArrayDataAccess(userData);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
494 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
495 } else {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
496 if (inline) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
497 daIndex.skip(compressedLen);
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
498 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
499 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
500 if (!extraReadsToBaseRev || i >= start) {
264
6bb5e7ed051a Optimize memory usage (reduce number of objects instantiated) when pooling file names and nodeids during manifest parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 263
diff changeset
501 // final long startMeasuring = System.currentTimeMillis(); // TIMING
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
502 inspector.next(i, actualLen, baseRevision, linkRevision, parent1Revision, parent2Revision, nodeidBuf, userDataAccess);
264
6bb5e7ed051a Optimize memory usage (reduce number of objects instantiated) when pooling file names and nodeids during manifest parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 263
diff changeset
503 // inspectorTime += (System.currentTimeMillis() - startMeasuring); // TIMING
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
504 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
505 if (cb != null) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
506 if (cb.isStopped()) {
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
507 return false;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
508 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
509 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
510 if (userDataAccess != null) {
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
511 userDataAccess.reset(); // not sure this is necessary here, as lastUserData would get reset anyway before next use.
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
512 }
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
513 if (lastUserData != null) {
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
514 lastUserData.done();
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
515 }
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
516 lastUserData = userDataAccess;
242
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
517 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
518 lastRevisionRead = end;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
519 return true;
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
520 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
521 }
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
522
ad6a046943be Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 223
diff changeset
523
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
524 private static int[] toArray(List<Integer> l) {
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
525 int[] rv = new int[l.size()];
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
526 for (int i = 0; i < rv.length; i++) {
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
527 rv[i] = l.get(i);
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
528 }
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
529 return rv;
2
08db726a0fb7 Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 0
diff changeset
530 }
198
33a7d76f067b Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 170
diff changeset
531
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
532
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
533 // mpatch.c : apply()
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
534 // FIXME need to implement patch merge (fold, combine, gather and discard from aforementioned mpatch.[c|py]), also see Revlog and Mercurial PDF
157
d5268ca7715b Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 53 102
diff changeset
535 public/*for HgBundle; until moved to better place*/static byte[] apply(DataAccess baseRevisionContent, int outcomeLen, List<PatchRecord> patch) throws IOException {
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
536 int last = 0, destIndex = 0;
43
1b26247d7367 Calculate result length of the patch operarion, when unknown
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
537 if (outcomeLen == -1) {
158
b413b16d10a5 Integer offsets and file length explictly, rather than casts throughout code. Inflater may benefit from total length hint, but shall calculate it by its own if needed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 157
diff changeset
538 outcomeLen = baseRevisionContent.length();
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
539 for (int i = 0, x = patch.size(); i < x; i++) {
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
540 PatchRecord pr = patch.get(i);
43
1b26247d7367 Calculate result length of the patch operarion, when unknown
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
541 outcomeLen += pr.start - last + pr.len;
1b26247d7367 Calculate result length of the patch operarion, when unknown
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
542 last = pr.end;
1b26247d7367 Calculate result length of the patch operarion, when unknown
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
543 }
1b26247d7367 Calculate result length of the patch operarion, when unknown
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
544 outcomeLen -= last;
1b26247d7367 Calculate result length of the patch operarion, when unknown
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
545 last = 0;
1b26247d7367 Calculate result length of the patch operarion, when unknown
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
546 }
1b26247d7367 Calculate result length of the patch operarion, when unknown
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
547 byte[] rv = new byte[outcomeLen];
263
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
548 for (int i = 0, x = patch.size(); i < x; i++) {
31f67be94e71 RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 258
diff changeset
549 PatchRecord pr = patch.get(i);
51
9429c7bd1920 Try DataAccess to reach revision data instead of plain byte arrays
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
550 baseRevisionContent.seek(last);
9429c7bd1920 Try DataAccess to reach revision data instead of plain byte arrays
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
551 baseRevisionContent.readBytes(rv, destIndex, pr.start-last);
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
552 destIndex += pr.start - last;
43
1b26247d7367 Calculate result length of the patch operarion, when unknown
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 37
diff changeset
553 System.arraycopy(pr.data, 0, rv, destIndex, pr.data.length);
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
554 destIndex += pr.data.length;
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
555 last = pr.end;
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
556 }
51
9429c7bd1920 Try DataAccess to reach revision data instead of plain byte arrays
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
557 baseRevisionContent.seek(last);
9429c7bd1920 Try DataAccess to reach revision data instead of plain byte arrays
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
558 baseRevisionContent.readBytes(rv, destIndex, (int) (baseRevisionContent.length() - last));
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
559 return rv;
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
560 }
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
561
35
6061aa826a9e Complete parsing of the bundle format
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 33
diff changeset
562 // @see http://mercurial.selenic.com/wiki/BundleFormat, in Changelog group description
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
563 public static class PatchRecord {
52
30bd38978846 brief explanation of patch record
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
564 /*
30bd38978846 brief explanation of patch record
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
565 Given there are pr1 and pr2:
30bd38978846 brief explanation of patch record
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
566 pr1.start to pr1.end will be replaced with pr's data (of pr1.len)
30bd38978846 brief explanation of patch record
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
567 pr1.end to pr2.start gets copied from base
30bd38978846 brief explanation of patch record
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 49
diff changeset
568 */
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
569 public int start, end, len;
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
570 public byte[] data;
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
571
36
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
572 // TODO consider PatchRecord that only records data position (absolute in data source), and acquires data as needed
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
573 private PatchRecord(int p1, int p2, int length, byte[] src) {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
574 start = p1;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
575 end = p2;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
576 len = length;
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
577 data = src;
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
578 }
36
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
579
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
580 /*package-local*/ static PatchRecord read(byte[] data, int offset) {
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
581 final int x = offset; // shorthand
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
582 int p1 = ((data[x] & 0xFF)<< 24) | ((data[x+1] & 0xFF) << 16) | ((data[x+2] & 0xFF) << 8) | (data[x+3] & 0xFF);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
583 int p2 = ((data[x+4] & 0xFF) << 24) | ((data[x+5] & 0xFF) << 16) | ((data[x+6] & 0xFF) << 8) | (data[x+7] & 0xFF);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
584 int len = ((data[x+8] & 0xFF) << 24) | ((data[x+9] & 0xFF) << 16) | ((data[x+10] & 0xFF) << 8) | (data[x+11] & 0xFF);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
585 byte[] dataCopy = new byte[len];
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
586 System.arraycopy(data, x+12, dataCopy, 0, len);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
587 return new PatchRecord(p1, p2, len, dataCopy);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
588 }
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
589
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
590 public /*for HgBundle*/ static PatchRecord read(DataAccess da) throws IOException {
36
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
591 int p1 = da.readInt();
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
592 int p2 = da.readInt();
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
593 int len = da.readInt();
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
594 byte[] src = new byte[len];
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
595 da.readBytes(src, 0, len);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
596 return new PatchRecord(p1, p2, len, src);
205f9b59b400 Strip parsing logic out from console frontend
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 35
diff changeset
597 }
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
598 }
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
599
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
600 // FIXME byte[] data might be too expensive, for few usecases it may be better to have intermediate Access object (when we don't need full data
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
601 // instantly - e.g. calculate hash, or comparing two revisions
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
602 public interface Inspector {
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
603 // XXX boolean retVal to indicate whether to continue?
157
d5268ca7715b Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 53 102
diff changeset
604 // TODO specify nodeid and data length, and reuse policy (i.e. if revlog stream doesn't reuse nodeid[] for each call)
d5268ca7715b Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 53 102
diff changeset
605 // implementers shall not invoke DataAccess.done(), it's accomplished by #iterate at appropraite moment
d5268ca7715b Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 53 102
diff changeset
606 void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[/*20*/] nodeid, DataAccess data);
3
24bb4f365164 Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 2
diff changeset
607 }
0
dbd663faec1f Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
608 }