Mercurial > jhg
annotate src/org/tmatesoft/hg/repo/HgChangelog.java @ 702:992fa84e7885
Reference ssh-dependant class by the fq name to avoid runtime dependency from the ssh library
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Thu, 08 Aug 2013 21:32:22 +0200 |
| parents | 545b1d4cc11d |
| children |
| rev | line source |
|---|---|
|
21
e929cecae4e1
Refactor to move revlog content to base class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
3
diff
changeset
|
1 /* |
|
589
c18095eedde0
Username in changeset uses UTF-8, not system encoding
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:
48
diff
changeset
|
3 * |
|
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
48
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:
48
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:
48
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:
48
diff
changeset
|
7 * |
|
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
48
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:
48
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:
48
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:
48
diff
changeset
|
11 * GNU General Public License for more details. |
|
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
48
diff
changeset
|
12 * |
|
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
48
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:
48
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:
97
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 */ |
|
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
48
diff
changeset
|
17 package org.tmatesoft.hg.repo; |
|
0
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
|
157
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
diff
changeset
|
19 import java.io.IOException; |
|
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
20 import java.util.ArrayList; |
|
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
21 import java.util.Arrays; |
|
146
8c9f729f4dfa
Timezone finally in use
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
137
diff
changeset
|
22 import java.util.Calendar; |
|
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
23 import java.util.Date; |
|
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
24 import java.util.Formatter; |
|
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
25 import java.util.List; |
|
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
26 import java.util.Locale; |
|
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
27 import java.util.Map; |
|
146
8c9f729f4dfa
Timezone finally in use
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
137
diff
changeset
|
28 import java.util.TimeZone; |
|
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
29 |
|
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
48
diff
changeset
|
30 import org.tmatesoft.hg.core.Nodeid; |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
31 import org.tmatesoft.hg.core.SessionContext; |
|
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:
419
diff
changeset
|
32 import org.tmatesoft.hg.internal.Callback; |
|
673
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
33 import org.tmatesoft.hg.internal.ChangesetParser; |
|
157
d5268ca7715b
Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
diff
changeset
|
34 import org.tmatesoft.hg.internal.DataAccess; |
|
312
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
252
diff
changeset
|
35 import org.tmatesoft.hg.internal.Lifecycle; |
|
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:
427
diff
changeset
|
36 import org.tmatesoft.hg.internal.LifecycleBridge; |
|
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
37 import org.tmatesoft.hg.internal.RevlogStream; |
|
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:
427
diff
changeset
|
38 import org.tmatesoft.hg.util.Adaptable; |
|
312
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
252
diff
changeset
|
39 import org.tmatesoft.hg.util.CancelSupport; |
|
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
252
diff
changeset
|
40 import org.tmatesoft.hg.util.ProgressSupport; |
|
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
48
diff
changeset
|
41 |
|
0
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
42 /** |
|
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
43 * Representation of the Mercurial changelog file (list of ChangeSets) |
| 153 | 44 * |
|
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
48
diff
changeset
|
45 * @author Artem Tikhomirov |
|
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
48
diff
changeset
|
46 * @author TMate Software Ltd. |
|
0
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 */ |
|
426
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
48 public final class HgChangelog extends Revlog { |
|
0
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
49 |
| 153 | 50 /* package-local */HgChangelog(HgRepository hgRepo, RevlogStream content) { |
|
600
46f29b73e51e
Utilize RevisionLookup to speed-up getRevisionIndex of both manifest and changelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
589
diff
changeset
|
51 super(hgRepo, content, true); |
|
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
52 } |
|
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
53 |
|
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
54 /** |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
55 * Iterate over whole changelog |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
56 * @param inspector callback to process entries |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
57 * @throws HgInvalidControlFileException if failed to access revlog index/data entry. <em>Runtime exception</em> |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
58 * @throws HgRuntimeException subclass thereof to indicate other 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:
600
diff
changeset
|
59 */ |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
60 public void all(final HgChangelog.Inspector inspector) throws HgRuntimeException { |
|
137
144d771ee73c
explicit op name instead math op to get last rev number
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
135
diff
changeset
|
61 range(0, getLastRevision(), inspector); |
|
48
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
62 } |
|
e34f90b9ded1
Limit option for history/log
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
47
diff
changeset
|
63 |
|
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
64 /** |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
65 * Iterate over changelog part |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
66 * @param start first changelog entry to process |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
67 * @param end last changelog entry to process |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
68 * @param inspector callback to process entries |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
69 * @throws HgInvalidRevisionException if any supplied revision doesn't identify revision from this revlog. <em>Runtime exception</em> |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
70 * @throws HgInvalidControlFileException if failed to access revlog index/data entry. <em>Runtime exception</em> |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
71 * @throws HgRuntimeException subclass thereof to indicate other 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:
600
diff
changeset
|
72 */ |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
73 public void range(int start, int end, final HgChangelog.Inspector inspector) throws HgRuntimeException { |
|
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
74 if (inspector == null) { |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
75 throw new IllegalArgumentException(); |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
76 } |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
77 content.iterate(start, end, true, new RawCsetParser(getRepo(), inspector)); |
|
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
78 } |
|
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
79 |
|
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
80 /** |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
81 * @see #range(int, int, Inspector) |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
82 * @return changeset entry objects, never <code>null</code> |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
83 * @throws HgInvalidRevisionException if any supplied revision doesn't identify revision from this revlog. <em>Runtime exception</em> |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
84 * @throws HgInvalidControlFileException if failed to access revlog index/data entry. <em>Runtime exception</em> |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
85 * @throws HgRuntimeException subclass thereof to indicate other 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:
600
diff
changeset
|
86 */ |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
87 public List<RawChangeset> range(int start, int end) throws HgRuntimeException { |
|
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
88 final RawCsetCollector c = new RawCsetCollector(end - start + 1); |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
89 range(start, end, c); |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
90 return c.result; |
|
2
08db726a0fb7
Shaping out low-level Hg structures
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
0
diff
changeset
|
91 } |
|
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
92 |
|
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
93 /** |
|
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
94 * Access individual revisions. Note, regardless of supplied revision order, inspector gets |
|
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
95 * changesets strictly in the order they are in the changelog. |
|
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
96 * @param inspector callback to get changesets |
|
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
97 * @param revisions revisions to read, unrestricted ordering. |
|
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
98 * @throws HgInvalidRevisionException if any supplied revision doesn't identify revision from this revlog <em>Runtime exception</em> |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
99 * @throws HgInvalidControlFileException if failed to access revlog index/data entry. <em>Runtime exception</em> |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
100 * @throws HgRuntimeException subclass thereof to indicate other 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:
236
diff
changeset
|
101 */ |
|
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
102 public void range(final HgChangelog.Inspector inspector, final int... revisions) throws HgRuntimeException { |
|
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
103 Arrays.sort(revisions); |
|
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
104 rangeInternal(inspector, revisions); |
|
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
105 } |
|
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
106 |
|
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
107 /** |
|
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
108 * Friends-only version of {@link #range(Inspector, int...)}, when callers know array is sorted |
|
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
109 */ |
|
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
110 /*package-local*/ void rangeInternal(HgChangelog.Inspector inspector, int[] sortedRevisions) throws HgRuntimeException { |
|
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
111 if (sortedRevisions == null || sortedRevisions.length == 0) { |
|
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
112 return; |
|
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
113 } |
|
242
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
114 if (inspector == null) { |
|
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
115 throw new IllegalArgumentException(); |
|
ad6a046943be
Improved reading of sparse revisions from a revlog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
236
diff
changeset
|
116 } |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
117 content.iterate(sortedRevisions, true, new RawCsetParser(getRepo(), inspector)); |
|
3
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
2
diff
changeset
|
118 } |
|
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
119 |
|
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
120 /** |
|
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
121 * Get changeset entry object |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
122 * @throws HgInvalidRevisionException if supplied nodeid doesn't identify any revision from this revlog. <em>Runtime exception</em> |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
123 * @throws HgInvalidControlFileException if failed to access revlog index/data entry. <em>Runtime exception</em> |
|
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
124 * @throws HgRuntimeException subclass thereof to indicate other issues with the library. <em>Runtime exception</em> |
|
354
5f9073eabf06
Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
329
diff
changeset
|
125 */ |
|
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
126 public RawChangeset changeset(Nodeid nid) throws HgRuntimeException { |
|
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
|
127 int x = getRevisionIndex(nid); |
|
236
883300108179
Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
211
diff
changeset
|
128 return range(x, x).get(0); |
|
883300108179
Speed up branches calculation when cached branch information is available
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
211
diff
changeset
|
129 } |
|
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
130 |
|
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:
419
diff
changeset
|
131 @Callback |
|
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
132 public interface Inspector { |
|
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:
419
diff
changeset
|
133 /** |
|
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:
419
diff
changeset
|
134 * Access next changeset |
|
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:
419
diff
changeset
|
135 * TODO describe what revisionNumber is when Inspector is used with HgBundle (BAD_REVISION or bundle's local order?) |
|
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:
419
diff
changeset
|
136 * |
|
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:
419
diff
changeset
|
137 * @param revisionIndex index of revision being inspected, local to the inspected object |
|
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:
419
diff
changeset
|
138 * @param nodeid revision being inspected |
|
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:
419
diff
changeset
|
139 * @param cset changeset raw data |
|
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:
419
diff
changeset
|
140 */ |
|
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
141 void next(int revisionIndex, Nodeid nodeid, RawChangeset cset) throws HgRuntimeException; |
|
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
142 } |
|
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
143 |
|
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
144 /** |
|
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
145 * Entry in the Changelog |
|
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
146 */ |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
147 public static final class RawChangeset implements Cloneable /* for those that would like to keep a copy */{ |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
148 // would be nice to get it immutable, but then we can't reuse instances |
|
673
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
149 /* final */Nodeid manifest; |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
150 String user; |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
151 String comment; |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
152 String[] files; // shall not be modified (#clone() does shallow copy) |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
153 Date time; |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
154 int timezone; |
|
161
9423235ca77b
Record possible value (and knowledge source) for extras field
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
155 // http://mercurial.selenic.com/wiki/PruningDeadBranches - Closing changesets can be identified by close=1 in the changeset's extra field. |
|
673
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
156 Map<String, String> extras; |
|
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
157 |
|
154
ba2bf656f00f
Changeset => RawChangeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
153
diff
changeset
|
158 private RawChangeset() { |
| 153 | 159 } |
|
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
160 |
| 153 | 161 public Nodeid manifest() { |
| 162 return manifest; | |
| 163 } | |
|
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
164 |
| 153 | 165 public String user() { |
| 166 return user; | |
| 167 } | |
| 168 | |
| 169 public String comment() { | |
| 170 return comment; | |
| 171 } | |
| 172 | |
| 173 public List<String> files() { | |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
174 return Arrays.asList(files); |
| 153 | 175 } |
| 176 | |
| 177 public Date date() { | |
| 178 return time; | |
| 179 } | |
|
211
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
180 |
|
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
181 /** |
|
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
182 * @return time zone value, as is, positive for Western Hemisphere. |
|
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
183 */ |
|
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
184 public int timezone() { |
|
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
185 return timezone; |
|
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
186 } |
| 153 | 187 |
| 188 public String dateString() { | |
| 189 // XXX keep once formatted? Perhaps, there's faster way to set up calendar/time zone? | |
| 190 StringBuilder sb = new StringBuilder(30); | |
| 191 Formatter f = new Formatter(sb, Locale.US); | |
|
211
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
192 TimeZone tz = TimeZone.getTimeZone(TimeZone.getAvailableIDs(timezone * 1000)[0]); |
| 153 | 193 // apparently timezone field records number of seconds time differs from UTC, |
| 194 // i.e. value to substract from time to get UTC time. Calendar seems to add | |
| 195 // timezone offset to UTC, instead, hence sign change. | |
|
211
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
196
diff
changeset
|
196 // tz.setRawOffset(timezone * -1000); |
| 153 | 197 Calendar c = Calendar.getInstance(tz, Locale.US); |
| 198 c.setTime(time); | |
| 199 f.format("%ta %<tb %<td %<tH:%<tM:%<tS %<tY %<tz", c); | |
| 200 return sb.toString(); | |
| 201 } | |
| 202 | |
| 203 public Map<String, String> extras() { | |
| 204 return extras; | |
| 205 } | |
| 206 | |
| 207 public String branch() { | |
| 208 return extras.get("branch"); | |
| 209 } | |
| 210 | |
| 211 @Override | |
| 212 public String toString() { | |
| 213 StringBuilder sb = new StringBuilder(); | |
| 214 sb.append("Changeset {"); | |
| 215 sb.append("User: ").append(user).append(", "); | |
| 216 sb.append("Comment: ").append(comment).append(", "); | |
| 217 sb.append("Manifest: ").append(manifest).append(", "); | |
| 218 sb.append("Date: ").append(time).append(", "); | |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
219 sb.append("Files: ").append(files.length); |
| 153 | 220 for (String s : files) { |
| 221 sb.append(", ").append(s); | |
| 222 } | |
| 223 if (extras != null) { | |
| 224 sb.append(", Extra: ").append(extras); | |
| 225 } | |
| 226 sb.append("}"); | |
| 227 return sb.toString(); | |
| 228 } | |
| 229 | |
| 230 @Override | |
|
154
ba2bf656f00f
Changeset => RawChangeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
153
diff
changeset
|
231 public RawChangeset clone() { |
| 153 | 232 try { |
|
154
ba2bf656f00f
Changeset => RawChangeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
153
diff
changeset
|
233 return (RawChangeset) super.clone(); |
| 153 | 234 } catch (CloneNotSupportedException ex) { |
| 235 throw new InternalError(ex.toString()); | |
| 236 } | |
| 237 } | |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
238 } |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
239 |
|
673
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
240 /*package-local*/static final class RawCsetFactory implements ChangesetParser.CsetFactory { |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
241 private RawChangeset cset; |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
242 |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
243 public RawCsetFactory(boolean shallReuseCsetInstance) { |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
244 if (shallReuseCsetInstance) { |
|
673
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
245 cset = new RawChangeset(); |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
246 } |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
247 } |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
248 |
|
673
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
249 public RawChangeset create(Nodeid nodeidManifest, String user, Date time, int timezone, List<String> files, String comment, Map<String, String> extrasMap) { |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
250 RawChangeset target; |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
251 if (cset != null) { |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
252 target = cset; |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
253 } else { |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
254 target = new RawChangeset(); |
| 153 | 255 } |
|
673
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
256 target.manifest = nodeidManifest; |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
257 target.user = user; |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
258 target.time = time; |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
259 target.timezone = timezone; |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
260 target.files = files == null ? new String[0] : files.toArray(new String[files.size()]); |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
261 target.comment = comment; |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
262 target.extras = extrasMap; |
|
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
263 return target; |
|
363
d9dfa9fe9cec
Decode escape sequences in changeset extras field
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
360
diff
changeset
|
264 } |
|
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
265 } |
|
673
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
266 |
|
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
267 private static class RawCsetCollector implements Inspector { |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
268 final ArrayList<RawChangeset> result; |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
269 |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
270 public RawCsetCollector(int count) { |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
271 result = new ArrayList<RawChangeset>(count > 0 ? count : 5); |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
272 } |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
273 |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
274 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) { |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
275 result.add(cset.clone()); |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
276 } |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
277 } |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
278 |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
279 private static final class RawCsetParser implements RevlogStream.Inspector, Adaptable, Lifecycle { |
|
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
280 |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
281 private final Inspector inspector; |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
282 private final ChangesetParser csetBuilder; |
|
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:
427
diff
changeset
|
283 // non-null when inspector uses high-level lifecycle entities (progress and/or cancel supports) |
|
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
284 private final LifecycleBridge lifecycleStub; |
|
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
285 // non-null when inspector relies on low-level lifecycle and is responsible |
|
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
286 // to proceed any possible high-level entities himself. |
|
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
287 private final Lifecycle inspectorLifecycle; |
|
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
288 |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
289 public RawCsetParser(SessionContext.Source sessionContext, HgChangelog.Inspector delegate) { |
|
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
290 assert delegate != null; |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
291 inspector = delegate; |
|
673
545b1d4cc11d
Refactor HgBundle.GroupElement (clear experimental mark), resolve few technical debt issues
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
667
diff
changeset
|
292 csetBuilder = new ChangesetParser(sessionContext, new RawCsetFactory(true)); |
|
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:
427
diff
changeset
|
293 inspectorLifecycle = Adaptable.Factory.getAdapter(delegate, 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:
427
diff
changeset
|
294 if (inspectorLifecycle == 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:
427
diff
changeset
|
295 ProgressSupport ph = Adaptable.Factory.getAdapter(delegate, ProgressSupport.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:
427
diff
changeset
|
296 CancelSupport cs = Adaptable.Factory.getAdapter(delegate, CancelSupport.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:
427
diff
changeset
|
297 if (cs != null || ph != 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:
427
diff
changeset
|
298 lifecycleStub = new LifecycleBridge(ph, cs); |
|
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
299 } else { |
|
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
300 lifecycleStub = 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:
427
diff
changeset
|
301 } |
|
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
302 } else { |
|
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
303 lifecycleStub = 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:
427
diff
changeset
|
304 } |
|
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
305 } |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
306 |
|
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
600
diff
changeset
|
307 public void next(int revisionNumber, int actualLen, int baseRevision, int linkRevision, int parent1Revision, int parent2Revision, byte[] nodeid, DataAccess da) throws HgRuntimeException { |
|
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
308 try { |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
309 RawChangeset cset = csetBuilder.parse(da); |
|
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
310 // XXX there's no guarantee for Changeset.Callback that distinct instance comes each time, consider instance reuse |
|
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
311 inspector.next(revisionNumber, Nodeid.fromBinary(nodeid, 0), cset); |
|
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:
427
diff
changeset
|
312 if (lifecycleStub != 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:
427
diff
changeset
|
313 lifecycleStub.nextStep(); |
|
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
314 } |
|
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
426
diff
changeset
|
315 } catch (HgInvalidDataFormatException ex) { |
|
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
426
diff
changeset
|
316 throw ex.setRevisionIndex(revisionNumber); |
|
366
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
365
diff
changeset
|
317 } 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:
419
diff
changeset
|
318 // XXX need better exception, perhaps smth like HgChangelogException (extends 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:
419
diff
changeset
|
319 throw new HgInvalidControlFileException("Failed reading changelog", ex, null).setRevisionIndex(revisionNumber); |
|
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
320 } |
|
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:
427
diff
changeset
|
321 } |
|
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
322 |
|
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
323 public <T> T getAdapter(Class<T> adapterClass) { |
|
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
324 if (adapterClass == Lifecycle.class) { |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
325 return adapterClass.cast(this); |
|
312
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
252
diff
changeset
|
326 } |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
327 // XXX what if caller takes Progress/Cancel (which we update through lifecycleStub, too) |
|
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:
427
diff
changeset
|
328 return Adaptable.Factory.getAdapter(inspector, adapterClass, null); |
|
312
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
252
diff
changeset
|
329 } |
|
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
252
diff
changeset
|
330 |
|
667
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
331 public void start(int count, Callback callback, Object token) { |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
332 if (inspectorLifecycle != null) { |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
333 inspectorLifecycle.start(count, callback, token); |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
334 } else if (lifecycleStub != null) { |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
335 lifecycleStub.start(count, callback, token); |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
336 } |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
337 } |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
338 |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
339 public void finish(Object token) { |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
340 if (inspectorLifecycle != null) { |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
341 inspectorLifecycle.finish(token); |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
342 } else if (lifecycleStub != null) { |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
343 lifecycleStub.finish(token); |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
344 } |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
345 csetBuilder.dispose(); |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
346 } |
|
fba85bc1dfb8
Refactoring: move all encoding/decoding operations into single place, EncodingHelper
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
656
diff
changeset
|
347 |
|
196
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
182
diff
changeset
|
348 } |
|
0
dbd663faec1f
Basic changelog parsing
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
349 } |
