Mercurial > jhg
annotate src/org/tmatesoft/hg/internal/RevlogStream.java @ 630:72c979555cb8
HgDiffCommand. Do not use deprecated code. Javadoc
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 23 May 2013 19:44:28 +0200 |
parents | 6526d8adbc0f |
children | 1deea2f33218 |
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 /* |
530
0f6fa88e2162
Towards commit command: refactor clone, extract pieces to reuse. Describe a defect discovered when bundle has few patches with 0,0 parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
2 * Copyright (c) 2010-2013 TMate Software Ltd |
74
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; |
530
0f6fa88e2162
Towards commit command: refactor clone, extract pieces to reuse. Describe a defect discovered when bundle has few patches with 0,0 parents
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
21 import static org.tmatesoft.hg.internal.Internals.REVLOGV1_RECORD_SIZE; |
5
fc265ddeab26
File content and non-effective, although working, patch application
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
4
diff
changeset
|
22 |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
23 import java.io.File; |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
24 import java.io.IOException; |
593
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
25 import java.lang.ref.Reference; |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
26 import java.lang.ref.ReferenceQueue; |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
27 import java.lang.ref.SoftReference; |
607
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
28 import java.util.ArrayList; |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
29 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
|
30 import java.util.zip.Inflater; |
0
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 |
617
65c01508f002
Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
608
diff
changeset
|
32 import org.tmatesoft.hg.core.HgIOException; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
52
diff
changeset
|
33 import org.tmatesoft.hg.core.Nodeid; |
300
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
297
diff
changeset
|
34 import org.tmatesoft.hg.repo.HgInternals; |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
420
diff
changeset
|
35 import org.tmatesoft.hg.repo.HgInvalidControlFileException; |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
420
diff
changeset
|
36 import org.tmatesoft.hg.repo.HgInvalidRevisionException; |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
420
diff
changeset
|
37 import org.tmatesoft.hg.repo.HgInvalidStateException; |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
38 import org.tmatesoft.hg.repo.HgRepository; |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
39 import org.tmatesoft.hg.repo.HgRuntimeException; |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
440
diff
changeset
|
40 import org.tmatesoft.hg.util.Adaptable; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
52
diff
changeset
|
41 |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
42 |
0
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 /** |
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
44 * ? 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
|
45 * 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
|
46 * |
0
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 * @see http://mercurial.selenic.com/wiki/Revlog |
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
48 * @see http://mercurial.selenic.com/wiki/RevlogNG |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
52
diff
changeset
|
49 * |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
52
diff
changeset
|
50 * @author Artem Tikhomirov |
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
52
diff
changeset
|
51 * @author TMate Software Ltd. |
0
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 */ |
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 public class RevlogStream { |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
54 |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
55 static final int INLINEDATA = 1 << 16; |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
56 |
198
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
57 /* |
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
58 * 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
|
59 * |
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
60 * 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
|
61 * 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
|
62 * 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
|
63 * 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
|
64 */ |
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
65 private int[] indexRecordOffset; |
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
66 private int[] baseRevisions; |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
67 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
|
68 private final File indexFile; |
396
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
69 private File dataFile; |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
70 private final Internals repo; |
593
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
71 // keeps last complete revision we've read. Note, this cached revision doesn't help |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
72 // for subsequent #iterate() calls with the same revision (Inspector needs more data than |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
73 // we currently cache here, perhaps, we shall cache everything it wants to cover same |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
74 // revision case as well). Now this helps when second #iterate() call is for a revision greater |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
75 // than one from the first call, and both revisions got same base rev. It's often the case when |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
76 // parents/children are analyzed. |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
77 private SoftReference<CachedRevision> lastRevisionRead; |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
78 private final ReferenceQueue<CachedRevision> lastRevisionQueue = new ReferenceQueue<CachedRevision>(); |
607
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
79 // |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
80 private final RevlogChangeMonitor changeTracker; |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
81 private List<Observer> observers; |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
82 private boolean shallDropDerivedCaches = false; |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
83 |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
84 public RevlogStream(Internals hgRepo, File indexFile) { |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
85 repo = hgRepo; |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
86 this.indexFile = indexFile; |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
87 changeTracker = repo.getRevlogTracker(indexFile); |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
88 } |
621
99ad1e3a4e4d
RevlogStream: be aware of existence (not HgDataFile), facilitate use of an added HgDataFile over a commit; Rollback: be more sensitive about file changes (file size is not enough: write/rollback leaves it intact); tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
617
diff
changeset
|
89 |
99ad1e3a4e4d
RevlogStream: be aware of existence (not HgDataFile), facilitate use of an added HgDataFile over a commit; Rollback: be more sensitive about file changes (file size is not enough: write/rollback leaves it intact); tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
617
diff
changeset
|
90 public boolean exists() { |
99ad1e3a4e4d
RevlogStream: be aware of existence (not HgDataFile), facilitate use of an added HgDataFile over a commit; Rollback: be more sensitive about file changes (file size is not enough: write/rollback leaves it intact); tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
617
diff
changeset
|
91 return indexFile.exists(); |
99ad1e3a4e4d
RevlogStream: be aware of existence (not HgDataFile), facilitate use of an added HgDataFile over a commit; Rollback: be more sensitive about file changes (file size is not enough: write/rollback leaves it intact); tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
617
diff
changeset
|
92 } |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
93 |
606
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
94 /** |
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
95 * @param shortRead pass <code>true</code> to indicate intention to read few revisions only (as opposed to reading most of/complete revlog) |
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
96 * @return never <code>null</code>, empty {@link DataAccess} if no stream is available |
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
97 */ |
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
98 /*package*/ DataAccess getIndexStream(boolean shortRead) { |
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
99 // shortRead hint helps to avoid mmap files when only |
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
100 // few bytes are to be read (i.e. #dataLength()) |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
101 DataAccessProvider dataAccess = repo.getDataAccess(); |
606
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
102 return dataAccess.createReader(indexFile, shortRead); |
0
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
103 } |
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
104 |
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
|
105 /*package*/ DataAccess getDataStream() { |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
106 DataAccessProvider dataAccess = repo.getDataAccess(); |
606
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
107 return dataAccess.createReader(getDataFile(), false); |
534
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
108 } |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
109 |
617
65c01508f002
Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
608
diff
changeset
|
110 /*package*/ DataSerializer getIndexStreamWriter(Transaction tr) throws HgIOException { |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
111 DataAccessProvider dataAccess = repo.getDataAccess(); |
617
65c01508f002
Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
608
diff
changeset
|
112 return dataAccess.createWriter(tr, indexFile, true); |
534
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
113 } |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
114 |
617
65c01508f002
Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
608
diff
changeset
|
115 /*package*/ DataSerializer getDataStreamWriter(Transaction tr) throws HgIOException { |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
116 DataAccessProvider dataAccess = repo.getDataAccess(); |
617
65c01508f002
Rollback support for commands that modify repository. Strategy to keep complete copy of a file being changed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
608
diff
changeset
|
117 return dataAccess.createWriter(tr, getDataFile(), true); |
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
|
118 } |
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
|
119 |
396
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
120 /** |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
121 * Constructs file object that corresponds to .d revlog counterpart. |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
122 * Note, it's caller responsibility to ensure this file makes any sense (i.e. check {@link #inline} attribute) |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
123 */ |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
124 private File getDataFile() { |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
125 if (dataFile == null) { |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
126 final String indexName = indexFile.getName(); |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
127 dataFile = new File(indexFile.getParentFile(), indexName.substring(0, indexName.length() - 1) + "d"); |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
128 } |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
129 return dataFile; |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
130 } |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
131 |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
132 // initialize exception with the file where revlog structure information comes from |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
133 public HgInvalidControlFileException initWithIndexFile(HgInvalidControlFileException ex) { |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
134 return ex.setFile(indexFile); |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
135 } |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
136 |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
137 // initialize exception with the file where revlog data comes from |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
138 public HgInvalidControlFileException initWithDataFile(HgInvalidControlFileException ex) { |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
139 // exceptions are usually raised after read attepmt, hence inline shall be initialized |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
140 // although honest approach is to call #initOutline() first |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
141 return ex.setFile(inline ? indexFile : getDataFile()); |
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
142 } |
534
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
143 |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
144 /*package-private*/String getDataFileName() { |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
145 // XXX a temporary solution to provide more info to fill in exceptions other than |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
146 // HgInvalidControlFileException (those benefit from initWith* methods above) |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
147 // |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
148 // Besides, since RevlogStream represents both revlogs with user data (those with WC representative and |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
149 // system data under store/data) and system-only revlogs (like changelog and manifest), there's no |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
150 // easy way to supply human-friendly name of the active file (independent from whether it's index of data) |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
151 return inline ? indexFile.getPath() : getDataFile().getPath(); |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
152 } |
396
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
153 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
154 public boolean isInlineData() throws HgInvalidControlFileException { |
534
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
155 initOutline(); |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
156 return inline; |
243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
530
diff
changeset
|
157 } |
396
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
158 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
159 public int revisionCount() throws HgInvalidControlFileException { |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
160 initOutline(); |
198
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
161 return baseRevisions.length; |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
162 } |
22
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
163 |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
288
diff
changeset
|
164 /** |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
165 * @throws HgInvalidControlFileException if attempt to read index file failed |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
166 * @throws HgInvalidRevisionException if revisionIndex argument doesn't represent a valid record in the revlog |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
288
diff
changeset
|
167 */ |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
168 public int dataLength(int revisionIndex) throws HgInvalidControlFileException, HgInvalidRevisionException { |
22
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
169 // 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
|
170 // |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
171 revisionIndex = checkRevisionIndex(revisionIndex); |
606
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
172 DataAccess daIndex = getIndexStream(true); |
22
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
173 try { |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
174 int recordOffset = getIndexOffsetInt(revisionIndex); |
22
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
175 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
|
176 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
|
177 return actualLen; |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
178 } catch (IOException ex) { |
440
299870249a28
Issue 30: bogus IOException for mmap file on linux
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
179 throw new HgInvalidControlFileException(null, ex, indexFile).setRevisionIndex(revisionIndex); |
22
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
180 } finally { |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
181 daIndex.done(); |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
182 } |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
183 } |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
184 |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
288
diff
changeset
|
185 /** |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
186 * Read nodeid at given index |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
187 * |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
188 * @throws HgInvalidControlFileException if attempt to read index file failed |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
189 * @throws HgInvalidRevisionException if revisionIndex argument doesn't represent a valid record in the revlog |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
288
diff
changeset
|
190 */ |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
191 public byte[] nodeid(int revisionIndex) throws HgInvalidControlFileException, HgInvalidRevisionException { |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
192 revisionIndex = checkRevisionIndex(revisionIndex); |
606
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
193 DataAccess daIndex = getIndexStream(true); |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
194 try { |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
195 int recordOffset = getIndexOffsetInt(revisionIndex); |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
196 daIndex.seek(recordOffset + 32); |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
197 byte[] rv = new byte[20]; |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
198 daIndex.readBytes(rv, 0, 20); |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
199 return rv; |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
200 } catch (IOException ex) { |
440
299870249a28
Issue 30: bogus IOException for mmap file on linux
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
201 throw new HgInvalidControlFileException("Revision lookup failed", ex, indexFile).setRevisionIndex(revisionIndex); |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
202 } finally { |
88
61eedab3eb3e
Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
80
diff
changeset
|
203 daIndex.done(); |
61eedab3eb3e
Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
80
diff
changeset
|
204 } |
61eedab3eb3e
Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
80
diff
changeset
|
205 } |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
288
diff
changeset
|
206 |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
288
diff
changeset
|
207 /** |
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
288
diff
changeset
|
208 * Get link field from the index record. |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
209 * |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
210 * @throws HgInvalidControlFileException if attempt to read index file failed |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
211 * @throws HgInvalidRevisionException if revisionIndex argument doesn't represent a valid record in the revlog |
295
981f9f50bb6c
Issue 11: Error log facility. SessionContext to share common facilities
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
288
diff
changeset
|
212 */ |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
213 public int linkRevision(int revisionIndex) throws HgInvalidControlFileException, HgInvalidRevisionException { |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
214 revisionIndex = checkRevisionIndex(revisionIndex); |
606
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
215 DataAccess daIndex = getIndexStream(true); |
88
61eedab3eb3e
Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
80
diff
changeset
|
216 try { |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
217 int recordOffset = getIndexOffsetInt(revisionIndex); |
88
61eedab3eb3e
Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
80
diff
changeset
|
218 daIndex.seek(recordOffset + 20); |
61eedab3eb3e
Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
80
diff
changeset
|
219 int linkRev = daIndex.readInt(); |
61eedab3eb3e
Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
80
diff
changeset
|
220 return linkRev; |
61eedab3eb3e
Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
80
diff
changeset
|
221 } catch (IOException ex) { |
440
299870249a28
Issue 30: bogus IOException for mmap file on linux
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
222 throw new HgInvalidControlFileException("Linked revision lookup failed", ex, indexFile).setRevisionIndex(revisionIndex); |
88
61eedab3eb3e
Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
80
diff
changeset
|
223 } finally { |
61eedab3eb3e
Status between two revisions to recognize copy/rename
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
80
diff
changeset
|
224 daIndex.done(); |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
225 } |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
226 } |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
227 |
585
b47ef0d2777b
Access to base revision filed comes handy for debug sometimes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
228 /** |
b47ef0d2777b
Access to base revision filed comes handy for debug sometimes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
229 * Extract base revision field from the revlog |
b47ef0d2777b
Access to base revision filed comes handy for debug sometimes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
230 * |
b47ef0d2777b
Access to base revision filed comes handy for debug sometimes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
231 * @throws HgInvalidControlFileException if attempt to read index file failed |
b47ef0d2777b
Access to base revision filed comes handy for debug sometimes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
232 * @throws HgInvalidRevisionException if revisionIndex argument doesn't represent a valid record in the revlog |
b47ef0d2777b
Access to base revision filed comes handy for debug sometimes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
233 */ |
b47ef0d2777b
Access to base revision filed comes handy for debug sometimes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
234 public int baseRevision(int revisionIndex) throws HgInvalidControlFileException, HgInvalidRevisionException { |
b47ef0d2777b
Access to base revision filed comes handy for debug sometimes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
235 revisionIndex = checkRevisionIndex(revisionIndex); |
b47ef0d2777b
Access to base revision filed comes handy for debug sometimes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
236 return getBaseRevision(revisionIndex); |
b47ef0d2777b
Access to base revision filed comes handy for debug sometimes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
237 } |
b47ef0d2777b
Access to base revision filed comes handy for debug sometimes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
584
diff
changeset
|
238 |
49
26e3eeaa3962
branch and user filtering for log operation
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
44
diff
changeset
|
239 // 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
|
240 // 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
|
241 // 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
|
242 // 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
|
243 /** |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
244 * @return integer in [0..revisionCount()) or {@link HgRepository#BAD_REVISION} if not found |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
245 * @throws HgInvalidControlFileException if attempt to read index file failed |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
246 */ |
367
2fadf8695f8a
Use 'revision index' instead of the vague 'local revision number' concept in the API
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
366
diff
changeset
|
247 public int findRevisionIndex(Nodeid nodeid) throws HgInvalidControlFileException { |
22
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
248 // 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
|
249 final int indexSize = revisionCount(); |
606
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
250 DataAccess daIndex = getIndexStream(false); |
22
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
251 try { |
24
d4fdd1845b3f
Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
252 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
|
253 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
|
254 daIndex.skip(8); |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
255 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
|
256 daIndex.skip(20); |
24
d4fdd1845b3f
Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
257 daIndex.readBytes(nodeidBuf, 0, 20); |
d4fdd1845b3f
Nodeid with array of exactly 20 bytes
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
22
diff
changeset
|
258 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
|
259 return i; |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
260 } |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
261 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
|
262 } |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
263 } catch (IOException ex) { |
440
299870249a28
Issue 30: bogus IOException for mmap file on linux
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
425
diff
changeset
|
264 throw new HgInvalidControlFileException("Revision lookup failed", ex, indexFile).setRevision(nodeid); |
22
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
265 } finally { |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
266 daIndex.done(); |
603806cd2dc6
Status of local working dir against non-tip base revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
10
diff
changeset
|
267 } |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
268 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
|
269 } |
538
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
270 |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
271 /** |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
272 * @return value suitable for the corresponding field in the new revision's header, not physical offset in the file |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
273 * (which is different in case of inline revlogs) |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
274 */ |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
275 public long newEntryOffset() throws HgInvalidControlFileException { |
538
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
276 if (revisionCount() == 0) { |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
277 return 0; |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
278 } |
606
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
279 DataAccess daIndex = getIndexStream(true); |
538
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
280 int lastRev = revisionCount() - 1; |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
281 try { |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
282 int recordOffset = getIndexOffsetInt(lastRev); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
283 daIndex.seek(recordOffset); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
284 long value = daIndex.readLong(); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
285 value = value >>> 16; |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
286 int compressedLen = daIndex.readInt(); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
287 return lastRev == 0 ? compressedLen : value + compressedLen; |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
288 } catch (IOException ex) { |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
289 throw new HgInvalidControlFileException("Linked revision lookup failed", ex, indexFile).setRevisionIndex(lastRev); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
290 } finally { |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
291 daIndex.done(); |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
292 } |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
293 } |
dd4f6311af52
Commit: first working version
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
534
diff
changeset
|
294 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
295 /** |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
296 * should be possible to use TIP, ALL, or -1, -2, -n notation of Hg |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
297 * ? boolean needsNodeid |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
298 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
299 */ |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
300 public void iterate(int start, int end, boolean needData, Inspector inspector) throws HgRuntimeException { |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
301 initOutline(); |
198
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
302 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
|
303 if (indexSize == 0) { |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
304 return; |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
305 } |
5
fc265ddeab26
File content and non-effective, although working, patch application
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
4
diff
changeset
|
306 if (end == TIP) { |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
307 end = indexSize - 1; |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
308 } |
5
fc265ddeab26
File content and non-effective, although working, patch application
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
4
diff
changeset
|
309 if (start == TIP) { |
fc265ddeab26
File content and non-effective, although working, patch application
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
4
diff
changeset
|
310 start = indexSize - 1; |
fc265ddeab26
File content and non-effective, although working, patch application
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
4
diff
changeset
|
311 } |
300
650b45d290b1
Share range check code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
297
diff
changeset
|
312 HgInternals.checkRevlogRange(start, end, indexSize-1); |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
313 // 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
|
314 |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
315 ReaderN1 r = new ReaderN1(needData, inspector, repo.shallMergePatches()); |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
316 try { |
593
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
317 r.start(end - start + 1, getLastRevisionRead()); |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
318 r.range(start, end); |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
319 } catch (IOException ex) { |
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
320 throw new HgInvalidControlFileException(String.format("Failed reading [%d..%d]", start, end), ex, indexFile); |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
321 } finally { |
593
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
322 CachedRevision cr = r.finish(); |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
323 setLastRevisionRead(cr); |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
324 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
325 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
326 |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
327 /** |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
328 * 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
|
329 * revisions are of interest. |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
330 * @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
|
331 * @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
|
332 * @param inspector callback to process entries |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
333 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
334 */ |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
335 public void iterate(int[] sortedRevisions, boolean needData, Inspector inspector) throws HgRuntimeException { |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
336 final int indexSize = revisionCount(); |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
337 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
|
338 return; |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
339 } |
347
8da7ade36c57
Add specific IAE subclass to handle wrong (e.g. outdated after rollback) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
340 if (sortedRevisions[0] > indexSize) { |
8da7ade36c57
Add specific IAE subclass to handle wrong (e.g. outdated after rollback) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
341 throw new HgInvalidRevisionException(String.format("Can't iterate [%d, %d] in range [0..%d]", sortedRevisions[0], sortedRevisions[sortedRevisions.length - 1], indexSize), null, sortedRevisions[0]); |
8da7ade36c57
Add specific IAE subclass to handle wrong (e.g. outdated after rollback) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
342 } |
8da7ade36c57
Add specific IAE subclass to handle wrong (e.g. outdated after rollback) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
343 if (sortedRevisions[sortedRevisions.length - 1] > indexSize) { |
8da7ade36c57
Add specific IAE subclass to handle wrong (e.g. outdated after rollback) revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
344 throw new HgInvalidRevisionException(String.format("Can't iterate [%d, %d] in range [0..%d]", sortedRevisions[0], sortedRevisions[sortedRevisions.length - 1], indexSize), null, sortedRevisions[sortedRevisions.length - 1]); |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
345 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
346 |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
347 ReaderN1 r = new ReaderN1(needData, inspector, repo.shallMergePatches()); |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
348 try { |
594
cc7b0c4dc993
Cache only in-memory revision representations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
593
diff
changeset
|
349 r.start(sortedRevisions.length, getLastRevisionRead()); |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
350 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
|
351 int x = i; |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
352 i++; |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
353 while (i < sortedRevisions.length) { |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
354 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
|
355 i++; |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
356 } 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
|
357 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
|
358 } |
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
|
359 } |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
360 // 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
|
361 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
|
362 return; |
51
9429c7bd1920
Try DataAccess to reach revision data instead of plain byte arrays
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
49
diff
changeset
|
363 } |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
364 } |
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
365 } catch (IOException ex) { |
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
366 final int c = sortedRevisions.length; |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
367 throw new HgInvalidControlFileException(String.format("Failed reading %d revisions in [%d; %d]", c, sortedRevisions[0], sortedRevisions[c-1]), ex, indexFile); |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
368 } finally { |
593
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
369 CachedRevision cr = r.finish(); |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
370 setLastRevisionRead(cr); |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
371 } |
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
372 } |
607
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
373 |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
374 public void attach(Observer listener) { |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
375 assert listener != null; |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
376 if (observers == null) { |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
377 observers = new ArrayList<Observer>(3); |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
378 } |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
379 observers.add(listener); |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
380 } |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
381 |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
382 public void detach(Observer listener) { |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
383 assert listener != null; |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
384 if (observers != null) { |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
385 observers.remove(listener); |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
386 } |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
387 } |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
388 |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
389 /* |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
390 * Note, this method IS NOT a replacement for Observer. It has to be invoked when the validity of any |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
391 * cache built using revision information is in doubt, but it provides reasonable value only till the |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
392 * first initOutline() to be invoked, i.e. in [change..revlog read operation] time frame. If your code |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
393 * accesses cached information without any prior explicit read operation, you shall consult this method |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
394 * if next read operation would in fact bring changed content. |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
395 * Observer is needed in addition to this method because any revlog read operation (e.g. Revlog#getLastRevision) |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
396 * would clear shallDropDerivedCaches(), and if code relies only on this method to clear its derived caches, |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
397 * it would miss the update. |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
398 */ |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
399 public boolean shallDropDerivedCaches() { |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
400 if (shallDropDerivedCaches) { |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
401 return shallDropDerivedCaches; |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
402 } |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
403 return shallDropDerivedCaches = changeTracker.hasChanged(indexFile); |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
404 } |
198
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
405 |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
406 void revisionAdded(int revisionIndex, Nodeid revision, int baseRevisionIndex, long revisionOffset) throws HgInvalidControlFileException { |
607
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
407 shallDropDerivedCaches = true; |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
408 if (!outlineCached()) { |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
409 return; |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
410 } |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
411 if (baseRevisions.length != revisionIndex) { |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
412 throw new HgInvalidControlFileException(String.format("New entry's index shall be %d, not %d", baseRevisions.length, revisionIndex), null, indexFile); |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
413 } |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
414 if (baseRevisionIndex < 0 || baseRevisionIndex > baseRevisions.length) { |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
415 // baseRevisionIndex MAY be == to baseRevisions.length, it's when new revision is based on itself |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
416 throw new HgInvalidControlFileException(String.format("Base revision index %d doesn't fit [0..%d] range", baseRevisionIndex, baseRevisions.length), null, indexFile); |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
417 } |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
418 assert revision != null; |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
419 assert !revision.isNull(); |
621
99ad1e3a4e4d
RevlogStream: be aware of existence (not HgDataFile), facilitate use of an added HgDataFile over a commit; Rollback: be more sensitive about file changes (file size is not enough: write/rollback leaves it intact); tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
617
diff
changeset
|
420 // next effort doesn't seem to be of any value at least in case of regular commit |
99ad1e3a4e4d
RevlogStream: be aware of existence (not HgDataFile), facilitate use of an added HgDataFile over a commit; Rollback: be more sensitive about file changes (file size is not enough: write/rollback leaves it intact); tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
617
diff
changeset
|
421 // as the next call to #initOutline would recognize the file change and reload complete revlog anyway |
99ad1e3a4e4d
RevlogStream: be aware of existence (not HgDataFile), facilitate use of an added HgDataFile over a commit; Rollback: be more sensitive about file changes (file size is not enough: write/rollback leaves it intact); tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
617
diff
changeset
|
422 // OTOH, there might be transaction strategy that doesn't update the file until its completion, |
99ad1e3a4e4d
RevlogStream: be aware of existence (not HgDataFile), facilitate use of an added HgDataFile over a commit; Rollback: be more sensitive about file changes (file size is not enough: write/rollback leaves it intact); tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
617
diff
changeset
|
423 // while it's handy to know new revisions meanwhile. |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
424 int[] baseRevisionsCopy = new int[baseRevisions.length + 1]; |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
425 System.arraycopy(baseRevisions, 0, baseRevisionsCopy, 0, baseRevisions.length); |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
426 baseRevisionsCopy[baseRevisions.length] = baseRevisionIndex; |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
427 baseRevisions = baseRevisionsCopy; |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
428 if (inline && indexRecordOffset != null) { |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
429 assert indexRecordOffset.length == revisionIndex; |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
430 int[] indexRecordOffsetCopy = new int[indexRecordOffset.length + 1]; |
559
6ca3d0c5b4bc
Commit: tests and fixes for defects discovered
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
539
diff
changeset
|
431 System.arraycopy(indexRecordOffset, 0, indexRecordOffsetCopy, 0, indexRecordOffset.length); |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
432 indexRecordOffsetCopy[indexRecordOffset.length] = offsetFieldToInlineFileOffset(revisionOffset, revisionIndex); |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
433 indexRecordOffset = indexRecordOffsetCopy; |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
434 } |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
435 } |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
436 |
198
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
437 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
|
438 return baseRevisions[revision]; |
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
439 } |
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
440 |
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
441 /** |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
442 * @param revisionIndex shall be valid index, [0..baseRevisions.length-1]. |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
443 * It's advised to use {@link #checkRevisionIndex(int)} to ensure argument is correct. |
198
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
444 * @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
|
445 */ |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
446 private int getIndexOffsetInt(int revisionIndex) { |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
447 return inline ? indexRecordOffset[revisionIndex] : revisionIndex * REVLOGV1_RECORD_SIZE; |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
448 } |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
449 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
450 private int checkRevisionIndex(int revisionIndex) throws HgInvalidControlFileException, HgInvalidRevisionException { |
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
451 final int last = revisionCount() - 1; |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
452 if (revisionIndex == TIP) { |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
453 revisionIndex = last; |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
454 } |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
455 if (revisionIndex < 0 || revisionIndex > last) { |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
456 throw new HgInvalidRevisionException(revisionIndex).setRevisionIndex(revisionIndex, 0, last); |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
457 } |
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
347
diff
changeset
|
458 return revisionIndex; |
198
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
459 } |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
460 |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
461 private boolean outlineCached() { |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
462 return baseRevisions != null && baseRevisions.length > 0; |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
463 } |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
464 |
584
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
465 // translate 6-byte offset field value to physical file offset for inline revlogs |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
466 // DOESN'T MAKE SENSE if revlog with data is separate |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
467 private static int offsetFieldToInlineFileOffset(long offset, int recordIndex) throws HgInvalidStateException { |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
468 int o = Internals.ltoi(offset); |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
469 if (o != offset) { |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
470 // just in case, can't happen, ever, unless HG (or some other bad tool) produces index file |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
471 // with inlined data of size greater than 2 Gb. |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
472 throw new HgInvalidStateException("Data too big, offset didn't fit to sizeof(int)"); |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
473 } |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
474 return o + REVLOGV1_RECORD_SIZE * recordIndex; |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
475 } |
198
33a7d76f067b
Performance optimization: reduce memory to keep revlog cached info
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
170
diff
changeset
|
476 |
607
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
477 // every access to index revlog goes after this method only. |
425
48f993aa2f41
FIXMEs: exceptions, javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
423
diff
changeset
|
478 private void initOutline() throws HgInvalidControlFileException { |
607
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
479 // true to send out 'drop-your-caches' event after outline has been built |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
480 final boolean notifyReload; |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
481 if (outlineCached()) { |
607
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
482 if (!changeTracker.hasChanged(indexFile)) { |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
483 return; |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
484 } |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
485 notifyReload = true; |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
486 } else { |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
487 // no cached outline - inital read, do not send any reload/invalidate notifications |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
488 notifyReload = false; |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
489 } |
607
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
490 changeTracker.touch(indexFile); |
606
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
491 DataAccess da = getIndexStream(false); |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
492 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
|
493 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
|
494 // 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
|
495 baseRevisions = new int[0]; |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
496 // empty revlog, likely to be populated, indicate we start with a single file |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
497 inline = true; |
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
|
498 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
|
499 } |
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
|
500 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
|
501 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
|
502 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
|
503 IntVector resBases, resOffsets = null; |
420
6c22bdc0bdfd
Respect long offsets in revlogs
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
398
diff
changeset
|
504 int entryCountGuess = Internals.ltoi(da.longLength() / REVLOGV1_RECORD_SIZE); |
288
b11f6a08f748
Avoid boxing int values and list resizes on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
505 if (inline) { |
b11f6a08f748
Avoid boxing int values and list resizes on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
506 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
|
507 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
|
508 } |
b11f6a08f748
Avoid boxing int values and list resizes on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
509 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
|
510 |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
511 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
|
512 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
|
513 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
|
514 // 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
|
515 @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
|
516 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
|
517 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
|
518 // 12 + 8 = 20 bytes read here |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
519 // int linkRevision = di.readInt(); |
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
520 // int parent1Revision = di.readInt(); |
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
521 // int parent2Revision = di.readInt(); |
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
522 // 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
|
523 resBases.add(baseRevision); |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
524 if (inline) { |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
525 int o = offsetFieldToInlineFileOffset(offset, resOffsets.size()); |
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
526 resOffsets.add(o); |
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
|
527 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
|
528 } 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
|
529 da.skip(3*4 + 32); |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
530 } |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
531 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
|
532 // 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
|
533 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
|
534 if (inline) { |
288
b11f6a08f748
Avoid boxing int values and list resizes on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
280
diff
changeset
|
535 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
|
536 } |
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
|
537 break; |
10
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
538 } else { |
382cfe9463db
Dirstate parsing. DataAccess refactored to allow reuse and control over constants
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
9
diff
changeset
|
539 // 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
|
540 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
|
541 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
|
542 } |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
543 } |
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
544 } catch (IOException ex) { |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
420
diff
changeset
|
545 throw new HgInvalidControlFileException("Failed to analyze revlog index", ex, indexFile); |
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
|
546 } 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
|
547 da.done(); |
607
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
548 if (notifyReload && observers != null) { |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
549 for (Observer l : observers) { |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
550 l.reloaded(this); |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
551 } |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
552 shallDropDerivedCaches = false; |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
553 } |
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
554 } |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
555 } |
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
556 |
593
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
557 private CachedRevision getLastRevisionRead() { |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
558 return lastRevisionRead == null ? null : lastRevisionRead.get(); |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
559 } |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
560 |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
561 private void setLastRevisionRead(CachedRevision cr) { |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
562 // done() for lastRevisionRead.userData has been called by ReaderN1 once |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
563 // it noticed unsuitable DataAccess. |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
564 // Now, done() for any CachedRevision cleared by GC: |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
565 for (Reference<? extends CachedRevision> r; (r = lastRevisionQueue.poll()) != null;) { |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
566 CachedRevision toClean = r.get(); |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
567 if (toClean != null && toClean.userData != null) { |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
568 toClean.userData.done(); |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
569 } |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
570 } |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
571 if (cr != null) { |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
572 lastRevisionRead = new SoftReference<CachedRevision>(cr, lastRevisionQueue); |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
573 } else { |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
574 lastRevisionRead = null; |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
575 } |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
576 } |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
577 |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
578 final static class CachedRevision { |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
579 final int revision; |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
580 final DataAccess userData; |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
581 |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
582 public CachedRevision(int lastRevisionRead, DataAccess lastUserData) { |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
583 revision = lastRevisionRead; |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
584 userData = lastUserData; |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
585 } |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
586 } |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
587 |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
588 /** |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
589 * operation with single file open/close and multiple diverse reads. |
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
354
diff
changeset
|
590 * XXX initOutline might need similar extraction to keep N1 format knowledge |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
591 */ |
584
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
592 final class ReaderN1 { |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
593 private final Inspector inspector; |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
594 private final boolean needData; |
584
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
595 private final boolean mergePatches; |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
596 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
|
597 private Lifecycle.BasicCallback cb = null; |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
440
diff
changeset
|
598 private Lifecycle lifecycleListener = null; |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
599 private int lastRevisionRead = BAD_REVISION; |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
600 private DataAccess lastUserData; |
584
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
601 // |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
602 // next are transient values, for range() use only |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
603 private final Inflater inflater = new Inflater(); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
604 // can share buffer between instances of InflaterDataAccess as I never read any two of them in parallel |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
605 private final byte[] inflaterBuffer = new byte[10 * 1024]; // TODO [post-1.1] consider using DAP.DEFAULT_FILE_BUFFER |
584
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
606 private final byte[] nodeidBuf = new byte[20]; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
607 // revlog record fields |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
608 private long offset; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
609 @SuppressWarnings("unused") |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
610 private int flags; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
611 private int compressedLen; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
612 private int actualLen; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
613 private int baseRevision; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
614 private int linkRevision; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
615 private int parent1Revision; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
616 private int parent2Revision; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
617 |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
618 public ReaderN1(boolean dataRequested, Inspector insp, boolean usePatchMerge) { |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
619 assert insp != null; |
584
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
620 needData = dataRequested; |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
621 inspector = insp; |
584
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
622 mergePatches = usePatchMerge; |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
623 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
624 |
593
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
625 public void start(int totalWork, CachedRevision cachedRevision) { |
606
5daa42067e7c
Avoid mmap files when only few bytes are to be read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
594
diff
changeset
|
626 daIndex = getIndexStream(totalWork <= 10); |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
627 if (needData && !inline) { |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
628 daData = getDataStream(); |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
629 } |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
440
diff
changeset
|
630 lifecycleListener = Adaptable.Factory.getAdapter(inspector, Lifecycle.class, null); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
440
diff
changeset
|
631 if (lifecycleListener != null) { |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
632 cb = new Lifecycle.BasicCallback(); |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
440
diff
changeset
|
633 lifecycleListener.start(totalWork, cb, cb); |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
634 } |
593
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
635 if (needData && cachedRevision != null) { |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
636 lastUserData = cachedRevision.userData; |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
637 lastRevisionRead = cachedRevision.revision; |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
638 assert lastUserData != null; |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
639 } |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
640 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
641 |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
440
diff
changeset
|
642 // invoked only once per instance |
593
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
643 public CachedRevision finish() { |
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
644 CachedRevision rv = null; |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
645 if (lastUserData != null) { |
594
cc7b0c4dc993
Cache only in-memory revision representations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
593
diff
changeset
|
646 if (lastUserData instanceof ByteArrayDataAccess) { |
cc7b0c4dc993
Cache only in-memory revision representations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
593
diff
changeset
|
647 // it's safe to cache only in-memory revision texts, |
cc7b0c4dc993
Cache only in-memory revision representations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
593
diff
changeset
|
648 // if lastUserData is merely a filter over file stream, |
cc7b0c4dc993
Cache only in-memory revision representations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
593
diff
changeset
|
649 // we'd need to keep file open, and this is bad. |
cc7b0c4dc993
Cache only in-memory revision representations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
593
diff
changeset
|
650 // XXX perhaps, wrap any DataAccess.byteArray into |
cc7b0c4dc993
Cache only in-memory revision representations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
593
diff
changeset
|
651 // ByteArrayDataAccess? |
cc7b0c4dc993
Cache only in-memory revision representations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
593
diff
changeset
|
652 rv = new CachedRevision(lastRevisionRead, lastUserData); |
cc7b0c4dc993
Cache only in-memory revision representations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
593
diff
changeset
|
653 } else { |
cc7b0c4dc993
Cache only in-memory revision representations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
593
diff
changeset
|
654 lastUserData.done(); |
cc7b0c4dc993
Cache only in-memory revision representations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
593
diff
changeset
|
655 } |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
656 lastUserData = null; |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
657 } |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
440
diff
changeset
|
658 if (lifecycleListener != null) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
440
diff
changeset
|
659 lifecycleListener.finish(cb); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
440
diff
changeset
|
660 lifecycleListener = null; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
440
diff
changeset
|
661 cb = null; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
440
diff
changeset
|
662 |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
663 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
664 daIndex.done(); |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
665 if (daData != null) { |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
666 daData.done(); |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
440
diff
changeset
|
667 daData = null; |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
668 } |
593
9619301a7bb9
Share last revision read between #iterate() invocations, to save revision rebuild efforts when few subsequent revisions are read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
585
diff
changeset
|
669 return rv; |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
670 } |
584
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
671 |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
672 private void readHeaderRecord(int i) throws IOException { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
673 if (inline && needData) { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
674 // inspector reading data (though FilterDataAccess) may have affected index position |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
675 daIndex.seek(getIndexOffsetInt(i)); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
676 } |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
677 long l = daIndex.readLong(); // 0 |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
678 offset = i == 0 ? 0 : (l >>> 16); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
679 flags = (int) (l & 0x0FFFF); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
680 compressedLen = daIndex.readInt(); // +8 |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
681 actualLen = daIndex.readInt(); // +12 |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
682 baseRevision = daIndex.readInt(); // +16 |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
683 linkRevision = daIndex.readInt(); // +20 |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
684 parent1Revision = daIndex.readInt(); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
685 parent2Revision = daIndex.readInt(); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
686 // Hg has 32 bytes here, uses 20 for nodeid, and keeps 12 last bytes empty |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
687 daIndex.readBytes(nodeidBuf, 0, 20); // +32 |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
688 daIndex.skip(12); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
689 } |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
690 |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
691 private boolean isPatch(int i) { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
692 return baseRevision != i; // the only way I found to tell if it's a patch |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
693 } |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
694 |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
695 private DataAccess getStoredData(int i) throws IOException { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
696 DataAccess userDataAccess = null; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
697 DataAccess streamDataAccess; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
698 long streamOffset; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
699 if (inline) { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
700 streamOffset = getIndexOffsetInt(i) + REVLOGV1_RECORD_SIZE; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
701 streamDataAccess = daIndex; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
702 // don't need to do seek as it's actual position in the index stream, but it's safe to seek, just in case |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
703 daIndex.longSeek(streamOffset); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
704 } else { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
705 streamOffset = offset; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
706 streamDataAccess = daData; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
707 daData.longSeek(streamOffset); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
708 } |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
709 if (streamDataAccess.isEmpty() || compressedLen == 0) { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
710 userDataAccess = new DataAccess(); // empty |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
711 } else { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
712 final byte firstByte = streamDataAccess.readByte(); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
713 if (firstByte == 0x78 /* 'x' */) { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
714 inflater.reset(); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
715 userDataAccess = new InflaterDataAccess(streamDataAccess, streamOffset, compressedLen, isPatch(i) ? -1 : actualLen, inflater, inflaterBuffer); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
716 } else if (firstByte == 0x75 /* 'u' */) { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
717 userDataAccess = new FilterDataAccess(streamDataAccess, streamOffset+1, compressedLen-1); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
718 } else { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
719 // XXX Python impl in fact throws exception when there's not 'x', 'u' or '0' but I don't see reason not to return data as is |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
720 // |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
721 // although firstByte is already read from the streamDataAccess, FilterDataAccess#readByte would seek to |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
722 // initial offset before first attempt to read a byte |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
723 userDataAccess = new FilterDataAccess(streamDataAccess, streamOffset, compressedLen); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
724 } |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
725 } |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
726 return userDataAccess; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
727 } |
263
31f67be94e71
RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
258
diff
changeset
|
728 |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
440
diff
changeset
|
729 // may be invoked few times per instance life |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
730 public boolean range(int start, int end) throws IOException, HgRuntimeException { |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
731 int i; |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
732 // 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
|
733 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
|
734 // 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
|
735 // 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
|
736 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
|
737 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
|
738 } else { |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
739 if (lastUserData != null) { |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
740 lastUserData.done(); |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
741 lastUserData = null; |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
742 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
743 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
744 } else { |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
745 // 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
|
746 i = start; |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
747 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
748 |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
749 daIndex.seek(getIndexOffsetInt(i)); |
258
e5776067b3b8
Reduce number of objects instantiated on revlog read
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
243
diff
changeset
|
750 // |
584
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
751 // reuse instance, do not normalize it as patches from the stream are unlikely to need it |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
752 final Patch patch = new Patch(false); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
753 // |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
754 if (needData && mergePatches && start-i > 2) { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
755 // i+1 == start just reads lastUserData, i+2 == start applies one patch - not worth dedicated effort |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
756 Patch ultimatePatch = new Patch(true); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
757 for ( ; i < start; i++) { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
758 readHeaderRecord(i); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
759 DataAccess userDataAccess = getStoredData(i); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
760 if (lastUserData == null) { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
761 assert !isPatch(i); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
762 lastUserData = userDataAccess; |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
763 } else { |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
764 assert isPatch(i); // i < start and i == getBaseRevision() |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
765 patch.read(userDataAccess); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
766 userDataAccess.done(); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
767 // I assume empty patches are applied ok |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
768 ultimatePatch = ultimatePatch.apply(patch); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
769 patch.clear(); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
770 } |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
771 } |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
772 lastUserData.reset(); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
773 byte[] userData = ultimatePatch.apply(lastUserData, actualLen); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
774 ultimatePatch.clear(); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
775 lastUserData.done(); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
776 lastUserData = new ByteArrayDataAccess(userData); |
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
777 } |
263
31f67be94e71
RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
258
diff
changeset
|
778 // |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
779 |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
780 for (; i <= end; i++ ) { |
584
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
781 readHeaderRecord(i); |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
782 DataAccess userDataAccess = null; |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
783 if (needData) { |
584
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
784 userDataAccess = getStoredData(i); |
397
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
785 // userDataAccess is revision content, either complete revision, patch of a previous content, or an empty patch |
584
ed243b668502
Conditionally enable effective patch merge alternative for revlog reading
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
580
diff
changeset
|
786 if (isPatch(i)) { |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
787 // this is a patch |
397
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
788 if (userDataAccess.isEmpty()) { |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
789 // Issue 22, empty patch to an empty base revision |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
790 // Issue 24, empty patch to non-empty base revision |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
791 // empty patch modifies nothing, use content of a previous revision (shall present - it's a patch here) |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
792 // |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
793 assert lastUserData.length() == actualLen; // with no patch, data size shall be the same |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
794 userDataAccess = lastUserData; |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
795 } else { |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
796 patch.read(userDataAccess); |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
797 userDataAccess.done(); |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
798 // |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
799 // it shall be reset at the end of prev iteration, when it got assigned from userDataAccess |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
800 // however, actual userDataAccess and lastUserData may share Inflater object, which needs to be reset |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
801 // Alternatively, userDataAccess.done() above may be responsible to reset Inflater (if it's InflaterDataAccess) |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
802 lastUserData.reset(); |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
803 // final long startMeasuring = System.currentTimeMillis(); // TIMING |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
804 byte[] userData = patch.apply(lastUserData, actualLen); |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
805 // applyTime += (System.currentTimeMillis() - startMeasuring); // TIMING |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
806 patch.clear(); // do not keep any reference, allow byte[] data to be gc'd |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
807 userDataAccess = new ByteArrayDataAccess(userData); |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
808 } |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
809 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
810 } else { |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
811 if (inline) { |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
812 daIndex.skip(compressedLen); |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
813 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
814 } |
329
694ebabb5cb3
Refactor revlog patch mechanism, towards patch merging
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
300
diff
changeset
|
815 if (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
|
816 // 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
|
817 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
|
818 // 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
|
819 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
820 if (cb != null) { |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
821 if (cb.isStopped()) { |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
822 return false; |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
823 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
824 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
825 if (userDataAccess != null) { |
263
31f67be94e71
RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
258
diff
changeset
|
826 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
|
827 } |
397
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
828 if (lastUserData != null && lastUserData != userDataAccess /* empty patch case, reuse of recent data in actual revision */) { |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
829 // release lastUserData only if we didn't reuse it in actual revision due to empty patch: |
5e95b0da26f2
Issue 24: IAE, Underflow in FilterDataAccess. Issue 26:UnsupportedOperationException when patching empty base revision. Tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
377
diff
changeset
|
830 // empty patch means we have previous revision and didn't alter it with a patch, hence use lastUserData for userDataAccess above |
263
31f67be94e71
RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
258
diff
changeset
|
831 lastUserData.done(); |
31f67be94e71
RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
258
diff
changeset
|
832 } |
31f67be94e71
RevlogStream - reduce number of object instances, reuse when possible
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
258
diff
changeset
|
833 lastUserData = userDataAccess; |
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
834 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
835 lastRevisionRead = end; |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
836 return true; |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
837 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
838 } |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
839 |
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
223
diff
changeset
|
840 |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
841 public interface Inspector { |
608
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
842 /** |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
843 * XXX boolean retVal to indicate whether to continue? |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
844 * |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
845 * Implementers shall not invoke DataAccess.done(), it's accomplished by #iterate at appropriate moment |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
846 * |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
847 * @param revisionIndex absolute index of revision in revlog being iterated |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
848 * @param actualLen length of the user data at this revision |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
849 * @param baseRevision last revision known to hold complete revision (other hold patches). |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
850 * if baseRevision != revisionIndex, data for this revision is a result of a sequence of patches |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
851 * @param linkRevision index of corresponding changeset revision |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
852 * @param parent1Revision index of first parent revision in this revlog, or {@link HgRepository#NO_REVISION} |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
853 * @param parent2Revision index of second parent revision in this revlog, or {@link HgRepository#NO_REVISION} |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
854 * @param nodeid 20-byte buffer, shared between invocations |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
855 * @param data access to revision content of actualLen size, or <code>null</code> if no data has been requested with |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
856 * {@link RevlogStream#iterate(int[], boolean, Inspector)} |
e1b29756f901
Clean, organize and resolve some TODOs and FIXMEs: minor refactorings and comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
607
diff
changeset
|
857 */ |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
621
diff
changeset
|
858 void next(int revisionIndex, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[/*20*/] nodeid, DataAccess data) throws HgRuntimeException; |
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
859 } |
539
9edfd5a223b8
Commit: handle empty repository case
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
538
diff
changeset
|
860 |
607
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
861 public interface Observer { |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
862 // notify observer of invalidate/reload event in the stream |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
863 public void reloaded(RevlogStream src); |
66f1cc23b906
Refresh revlogs if a change to a file has been detected; do not force reload of the whole repository
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
606
diff
changeset
|
864 } |
0
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
865 } |