annotate src/org/tmatesoft/hg/core/HgLogCommand.java @ 415:ee8264d80747

Explicit constant for regular file flags, access to flags for a given file revision
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 22 Mar 2012 18:54:11 +0100
parents 2747b0723867
children 528b6780a8bd
rev   line source
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
396
0ae53c32ecef Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 383
diff changeset
2 * Copyright (c) 2011-2012 TMate Software Ltd
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 *
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
7 *
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
11 * GNU General Public License for more details.
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 *
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 * For information on how to redistribute this software under
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
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: 94
diff changeset
15 * contact TMate Software at support@hg4j.com
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 package org.tmatesoft.hg.core;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 70
diff changeset
19 import static org.tmatesoft.hg.repo.HgRepository.TIP;
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
20
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
21 import java.util.ArrayList;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
22 import java.util.Arrays;
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
23 import java.util.Calendar;
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
24 import java.util.Collection;
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
25 import java.util.Collections;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
26 import java.util.ConcurrentModificationException;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27 import java.util.LinkedList;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
28 import java.util.List;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29 import java.util.Set;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
30 import java.util.TreeSet;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
31
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
32 import org.tmatesoft.hg.internal.IntMap;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
33 import org.tmatesoft.hg.internal.IntVector;
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
34 import org.tmatesoft.hg.repo.HgChangelog;
154
ba2bf656f00f Changeset => RawChangeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 148
diff changeset
35 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
36 import org.tmatesoft.hg.repo.HgDataFile;
354
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 328
diff changeset
37 import org.tmatesoft.hg.repo.HgInternals;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 70
diff changeset
38 import org.tmatesoft.hg.repo.HgRepository;
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
39 import org.tmatesoft.hg.repo.HgStatusCollector;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
40 import org.tmatesoft.hg.util.CancelSupport;
157
d5268ca7715b Merged branch wrap-data-access into default for resource-friendly data access. Updated API to promote that friendliness to clients (channels, not byte[]). More exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 154
diff changeset
41 import org.tmatesoft.hg.util.CancelledException;
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
42 import org.tmatesoft.hg.util.Pair;
133
4a948ec83980 core.Path to util.Path as it's not Hg repo dependant
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 131
diff changeset
43 import org.tmatesoft.hg.util.Path;
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
44 import org.tmatesoft.hg.util.ProgressSupport;
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
46
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
47 /**
131
aa1629f36482 Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 129
diff changeset
48 * Access to changelog, 'hg log' command counterpart.
aa1629f36482 Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 129
diff changeset
49 *
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
50 * <pre>
131
aa1629f36482 Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 129
diff changeset
51 * Usage:
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 64
diff changeset
52 * new LogCommand().limit(20).branch("maintenance-2.1").user("me").execute(new MyHandler());
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
53 * </pre>
131
aa1629f36482 Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 129
diff changeset
54 * Not thread-safe (each thread has to use own {@link HgLogCommand} instance).
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
55 *
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
56 * @author Artem Tikhomirov
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
57 * @author TMate Software Ltd.
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
58 */
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
59 public class HgLogCommand extends HgAbstractCommand<HgLogCommand> implements HgChangelog.Inspector {
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
60
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
61 private final HgRepository repo;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
62 private Set<String> users;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
63 private Set<String> branches;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
64 private int limit = 0, count = 0;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
65 private int startRev = 0, endRev = TIP;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
66 private Calendar date;
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
67 private Path file;
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
68 private boolean followHistory; // makes sense only when file != null
193
37f3d4a596e4 Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 157
diff changeset
69 private ChangesetTransformer csetTransform;
195
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 193
diff changeset
70 private HgChangelog.ParentWalker parentHelper;
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
71
131
aa1629f36482 Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 129
diff changeset
72 public HgLogCommand(HgRepository hgRepo) {
107
7ec89d637f50 CatCommand
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
73 repo = hgRepo;
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
74 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
75
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
76 /**
148
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 142
diff changeset
77 * Limit search to specified user. Multiple user names may be specified. Once set, user names can't be
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 142
diff changeset
78 * cleared, use new command instance in such cases.
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
79 * @param user - full or partial name of the user, case-insensitive, non-null.
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
80 * @return <code>this</code> instance for convenience
148
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 142
diff changeset
81 * @throws IllegalArgumentException when argument is null
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
82 */
131
aa1629f36482 Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 129
diff changeset
83 public HgLogCommand user(String user) {
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
84 if (user == null) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
85 throw new IllegalArgumentException();
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
86 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
87 if (users == null) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
88 users = new TreeSet<String>();
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
89 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
90 users.add(user.toLowerCase());
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
91 return this;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
92 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
93
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
94 /**
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
95 * Limit search to specified branch. Multiple branch specification possible (changeset from any of these
148
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 142
diff changeset
96 * would be included in result). If unspecified, all branches are considered. There's no way to clean branch selection
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 142
diff changeset
97 * once set, create fresh new command instead.
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
98 * @param branch - branch name, case-sensitive, non-null.
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
99 * @return <code>this</code> instance for convenience
148
1a7a9a20e1f9 Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 142
diff changeset
100 * @throws IllegalArgumentException when branch argument is null
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
101 */
131
aa1629f36482 Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 129
diff changeset
102 public HgLogCommand branch(String branch) {
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
103 if (branch == null) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
104 throw new IllegalArgumentException();
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
105 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
106 if (branches == null) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
107 branches = new TreeSet<String>();
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
108 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
109 branches.add(branch);
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
110 return this;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
111 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
112
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
113 // limit search to specific date
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
114 // multiple?
131
aa1629f36482 Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 129
diff changeset
115 public HgLogCommand date(Calendar date) {
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
116 this.date = date;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
117 // FIXME implement
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
118 // isSet(field) - false => don't use in detection of 'same date'
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
119 throw HgRepository.notImplemented();
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
120 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
121
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
122 /**
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
123 *
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
124 * @param num - number of changeset to produce. Pass 0 to clear the limit.
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
125 * @return <code>this</code> instance for convenience
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
126 */
131
aa1629f36482 Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 129
diff changeset
127 public HgLogCommand limit(int num) {
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
128 limit = num;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
129 return this;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
130 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
131
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
132 /**
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
133 * Limit to specified subset of Changelog, [min(rev1,rev2), max(rev1,rev2)], inclusive.
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
134 * Revision may be specified with {@link HgRepository#TIP}
368
8107b95f4280 Update Javadoc with 'revision index'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
135 * @param rev1 - revision local index
8107b95f4280 Update Javadoc with 'revision index'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
136 * @param rev2 - revision local index
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
137 * @return <code>this</code> instance for convenience
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
138 */
131
aa1629f36482 Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 129
diff changeset
139 public HgLogCommand range(int rev1, int rev2) {
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
140 if (rev1 != TIP && rev2 != TIP) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
141 startRev = rev2 < rev1 ? rev2 : rev1;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
142 endRev = startRev == rev2 ? rev1 : rev2;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
143 } else if (rev1 == TIP && rev2 != TIP) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
144 startRev = rev2;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
145 endRev = rev1;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
146 } else {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
147 startRev = rev1;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
148 endRev = rev2;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
149 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
150 return this;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
151 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
152
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
153 /**
253
1874d11054e5 HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 250
diff changeset
154 * Select specific changeset
1874d11054e5 HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 250
diff changeset
155 *
1874d11054e5 HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 250
diff changeset
156 * @param nid changeset revision
1874d11054e5 HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 250
diff changeset
157 * @return <code>this</code> for convenience
354
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 328
diff changeset
158 * @throws HgInvalidRevisionException if supplied nodeid doesn't identify any revision from this revlog
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 328
diff changeset
159 * @throws HgInvalidControlFileException if access to revlog index/data entry failed
253
1874d11054e5 HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 250
diff changeset
160 */
354
5f9073eabf06 Propagate errors with exceptions up to a end client
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 328
diff changeset
161 public HgLogCommand changeset(Nodeid nid) throws HgInvalidControlFileException, HgInvalidRevisionException {
253
1874d11054e5 HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 250
diff changeset
162 // XXX perhaps, shall support multiple (...) arguments and extend #execute to handle not only range, but also set of revisions.
368
8107b95f4280 Update Javadoc with 'revision index'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
163 final int csetRevIndex = repo.getChangelog().getRevisionIndex(nid);
8107b95f4280 Update Javadoc with 'revision index'
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 367
diff changeset
164 return range(csetRevIndex, csetRevIndex);
253
1874d11054e5 HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 250
diff changeset
165 }
1874d11054e5 HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 250
diff changeset
166
1874d11054e5 HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 250
diff changeset
167 /**
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
168 * Visit history of a given file only.
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
169 * @param file path relative to repository root. Pass <code>null</code> to reset.
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
170 * @param followCopyRename true to report changesets of the original file(-s), if copy/rename ever occured to the file.
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
171 */
131
aa1629f36482 Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 129
diff changeset
172 public HgLogCommand file(Path file, boolean followCopyRename) {
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
173 // multiple? Bad idea, would need to include extra method into Handler to tell start of next file
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
174 this.file = file;
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
175 followHistory = followCopyRename;
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
176 return this;
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
177 }
142
37a34044e6bd More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
178
37a34044e6bd More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
179 /**
37a34044e6bd More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
180 * Handy analog of {@link #file(Path, boolean)} when clients' paths come from filesystem and need conversion to repository's
37a34044e6bd More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
181 */
37a34044e6bd More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
182 public HgLogCommand file(String file, boolean followCopyRename) {
37a34044e6bd More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
183 return file(Path.create(repo.getToRepoPathHelper().rewrite(file)), followCopyRename);
37a34044e6bd More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
184 }
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
185
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
186 /**
154
ba2bf656f00f Changeset => RawChangeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 148
diff changeset
187 * Similar to {@link #execute(org.tmatesoft.hg.repo.RawChangeset.Inspector)}, collects and return result as a list.
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
188 */
396
0ae53c32ecef Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 383
diff changeset
189 public List<HgChangeset> execute() throws HgException {
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
190 CollectHandler collector = new CollectHandler();
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
191 try {
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
192 execute(collector);
396
0ae53c32ecef Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 383
diff changeset
193 } catch (CancelledException ex) {
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
194 // can't happen as long as our CollectHandler doesn't throw any exception
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
195 throw new HgBadStateException(ex);
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
196 }
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
197 return collector.getChanges();
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
198 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
199
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
200 /**
402
1fcc7f7b6d65 FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 396
diff changeset
201 * Iterate over range of changesets configured in the command.
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
202 *
205
ffc5f6d59f7e HgLogCommand.Handler is used in few places, pull up to top-level class, HgChangesetHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 195
diff changeset
203 * @param handler callback to process changesets.
380
9517df1ef7ec Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 370
diff changeset
204 * @throws HgCallbackTargetException to re-throw exception from the handler
402
1fcc7f7b6d65 FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 396
diff changeset
205 * @throws HgInvalidControlFileException if access to revlog index/data entry failed
1fcc7f7b6d65 FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 396
diff changeset
206 * @throws HgException in case of some other library issue
380
9517df1ef7ec Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 370
diff changeset
207 * @throws CancelledException if execution of the command was cancelled
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
208 * @throws IllegalArgumentException when inspector argument is null
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
209 * @throws ConcurrentModificationException if this log command instance is already running
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
210 */
370
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
211 public void execute(HgChangesetHandler handler) throws HgCallbackTargetException, HgException, CancelledException {
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
212 if (handler == null) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
213 throw new IllegalArgumentException();
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
214 }
193
37f3d4a596e4 Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 157
diff changeset
215 if (csetTransform != null) {
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
216 throw new ConcurrentModificationException();
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
217 }
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
218 final ProgressSupport progressHelper = getProgressSupport(handler);
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
219 try {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
220 count = 0;
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
221 HgChangelog.ParentWalker pw = getParentHelper(file == null); // leave it uninitialized unless we iterate whole repo
193
37f3d4a596e4 Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 157
diff changeset
222 // ChangesetTransfrom creates a blank PathPool, and #file(String, boolean) above
37f3d4a596e4 Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 157
diff changeset
223 // may utilize it as well. CommandContext? How about StatusCollector there as well?
322
d68dcb3b5f49 Propagate command's CancelSupport to low-level API. CancelSupport from context got priority over one from command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 316
diff changeset
224 csetTransform = new ChangesetTransformer(repo, handler, pw, progressHelper, getCancelSupport(handler, true));
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
225 if (file == null) {
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
226 progressHelper.start(endRev - startRev + 1);
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
227 repo.getChangelog().range(startRev, endRev, this);
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
228 csetTransform.checkFailure();
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
229 } else {
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
230 progressHelper.start(-1/*XXX enum const, or a dedicated method startUnspecified(). How about startAtLeast(int)?*/);
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
231 HgDataFile fileNode = repo.getFileNode(file);
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
232 fileNode.history(startRev, endRev, this);
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
233 csetTransform.checkFailure();
126
b92a638764be Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 107
diff changeset
234 if (fileNode.isCopy()) {
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
235 // even if we do not follow history, report file rename
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
236 do {
126
b92a638764be Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 107
diff changeset
237 if (handler instanceof FileHistoryHandler) {
415
ee8264d80747 Explicit constant for regular file flags, access to flags for a given file revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
238 HgFileRevision src = new HgFileRevision(repo, fileNode.getCopySourceRevision(), null, fileNode.getCopySourceName());
ee8264d80747 Explicit constant for regular file flags, access to flags for a given file revision
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 403
diff changeset
239 HgFileRevision dst = new HgFileRevision(repo, fileNode.getRevision(0), null, fileNode.getPath(), src.getPath());
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
240 try {
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
241 ((FileHistoryHandler) handler).copy(src, dst);
370
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
242 } catch (HgCallbackTargetException.Wrap ex) {
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
243 throw new HgCallbackTargetException(ex).setRevision(fileNode.getCopySourceRevision()).setFileName(fileNode.getCopySourceName());
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
244 }
126
b92a638764be Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 107
diff changeset
245 }
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
246 if (limit > 0 && count >= limit) {
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
247 // if limit reach, follow is useless.
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
248 break;
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
249 }
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
250 if (followHistory) {
126
b92a638764be Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 107
diff changeset
251 fileNode = repo.getFileNode(fileNode.getCopySourceName());
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
252 fileNode.history(this);
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
253 csetTransform.checkFailure();
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
254 }
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
255 } while (followHistory && fileNode.isCopy());
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
256 }
77
c677e1593919 Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
257 }
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
258 } finally {
193
37f3d4a596e4 Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 157
diff changeset
259 csetTransform = null;
215
41a778e3fd31 Issue 5: Facilities for progress and cancellation. More specific exceptions. Exceptions from callbacks as RuntimeException
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 205
diff changeset
260 progressHelper.done();
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
261 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
262 }
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
263
370
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
264 /**
402
1fcc7f7b6d65 FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 396
diff changeset
265 * Tree-wise iteration of a file history, with handy access to parent-child relations between changesets.
1fcc7f7b6d65 FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 396
diff changeset
266 *
1fcc7f7b6d65 FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 396
diff changeset
267 * @param handler callback to process changesets.
380
9517df1ef7ec Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 370
diff changeset
268 * @throws HgCallbackTargetException to re-throw exception from the handler
402
1fcc7f7b6d65 FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 396
diff changeset
269 * @throws HgInvalidControlFileException if access to revlog index/data entry failed
1fcc7f7b6d65 FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 396
diff changeset
270 * @throws HgException in case of some other library issue
380
9517df1ef7ec Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 370
diff changeset
271 * @throws CancelledException if execution of the command was cancelled
402
1fcc7f7b6d65 FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 396
diff changeset
272 * @throws IllegalArgumentException if command is not satisfied with its arguments
1fcc7f7b6d65 FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 396
diff changeset
273 * @throws ConcurrentModificationException if this log command instance is already running
370
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
274 */
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
275 public void execute(HgChangesetTreeHandler handler) throws HgCallbackTargetException, HgException, CancelledException {
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
276 if (handler == null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
277 throw new IllegalArgumentException();
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
278 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
279 if (csetTransform != null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
280 throw new ConcurrentModificationException();
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
281 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
282 if (file == null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
283 throw new IllegalArgumentException("History tree is supported for files only (at least now), please specify file");
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
284 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
285 if (followHistory) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
286 throw new UnsupportedOperationException("Can't follow file history when building tree (yet?)");
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
287 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
288 class TreeBuildInspector implements HgChangelog.ParentInspector, HgChangelog.RevisionInspector {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
289 HistoryNode[] completeHistory;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
290 int[] commitRevisions;
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
291
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
292 public void next(int revisionNumber, Nodeid revision, int linkedRevision) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
293 commitRevisions[revisionNumber] = linkedRevision;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
294 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
295
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
296 public void next(int revisionNumber, Nodeid revision, int parent1, int parent2, Nodeid nidParent1, Nodeid nidParent2) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
297 HistoryNode p1 = null, p2 = null;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
298 if (parent1 != -1) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
299 p1 = completeHistory[parent1];
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
300 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
301 if (parent2!= -1) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
302 p2 = completeHistory[parent2];
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
303 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
304 completeHistory[revisionNumber] = new HistoryNode(commitRevisions[revisionNumber], revision, p1, p2);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
305 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
306
366
189dc6dc1c3e Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
307 HistoryNode[] go(HgDataFile fileNode) throws HgInvalidControlFileException {
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
308 completeHistory = new HistoryNode[fileNode.getRevisionCount()];
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
309 commitRevisions = new int[completeHistory.length];
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
310 fileNode.walk(0, TIP, this);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
311 return completeHistory;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
312 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
313 };
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
314 final ProgressSupport progressHelper = getProgressSupport(handler);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
315 progressHelper.start(4);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
316 final CancelSupport cancelHelper = getCancelSupport(handler, true);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
317 cancelHelper.checkCancelled();
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
318 HgDataFile fileNode = repo.getFileNode(file);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
319 // build tree of nodes according to parents in file's revlog
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
320 final TreeBuildInspector treeBuildInspector = new TreeBuildInspector();
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
321 final HistoryNode[] completeHistory = treeBuildInspector.go(fileNode);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
322 progressHelper.worked(1);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
323 cancelHelper.checkCancelled();
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
324 ElementImpl ei = new ElementImpl(treeBuildInspector.commitRevisions.length);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
325 final ProgressSupport ph2;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
326 if (treeBuildInspector.commitRevisions.length < 100 /*XXX is it really worth it? */) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
327 ei.initTransform();
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
328 repo.getChangelog().range(ei, treeBuildInspector.commitRevisions);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
329 progressHelper.worked(1);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
330 ph2 = new ProgressSupport.Sub(progressHelper, 2);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
331 } else {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
332 ph2 = new ProgressSupport.Sub(progressHelper, 3);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
333 }
370
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
334 try {
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
335 ph2.start(completeHistory.length);
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
336 // XXX shall sort completeHistory according to changeset numbers?
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
337 for (int i = 0; i < completeHistory.length; i++ ) {
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
338 final HistoryNode n = completeHistory[i];
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
339 handler.next(ei.init(n));
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
340 ph2.worked(1);
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
341 cancelHelper.checkCancelled();
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
342 }
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
343 } catch (HgCallbackTargetException.Wrap ex) {
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
344 throw new HgCallbackTargetException(ex);
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
345 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
346 progressHelper.done();
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
347 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
348
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
349 //
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
350
154
ba2bf656f00f Changeset => RawChangeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 148
diff changeset
351 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
352 if (limit > 0 && count >= limit) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
353 return;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
354 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
355 if (branches != null && !branches.contains(cset.branch())) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
356 return;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
357 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
358 if (users != null) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
359 String csetUser = cset.user().toLowerCase();
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
360 boolean found = false;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
361 for (String u : users) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
362 if (csetUser.indexOf(u) != -1) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
363 found = true;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
364 break;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
365 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
366 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
367 if (!found) {
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
368 return;
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
369 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
370 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
371 if (date != null) {
383
994b5813a925 Few comments
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 380
diff changeset
372 // FIXME implement date support for log
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
373 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
374 count++;
193
37f3d4a596e4 Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 157
diff changeset
375 csetTransform.next(revisionNumber, nodeid, cset);
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
376 }
195
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 193
diff changeset
377
366
189dc6dc1c3e Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
378 private HgChangelog.ParentWalker getParentHelper(boolean create) throws HgInvalidControlFileException {
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
379 if (parentHelper == null && create) {
195
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 193
diff changeset
380 parentHelper = repo.getChangelog().new ParentWalker();
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 193
diff changeset
381 parentHelper.init();
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 193
diff changeset
382 }
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 193
diff changeset
383 return parentHelper;
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 193
diff changeset
384 }
c9b305df0b89 Optimization: use ParentWalker to get changeset's parents, if possible. Do not keep duplicating nodeids and strings in manifest revisions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 193
diff changeset
385
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
386
205
ffc5f6d59f7e HgLogCommand.Handler is used in few places, pull up to top-level class, HgChangesetHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 195
diff changeset
387 /**
ffc5f6d59f7e HgLogCommand.Handler is used in few places, pull up to top-level class, HgChangesetHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 195
diff changeset
388 * When {@link HgLogCommand} is executed against file, handler passed to {@link HgLogCommand#execute(HgChangesetHandler)} may optionally
249
4c3b9f679412 Deprecated HgLogCommand.FileRevision gone, top-level HgFileRevision is bright and shiny replacement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
389 * implement this interface to get information about file renames. Method {@link #copy(HgFileRevision, HgFileRevision)} would
129
645829962785 core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 126
diff changeset
390 * get invoked prior any changeset of the original file (if file history being followed) is reported via {@link #next(HgChangeset)}.
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
391 *
131
aa1629f36482 Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 129
diff changeset
392 * For {@link HgLogCommand#file(Path, boolean)} with renamed file path and follow argument set to false,
249
4c3b9f679412 Deprecated HgLogCommand.FileRevision gone, top-level HgFileRevision is bright and shiny replacement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 237
diff changeset
393 * {@link #copy(HgFileRevision, HgFileRevision)} would be invoked for the first copy/rename in the history of the file, but not
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
394 * followed by any changesets.
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
395 *
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
396 * @author Artem Tikhomirov
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
397 * @author TMate Software Ltd.
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
398 */
370
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
399 public interface FileHistoryHandler extends HgChangesetHandler { // FIXME move to stanalone class file, perhaps?
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
400 // XXX perhaps, should distinguish copy from rename? And what about merged revisions and following them?
370
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
401 /**
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
402 * @throws HgCallbackTargetException.Wrap wrapper object for any exception user code may produce. Wrapped exception would get re-thrown with {@link HgCallbackTargetException}
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
403 */
a2341e761609 Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 368
diff changeset
404 void copy(HgFileRevision from, HgFileRevision to) throws HgCallbackTargetException.Wrap;
80
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
405 }
4222b04f34ee Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 77
diff changeset
406
205
ffc5f6d59f7e HgLogCommand.Handler is used in few places, pull up to top-level class, HgChangesetHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 195
diff changeset
407 public static class CollectHandler implements HgChangesetHandler {
129
645829962785 core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 126
diff changeset
408 private final List<HgChangeset> result = new LinkedList<HgChangeset>();
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
409
129
645829962785 core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 126
diff changeset
410 public List<HgChangeset> getChanges() {
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
411 return Collections.unmodifiableList(result);
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
412 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
413
129
645829962785 core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 126
diff changeset
414 public void next(HgChangeset changeset) {
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
415 result.add(changeset.clone());
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
416 }
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
417 }
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
418
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
419 private static class HistoryNode {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
420 final int changeset;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
421 final Nodeid fileRevision;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
422 final HistoryNode parent1, parent2;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
423 List<HistoryNode> children;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
424
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
425 HistoryNode(int cs, Nodeid revision, HistoryNode p1, HistoryNode p2) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
426 changeset = cs;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
427 fileRevision = revision;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
428 parent1 = p1;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
429 parent2 = p2;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
430 if (p1 != null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
431 p1.addChild(this);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
432 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
433 if (p2 != null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
434 p2.addChild(this);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
435 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
436 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
437
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
438 void addChild(HistoryNode child) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
439 if (children == null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
440 children = new ArrayList<HistoryNode>(2);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
441 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
442 children.add(child);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
443 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
444 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
445
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
446 private class ElementImpl implements HgChangesetTreeHandler.TreeElement, HgChangelog.Inspector {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
447 private HistoryNode historyNode;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
448 private Pair<HgChangeset, HgChangeset> parents;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
449 private List<HgChangeset> children;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
450 private IntMap<HgChangeset> cachedChangesets;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
451 private ChangesetTransformer.Transformation transform;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
452 private Nodeid changesetRevision;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
453 private Pair<Nodeid,Nodeid> parentRevisions;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
454 private List<Nodeid> childRevisions;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
455
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
456 public ElementImpl(int total) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
457 cachedChangesets = new IntMap<HgChangeset>(total);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
458 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
459
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
460 ElementImpl init(HistoryNode n) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
461 historyNode = n;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
462 parents = null;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
463 children = null;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
464 changesetRevision = null;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
465 parentRevisions = null;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
466 childRevisions = null;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
467 return this;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
468 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
469
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
470 public Nodeid fileRevision() {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
471 return historyNode.fileRevision;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
472 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
473
366
189dc6dc1c3e Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
474 public HgChangeset changeset() throws HgException {
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
475 return get(historyNode.changeset)[0];
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
476 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
477
366
189dc6dc1c3e Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
478 public Pair<HgChangeset, HgChangeset> parents() throws HgException {
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
479 if (parents != null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
480 return parents;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
481 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
482 HistoryNode p;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
483 final int p1, p2;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
484 if ((p = historyNode.parent1) != null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
485 p1 = p.changeset;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
486 } else {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
487 p1 = -1;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
488 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
489 if ((p = historyNode.parent2) != null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
490 p2 = p.changeset;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
491 } else {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
492 p2 = -1;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
493 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
494 HgChangeset[] r = get(p1, p2);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
495 return parents = new Pair<HgChangeset, HgChangeset>(r[0], r[1]);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
496 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
497
366
189dc6dc1c3e Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
498 public Collection<HgChangeset> children() throws HgException {
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
499 if (children != null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
500 return children;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
501 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
502 if (historyNode.children == null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
503 children = Collections.emptyList();
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
504 } else {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
505 int[] childrentChangesetNumbers = new int[historyNode.children.size()];
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
506 int j = 0;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
507 for (HistoryNode hn : historyNode.children) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
508 childrentChangesetNumbers[j++] = hn.changeset;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
509 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
510 children = Arrays.asList(get(childrentChangesetNumbers));
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
511 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
512 return children;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
513 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
514
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
515 void populate(HgChangeset cs) {
403
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
516 cachedChangesets.put(cs.getRevisionIndex(), cs);
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
517 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
518
403
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
519 private HgChangeset[] get(int... changelogRevisionIndex) throws HgException {
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
520 HgChangeset[] rv = new HgChangeset[changelogRevisionIndex.length];
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
521 IntVector misses = new IntVector(changelogRevisionIndex.length, -1);
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
522 for (int i = 0; i < changelogRevisionIndex.length; i++) {
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
523 if (changelogRevisionIndex[i] == -1) {
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
524 rv[i] = null;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
525 continue;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
526 }
403
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
527 HgChangeset cached = cachedChangesets.get(changelogRevisionIndex[i]);
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
528 if (cached != null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
529 rv[i] = cached;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
530 } else {
403
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
531 misses.add(changelogRevisionIndex[i]);
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
532 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
533 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
534 if (misses.size() > 0) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
535 final int[] changesets2read = misses.toArray();
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
536 initTransform();
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
537 repo.getChangelog().range(this, changesets2read);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
538 for (int changeset2read : changesets2read) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
539 HgChangeset cs = cachedChangesets.get(changeset2read);
403
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
540 if (cs == null) {
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
541 throw new HgException(String.format("Can't get changeset for revision %d", changeset2read));
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
542 }
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
543 // HgChangelog.range may reorder changesets according to their order in the changelog
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
544 // thus need to find original index
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
545 boolean sanity = false;
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
546 for (int i = 0; i < changelogRevisionIndex.length; i++) {
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
547 if (changelogRevisionIndex[i] == cs.getRevisionIndex()) {
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
548 rv[i] = cs;
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
549 sanity = true;
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
550 break;
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
551 }
403
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
552 }
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
553 if (!sanity) {
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
554 HgInternals.getContext(repo).getLog().error(getClass(), "Index of revision %d:%s doesn't match any of requested", cs.getRevisionIndex(), cs.getNodeid().shortNotation());
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
555 }
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
556 assert sanity;
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
557 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
558 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
559 return rv;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
560 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
561
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
562 // init only when needed
366
189dc6dc1c3e Use exceptions to expose errors reading mercurial data
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 354
diff changeset
563 void initTransform() throws HgInvalidControlFileException {
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
564 if (transform == null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
565 transform = new ChangesetTransformer.Transformation(new HgStatusCollector(repo)/*XXX try to reuse from context?*/, getParentHelper(false));
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
566 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
567 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
568
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
569 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
570 HgChangeset cs = transform.handle(revisionNumber, nodeid, cset);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
571 populate(cs.clone());
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
572 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
573
403
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
574 public Nodeid changesetRevision() throws HgException {
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
575 if (changesetRevision == null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
576 changesetRevision = getRevision(historyNode.changeset);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
577 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
578 return changesetRevision;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
579 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
580
403
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
581 public Pair<Nodeid, Nodeid> parentRevisions() throws HgException {
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
582 if (parentRevisions == null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
583 HistoryNode p;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
584 final Nodeid p1, p2;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
585 if ((p = historyNode.parent1) != null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
586 p1 = getRevision(p.changeset);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
587 } else {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
588 p1 = Nodeid.NULL;;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
589 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
590 if ((p = historyNode.parent2) != null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
591 p2 = getRevision(p.changeset);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
592 } else {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
593 p2 = Nodeid.NULL;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
594 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
595 parentRevisions = new Pair<Nodeid, Nodeid>(p1, p2);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
596 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
597 return parentRevisions;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
598 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
599
403
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
600 public Collection<Nodeid> childRevisions() throws HgException {
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
601 if (childRevisions != null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
602 return childRevisions;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
603 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
604 if (historyNode.children == null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
605 childRevisions = Collections.emptyList();
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
606 } else {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
607 ArrayList<Nodeid> rv = new ArrayList<Nodeid>(historyNode.children.size());
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
608 for (HistoryNode hn : historyNode.children) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
609 rv.add(getRevision(hn.changeset));
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
610 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
611 childRevisions = Collections.unmodifiableList(rv);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
612 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
613 return childRevisions;
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
614 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
615
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
616 // reading nodeid involves reading index only, guess, can afford not to optimize multiple reads
403
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
617 private Nodeid getRevision(int changelogRevisionNumber) throws HgInvalidControlFileException {
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
618 // TODO [post-1.0] pipe through pool
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
619 HgChangeset cs = cachedChangesets.get(changelogRevisionNumber);
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
620 if (cs != null) {
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
621 return cs.getNodeid();
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
622 } else {
403
2747b0723867 FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 402
diff changeset
623 return repo.getChangelog().getRevision(changelogRevisionNumber);
328
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
624 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
625 }
a674b8590362 Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 322
diff changeset
626 }
64
19e9e220bf68 Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
627 }