Mercurial > jhg
annotate src/org/tmatesoft/hg/repo/HgChangelog.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 | a937e63b6e02 | 
| rev | line source | 
|---|---|
| 21 
e929cecae4e1
Refactor to move revlog content to base class
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
3diff
changeset | 1 /* | 
| 589 
c18095eedde0
Username in changeset uses UTF-8, not system encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
520diff
changeset | 2 * Copyright (c) 2010-2013 TMate Software Ltd | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
48diff
changeset | 3 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
48diff
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: 
48diff
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: 
48diff
changeset | 6 * the Free Software Foundation; version 2 of the License. | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
48diff
changeset | 7 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
48diff
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: 
48diff
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: 
48diff
changeset | 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
48diff
changeset | 11 * GNU General Public License for more details. | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
48diff
changeset | 12 * | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
48diff
changeset | 13 * For information on how to redistribute this software under | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
48diff
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: 
97diff
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: 
48diff
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; | 
| 129 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 20 import java.io.UnsupportedEncodingException; | 
| 2 
08db726a0fb7
Shaping out low-level Hg structures
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
0diff
changeset | 21 import java.util.ArrayList; | 
| 3 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
2diff
changeset | 22 import java.util.Arrays; | 
| 146 
8c9f729f4dfa
Timezone finally in use
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
137diff
changeset | 23 import java.util.Calendar; | 
| 129 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 24 import java.util.Collections; | 
| 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 25 import java.util.Date; | 
| 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 26 import java.util.Formatter; | 
| 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 27 import java.util.HashMap; | 
| 2 
08db726a0fb7
Shaping out low-level Hg structures
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
0diff
changeset | 28 import java.util.List; | 
| 129 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 29 import java.util.Locale; | 
| 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 30 import java.util.Map; | 
| 146 
8c9f729f4dfa
Timezone finally in use
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
137diff
changeset | 31 import java.util.TimeZone; | 
| 2 
08db726a0fb7
Shaping out low-level Hg structures
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
0diff
changeset | 32 | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
48diff
changeset | 33 import org.tmatesoft.hg.core.Nodeid; | 
| 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: 
419diff
changeset | 34 import org.tmatesoft.hg.internal.Callback; | 
| 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 | 35 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: 
252diff
changeset | 36 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: 
427diff
changeset | 37 import org.tmatesoft.hg.internal.LifecycleBridge; | 
| 196 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 38 import org.tmatesoft.hg.internal.Pool; | 
| 77 
c677e1593919
Moved RevlogStream implementation into .internal
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
74diff
changeset | 39 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: 
427diff
changeset | 40 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: 
252diff
changeset | 41 import org.tmatesoft.hg.util.CancelSupport; | 
| 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
252diff
changeset | 42 import org.tmatesoft.hg.util.ProgressSupport; | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
48diff
changeset | 43 | 
| 0 
dbd663faec1f
Basic changelog parsing
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 44 /** | 
| 
dbd663faec1f
Basic changelog parsing
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 45 * Representation of the Mercurial changelog file (list of ChangeSets) | 
| 153 | 46 * | 
| 74 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
48diff
changeset | 47 * @author Artem Tikhomirov | 
| 
6f1b88693d48
Complete refactoring to org.tmatesoft
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
48diff
changeset | 48 * @author TMate Software Ltd. | 
| 0 
dbd663faec1f
Basic changelog parsing
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 49 */ | 
| 426 
063b0663495a
HgManifest#getFileRevisions refactored into #walkFileRevisions to match pattern throught rest of the library
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
424diff
changeset | 50 public final class HgChangelog extends Revlog { | 
| 0 
dbd663faec1f
Basic changelog parsing
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 51 | 
| 153 | 52 /* 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: 
589diff
changeset | 53 super(hgRepo, content, true); | 
| 2 
08db726a0fb7
Shaping out low-level Hg structures
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
0diff
changeset | 54 } | 
| 
08db726a0fb7
Shaping out low-level Hg structures
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
0diff
changeset | 55 | 
| 628 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 56 /** | 
| 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 57 * Iterate over whole changelog | 
| 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 58 * @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: 
600diff
changeset | 59 * @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: 
600diff
changeset | 60 * @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: 
600diff
changeset | 61 */ | 
| 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 62 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: 
135diff
changeset | 63 range(0, getLastRevision(), inspector); | 
| 48 
e34f90b9ded1
Limit option for history/log
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
47diff
changeset | 64 } | 
| 
e34f90b9ded1
Limit option for history/log
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
47diff
changeset | 65 | 
| 628 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 66 /** | 
| 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 67 * Iterate over changelog part | 
| 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 68 * @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: 
600diff
changeset | 69 * @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: 
600diff
changeset | 70 * @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: 
600diff
changeset | 71 * @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: 
600diff
changeset | 72 * @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: 
600diff
changeset | 73 * @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: 
600diff
changeset | 74 */ | 
| 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 75 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: 
182diff
changeset | 76 if (inspector == null) { | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 77 throw new IllegalArgumentException(); | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 78 } | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 79 content.iterate(start, end, true, new RawCsetParser(inspector)); | 
| 2 
08db726a0fb7
Shaping out low-level Hg structures
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
0diff
changeset | 80 } | 
| 
08db726a0fb7
Shaping out low-level Hg structures
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
0diff
changeset | 81 | 
| 628 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 82 /** | 
| 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 83 * @see #range(int, int, Inspector) | 
| 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 84 * @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: 
600diff
changeset | 85 * @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: 
600diff
changeset | 86 * @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: 
600diff
changeset | 87 * @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: 
600diff
changeset | 88 */ | 
| 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 89 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: 
182diff
changeset | 90 final RawCsetCollector c = new RawCsetCollector(end - start + 1); | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 91 range(start, end, c); | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 92 return c.result; | 
| 2 
08db726a0fb7
Shaping out low-level Hg structures
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
0diff
changeset | 93 } | 
| 3 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
2diff
changeset | 94 | 
| 242 
ad6a046943be
Improved reading of sparse revisions from a revlog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
236diff
changeset | 95 /** | 
| 
ad6a046943be
Improved reading of sparse revisions from a revlog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
236diff
changeset | 96 * 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: 
236diff
changeset | 97 * 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: 
236diff
changeset | 98 * @param inspector callback to get changesets | 
| 
ad6a046943be
Improved reading of sparse revisions from a revlog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
236diff
changeset | 99 * @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: 
600diff
changeset | 100 * @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: 
600diff
changeset | 101 * @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: 
600diff
changeset | 102 * @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: 
236diff
changeset | 103 */ | 
| 628 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 104 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: 
236diff
changeset | 105 Arrays.sort(revisions); | 
| 
ad6a046943be
Improved reading of sparse revisions from a revlog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
236diff
changeset | 106 rangeInternal(inspector, revisions); | 
| 
ad6a046943be
Improved reading of sparse revisions from a revlog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
236diff
changeset | 107 } | 
| 
ad6a046943be
Improved reading of sparse revisions from a revlog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
236diff
changeset | 108 | 
| 
ad6a046943be
Improved reading of sparse revisions from a revlog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
236diff
changeset | 109 /** | 
| 
ad6a046943be
Improved reading of sparse revisions from a revlog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
236diff
changeset | 110 * 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: 
236diff
changeset | 111 */ | 
| 628 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 112 /*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: 
236diff
changeset | 113 if (sortedRevisions == null || sortedRevisions.length == 0) { | 
| 3 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
2diff
changeset | 114 return; | 
| 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
2diff
changeset | 115 } | 
| 242 
ad6a046943be
Improved reading of sparse revisions from a revlog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
236diff
changeset | 116 if (inspector == null) { | 
| 
ad6a046943be
Improved reading of sparse revisions from a revlog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
236diff
changeset | 117 throw new IllegalArgumentException(); | 
| 
ad6a046943be
Improved reading of sparse revisions from a revlog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
236diff
changeset | 118 } | 
| 
ad6a046943be
Improved reading of sparse revisions from a revlog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
236diff
changeset | 119 content.iterate(sortedRevisions, true, new RawCsetParser(inspector)); | 
| 3 
24bb4f365164
Rudimentary log functionality with basic infrastructure is in place
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
2diff
changeset | 120 } | 
| 354 
5f9073eabf06
Propagate errors with exceptions up to a end client
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
329diff
changeset | 121 | 
| 
5f9073eabf06
Propagate errors with exceptions up to a end client
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
329diff
changeset | 122 /** | 
| 628 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 123 * Get changeset entry object | 
| 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 124 * @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: 
600diff
changeset | 125 * @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: 
600diff
changeset | 126 * @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: 
329diff
changeset | 127 */ | 
| 628 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 128 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: 
366diff
changeset | 129 int x = getRevisionIndex(nid); | 
| 236 
883300108179
Speed up branches calculation when cached branch information is available
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
211diff
changeset | 130 return range(x, x).get(0); | 
| 
883300108179
Speed up branches calculation when cached branch information is available
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
211diff
changeset | 131 } | 
| 129 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 132 | 
| 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: 
419diff
changeset | 133 @Callback | 
| 129 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 134 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: 
419diff
changeset | 135 /** | 
| 
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: 
419diff
changeset | 136 * 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: 
419diff
changeset | 137 * 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: 
419diff
changeset | 138 * | 
| 
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: 
419diff
changeset | 139 * @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: 
419diff
changeset | 140 * @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: 
419diff
changeset | 141 * @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: 
419diff
changeset | 142 */ | 
| 628 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 143 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: 
102diff
changeset | 144 } | 
| 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 145 | 
| 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 146 /** | 
| 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 147 * Entry in the Changelog | 
| 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 148 */ | 
| 154 
ba2bf656f00f
Changeset => RawChangeset
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
153diff
changeset | 149 public static class RawChangeset implements Cloneable /* for those that would like to keep a copy */{ | 
| 129 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 150 // TODO immutable | 
| 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 151 private/* final */Nodeid manifest; | 
| 153 | 152 private String user; | 
| 153 private String comment; | |
| 154 private List<String> files; // unmodifiable collection (otherwise #files() and implicit #clone() shall be revised) | |
| 155 private Date time; | |
| 156 private int timezone; | |
| 161 
9423235ca77b
Record possible value (and knowledge source) for extras field
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
157diff
changeset | 157 // http://mercurial.selenic.com/wiki/PruningDeadBranches - Closing changesets can be identified by close=1 in the changeset's extra field. | 
| 153 | 158 private Map<String, String> extras; | 
| 129 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 159 | 
| 153 | 160 /** | 
| 161 * @see mercurial/changelog.py:read() | |
| 162 * | |
| 163 * <pre> | |
| 164 * format used: | |
| 165 * nodeid\n : manifest node in ascii | |
| 166 * user\n : user, no \n or \r allowed | |
| 167 * time tz extra\n : date (time is int or float, timezone is int) | |
| 168 * : extra is metadatas, encoded and separated by '\0' | |
| 169 * : older versions ignore it | |
| 170 * files\n\n : files modified by the cset, no \n or \r allowed | |
| 171 * (.*) : comment (free text, ideally utf-8) | |
| 172 * | |
| 173 * changelog v0 doesn't use extra | |
| 174 * </pre> | |
| 175 */ | |
| 154 
ba2bf656f00f
Changeset => RawChangeset
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
153diff
changeset | 176 private RawChangeset() { | 
| 153 | 177 } | 
| 129 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 178 | 
| 153 | 179 public Nodeid manifest() { | 
| 180 return manifest; | |
| 181 } | |
| 129 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 182 | 
| 153 | 183 public String user() { | 
| 184 return user; | |
| 185 } | |
| 186 | |
| 187 public String comment() { | |
| 188 return comment; | |
| 189 } | |
| 190 | |
| 191 public List<String> files() { | |
| 192 return files; | |
| 193 } | |
| 194 | |
| 195 public Date date() { | |
| 196 return time; | |
| 197 } | |
| 211 
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
196diff
changeset | 198 | 
| 
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
196diff
changeset | 199 /** | 
| 
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
196diff
changeset | 200 * @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: 
196diff
changeset | 201 */ | 
| 
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
196diff
changeset | 202 public int timezone() { | 
| 
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
196diff
changeset | 203 return timezone; | 
| 
644ee58c9f16
Compound HgDate object to provide flexible access to change date/time information
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
196diff
changeset | 204 } | 
| 153 | 205 | 
| 206 public String dateString() { | |
| 207 // XXX keep once formatted? Perhaps, there's faster way to set up calendar/time zone? | |
| 208 StringBuilder sb = new StringBuilder(30); | |
| 209 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: 
196diff
changeset | 210 TimeZone tz = TimeZone.getTimeZone(TimeZone.getAvailableIDs(timezone * 1000)[0]); | 
| 153 | 211 // apparently timezone field records number of seconds time differs from UTC, | 
| 212 // i.e. value to substract from time to get UTC time. Calendar seems to add | |
| 213 // 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: 
196diff
changeset | 214 // tz.setRawOffset(timezone * -1000); | 
| 153 | 215 Calendar c = Calendar.getInstance(tz, Locale.US); | 
| 216 c.setTime(time); | |
| 217 f.format("%ta %<tb %<td %<tH:%<tM:%<tS %<tY %<tz", c); | |
| 218 return sb.toString(); | |
| 219 } | |
| 220 | |
| 221 public Map<String, String> extras() { | |
| 222 return extras; | |
| 223 } | |
| 224 | |
| 225 public String branch() { | |
| 226 return extras.get("branch"); | |
| 227 } | |
| 228 | |
| 229 @Override | |
| 230 public String toString() { | |
| 231 StringBuilder sb = new StringBuilder(); | |
| 232 sb.append("Changeset {"); | |
| 233 sb.append("User: ").append(user).append(", "); | |
| 234 sb.append("Comment: ").append(comment).append(", "); | |
| 235 sb.append("Manifest: ").append(manifest).append(", "); | |
| 236 sb.append("Date: ").append(time).append(", "); | |
| 237 sb.append("Files: ").append(files.size()); | |
| 238 for (String s : files) { | |
| 239 sb.append(", ").append(s); | |
| 240 } | |
| 241 if (extras != null) { | |
| 242 sb.append(", Extra: ").append(extras); | |
| 243 } | |
| 244 sb.append("}"); | |
| 245 return sb.toString(); | |
| 246 } | |
| 247 | |
| 248 @Override | |
| 154 
ba2bf656f00f
Changeset => RawChangeset
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
153diff
changeset | 249 public RawChangeset clone() { | 
| 153 | 250 try { | 
| 154 
ba2bf656f00f
Changeset => RawChangeset
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
153diff
changeset | 251 return (RawChangeset) super.clone(); | 
| 153 | 252 } catch (CloneNotSupportedException ex) { | 
| 253 throw new InternalError(ex.toString()); | |
| 254 } | |
| 255 } | |
| 256 | |
| 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: 
426diff
changeset | 257 /*package*/ static RawChangeset parse(DataAccess da) throws IOException, HgInvalidDataFormatException { | 
| 365 
3572fcb06473
Don't expose methods with DataAccess in public API
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
363diff
changeset | 258 byte[] data = da.byteArray(); | 
| 
3572fcb06473
Don't expose methods with DataAccess in public API
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
363diff
changeset | 259 RawChangeset rv = new RawChangeset(); | 
| 
3572fcb06473
Don't expose methods with DataAccess in public API
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
363diff
changeset | 260 rv.init(data, 0, data.length, null); | 
| 
3572fcb06473
Don't expose methods with DataAccess in public API
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
363diff
changeset | 261 return rv; | 
| 153 | 262 } | 
| 263 | |
| 196 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 264 // @param usersPool - it's likely user names get repeated again and again throughout repository. can be null | 
| 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: 
426diff
changeset | 265 /* package-local */void init(byte[] data, int offset, int length, Pool<String> usersPool) throws HgInvalidDataFormatException { | 
| 153 | 266 final int bufferEndIndex = offset + length; | 
| 267 final byte lineBreak = (byte) '\n'; | |
| 268 int breakIndex1 = indexOf(data, lineBreak, offset, bufferEndIndex); | |
| 269 if (breakIndex1 == -1) { | |
| 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: 
426diff
changeset | 270 throw new HgInvalidDataFormatException("Bad Changeset data"); | 
| 153 | 271 } | 
| 272 Nodeid _nodeid = Nodeid.fromAscii(data, 0, breakIndex1); | |
| 273 int breakIndex2 = indexOf(data, lineBreak, breakIndex1 + 1, bufferEndIndex); | |
| 274 if (breakIndex2 == -1) { | |
| 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: 
426diff
changeset | 275 throw new HgInvalidDataFormatException("Bad Changeset data"); | 
| 153 | 276 } | 
| 589 
c18095eedde0
Username in changeset uses UTF-8, not system encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
520diff
changeset | 277 String _user; | 
| 
c18095eedde0
Username in changeset uses UTF-8, not system encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
520diff
changeset | 278 try { | 
| 
c18095eedde0
Username in changeset uses UTF-8, not system encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
520diff
changeset | 279 // TODO use encoding helper? Although where encoding is fixed (like here), seems to be just too much | 
| 
c18095eedde0
Username in changeset uses UTF-8, not system encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
520diff
changeset | 280 _user = new String(data, breakIndex1 + 1, breakIndex2 - breakIndex1 - 1, "UTF-8"); | 
| 
c18095eedde0
Username in changeset uses UTF-8, not system encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
520diff
changeset | 281 if (usersPool != null) { | 
| 
c18095eedde0
Username in changeset uses UTF-8, not system encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
520diff
changeset | 282 _user = usersPool.unify(_user); | 
| 
c18095eedde0
Username in changeset uses UTF-8, not system encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
520diff
changeset | 283 } | 
| 
c18095eedde0
Username in changeset uses UTF-8, not system encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
520diff
changeset | 284 } catch (UnsupportedEncodingException ex) { | 
| 
c18095eedde0
Username in changeset uses UTF-8, not system encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
520diff
changeset | 285 _user = ""; | 
| 
c18095eedde0
Username in changeset uses UTF-8, not system encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
520diff
changeset | 286 // Could hardly happen | 
| 
c18095eedde0
Username in changeset uses UTF-8, not system encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
520diff
changeset | 287 throw new HgInvalidDataFormatException("Bad Changeset data", ex); | 
| 196 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 288 } | 
| 589 
c18095eedde0
Username in changeset uses UTF-8, not system encoding
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
520diff
changeset | 289 | 
| 153 | 290 int breakIndex3 = indexOf(data, lineBreak, breakIndex2 + 1, bufferEndIndex); | 
| 291 if (breakIndex3 == -1) { | |
| 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: 
426diff
changeset | 292 throw new HgInvalidDataFormatException("Bad Changeset data"); | 
| 153 | 293 } | 
| 294 String _timeString = new String(data, breakIndex2 + 1, breakIndex3 - breakIndex2 - 1); | |
| 295 int space1 = _timeString.indexOf(' '); | |
| 296 if (space1 == -1) { | |
| 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: 
426diff
changeset | 297 throw new HgInvalidDataFormatException(String.format("Bad Changeset data: %s in [%d..%d]", "time string", breakIndex2+1, breakIndex3)); | 
| 153 | 298 } | 
| 299 int space2 = _timeString.indexOf(' ', space1 + 1); | |
| 300 if (space2 == -1) { | |
| 301 space2 = _timeString.length(); | |
| 302 } | |
| 363 
d9dfa9fe9cec
Decode escape sequences in changeset extras field
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 303 long unixTime = Long.parseLong(_timeString.substring(0, space1)); | 
| 153 | 304 int _timezone = Integer.parseInt(_timeString.substring(space1 + 1, space2)); | 
| 363 
d9dfa9fe9cec
Decode escape sequences in changeset extras field
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 305 // unixTime is local time, and timezone records difference of the local time to UTC. | 
| 153 | 306 Date _time = new Date(unixTime * 1000); | 
| 307 String _extras = space2 < _timeString.length() ? _timeString.substring(space2 + 1) : null; | |
| 308 Map<String, String> _extrasMap; | |
| 252 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
242diff
changeset | 309 final String extras_branch_key = "branch"; | 
| 386 
73e875154afb
Do not fail with empty extras string in changeset
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
367diff
changeset | 310 if (_extras == null || _extras.trim().length() == 0) { | 
| 252 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
242diff
changeset | 311 _extrasMap = Collections.singletonMap(extras_branch_key, HgRepository.DEFAULT_BRANCH_NAME); | 
| 153 | 312 } else { | 
| 313 _extrasMap = new HashMap<String, String>(); | |
| 314 for (String pair : _extras.split("\00")) { | |
| 363 
d9dfa9fe9cec
Decode escape sequences in changeset extras field
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 315 pair = decode(pair); | 
| 153 | 316 int eq = pair.indexOf(':'); | 
| 317 _extrasMap.put(pair.substring(0, eq), pair.substring(eq + 1)); | |
| 318 } | |
| 252 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
242diff
changeset | 319 if (!_extrasMap.containsKey(extras_branch_key)) { | 
| 
a6d19adc2636
HgRepository.getWorkingCopyBranchName() to retrieve branch associated with working directory
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
242diff
changeset | 320 _extrasMap.put(extras_branch_key, HgRepository.DEFAULT_BRANCH_NAME); | 
| 153 | 321 } | 
| 322 _extrasMap = Collections.unmodifiableMap(_extrasMap); | |
| 323 } | |
| 324 | |
| 325 // | |
| 326 int lastStart = breakIndex3 + 1; | |
| 327 int breakIndex4 = indexOf(data, lineBreak, lastStart, bufferEndIndex); | |
| 328 ArrayList<String> _files = null; | |
| 329 if (breakIndex4 > lastStart) { | |
| 330 // if breakIndex4 == lastStart, we already found \n\n and hence there are no files (e.g. merge revision) | |
| 331 _files = new ArrayList<String>(5); | |
| 332 while (breakIndex4 != -1 && breakIndex4 + 1 < bufferEndIndex) { | |
| 333 _files.add(new String(data, lastStart, breakIndex4 - lastStart)); | |
| 334 lastStart = breakIndex4 + 1; | |
| 335 if (data[breakIndex4 + 1] == lineBreak) { | |
| 336 // found \n\n | |
| 337 break; | |
| 338 } else { | |
| 339 breakIndex4 = indexOf(data, lineBreak, lastStart, bufferEndIndex); | |
| 129 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 340 } | 
| 153 | 341 } | 
| 342 if (breakIndex4 == -1 || breakIndex4 >= bufferEndIndex) { | |
| 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: 
426diff
changeset | 343 throw new HgInvalidDataFormatException("Bad Changeset data"); | 
| 153 | 344 } | 
| 345 } else { | |
| 346 breakIndex4--; | |
| 347 } | |
| 348 String _comment; | |
| 349 try { | |
| 350 _comment = new String(data, breakIndex4 + 2, bufferEndIndex - breakIndex4 - 2, "UTF-8"); | |
| 418 
528b6780a8bd
A bit of FIXME cleanup (mostly degraded to TODO post 1.0), comments and javadoc
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
386diff
changeset | 351 // TODO post-1.0 respect ui.fallbackencoding and try to decode if set; use EncodingHelper | 
| 153 | 352 } catch (UnsupportedEncodingException ex) { | 
| 353 _comment = ""; | |
| 366 
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
365diff
changeset | 354 // Could hardly happen | 
| 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: 
426diff
changeset | 355 throw new HgInvalidDataFormatException("Bad Changeset data", ex); | 
| 153 | 356 } | 
| 357 // change this instance at once, don't leave it partially changes in case of error | |
| 358 this.manifest = _nodeid; | |
| 359 this.user = _user; | |
| 360 this.time = _time; | |
| 361 this.timezone = _timezone; | |
| 362 this.files = _files == null ? Collections.<String> emptyList() : Collections.unmodifiableList(_files); | |
| 363 this.comment = _comment; | |
| 364 this.extras = _extrasMap; | |
| 365 } | |
| 129 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 366 | 
| 153 | 367 private static int indexOf(byte[] src, byte what, int startOffset, int endIndex) { | 
| 368 for (int i = startOffset; i < endIndex; i++) { | |
| 369 if (src[i] == what) { | |
| 370 return i; | |
| 371 } | |
| 372 } | |
| 373 return -1; | |
| 374 } | |
| 363 
d9dfa9fe9cec
Decode escape sequences in changeset extras field
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 375 | 
| 
d9dfa9fe9cec
Decode escape sequences in changeset extras field
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 376 private static String decode(String s) { | 
| 
d9dfa9fe9cec
Decode escape sequences in changeset extras field
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 377 if (s != null && s.indexOf('\\') != -1) { | 
| 
d9dfa9fe9cec
Decode escape sequences in changeset extras field
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 378 // TestAuxUtilities#testChangelogExtrasDecode | 
| 
d9dfa9fe9cec
Decode escape sequences in changeset extras field
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 379 return s.replace("\\\\", "\\").replace("\\n", "\n").replace("\\r", "\r").replace("\\0", "\00"); | 
| 
d9dfa9fe9cec
Decode escape sequences in changeset extras field
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 380 } | 
| 
d9dfa9fe9cec
Decode escape sequences in changeset extras field
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 381 return s; | 
| 
d9dfa9fe9cec
Decode escape sequences in changeset extras field
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
360diff
changeset | 382 } | 
| 129 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 383 } | 
| 
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
102diff
changeset | 384 | 
| 196 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 385 private static class RawCsetCollector implements Inspector { | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 386 final ArrayList<RawChangeset> result; | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 387 | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 388 public RawCsetCollector(int count) { | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 389 result = new ArrayList<RawChangeset>(count > 0 ? count : 5); | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 390 } | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 391 | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 392 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: 
182diff
changeset | 393 result.add(cset.clone()); | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 394 } | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 395 } | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 396 | 
| 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: 
427diff
changeset | 397 private static class RawCsetParser implements RevlogStream.Inspector, Adaptable { | 
| 196 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 398 | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 399 private final Inspector inspector; | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 400 private final Pool<String> usersPool; | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 401 private final RawChangeset cset = new RawChangeset(); | 
| 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: 
427diff
changeset | 402 // 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: 
427diff
changeset | 403 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: 
427diff
changeset | 404 // 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: 
427diff
changeset | 405 // 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: 
427diff
changeset | 406 private final Lifecycle inspectorLifecycle; | 
| 196 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 407 | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 408 public RawCsetParser(HgChangelog.Inspector delegate) { | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 409 assert delegate != null; | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 410 inspector = delegate; | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 411 usersPool = new Pool<String>(); | 
| 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: 
427diff
changeset | 412 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: 
427diff
changeset | 413 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: 
427diff
changeset | 414 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: 
427diff
changeset | 415 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: 
427diff
changeset | 416 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: 
427diff
changeset | 417 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: 
427diff
changeset | 418 } 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: 
427diff
changeset | 419 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: 
427diff
changeset | 420 } | 
| 
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
427diff
changeset | 421 } 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: 
427diff
changeset | 422 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: 
427diff
changeset | 423 } | 
| 196 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 424 } | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 425 | 
| 628 
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
600diff
changeset | 426 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: 
182diff
changeset | 427 try { | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 428 byte[] data = da.byteArray(); | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 429 cset.init(data, 0, data.length, usersPool); | 
| 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 430 // 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: 
182diff
changeset | 431 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: 
427diff
changeset | 432 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: 
427diff
changeset | 433 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: 
427diff
changeset | 434 } | 
| 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: 
426diff
changeset | 435 } 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: 
426diff
changeset | 436 throw ex.setRevisionIndex(revisionNumber); | 
| 366 
189dc6dc1c3e
Use exceptions to expose errors reading mercurial data
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
365diff
changeset | 437 } 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: 
419diff
changeset | 438 // 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: 
419diff
changeset | 439 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: 
182diff
changeset | 440 } | 
| 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: 
427diff
changeset | 441 } | 
| 
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
427diff
changeset | 442 | 
| 
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
427diff
changeset | 443 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: 
427diff
changeset | 444 if (adapterClass == Lifecycle.class) { | 
| 
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
427diff
changeset | 445 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: 
427diff
changeset | 446 return adapterClass.cast(inspectorLifecycle); | 
| 
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
427diff
changeset | 447 } | 
| 
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
427diff
changeset | 448 // reveal interest in lifecycle only when either progress or cancel support is there | 
| 
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
427diff
changeset | 449 // and inspector itself doesn't respond to lifecycle request | 
| 
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
427diff
changeset | 450 // lifecycleStub may still be null here (no progress and cancel), it's ok to cast(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: 
427diff
changeset | 451 return adapterClass.cast(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: 
427diff
changeset | 452 | 
| 312 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
252diff
changeset | 453 } | 
| 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: 
427diff
changeset | 454 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: 
252diff
changeset | 455 } | 
| 
f9f3e9b67ccc
Facilitate cancellation and progress reporting in changelog and manifest iterations
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
252diff
changeset | 456 | 
| 196 
e2115da4cf6a
Pool objects to avoid memory polution with duplicates
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: 
182diff
changeset | 457 } | 
| 0 
dbd663faec1f
Basic changelog parsing
 Artem Tikhomirov <tikhomirov.artem@gmail.com> parents: diff
changeset | 458 } | 
