Mercurial > hg4j
annotate src/org/tmatesoft/hg/core/HgLogCommand.java @ 514:5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 17 Dec 2012 19:06:07 +0100 |
parents | 122e0600799f |
children | e6c8b9b654b2 |
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 /* |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
2 s * 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; |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
432
diff
changeset
|
20 import static org.tmatesoft.hg.util.LogFacility.Severity.Error; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
21 |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
22 import java.util.ArrayList; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
23 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
|
24 import java.util.Calendar; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
25 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
|
26 import java.util.Collections; |
511
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
27 import java.util.Comparator; |
64
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.ConcurrentModificationException; |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
29 import java.util.Iterator; |
64
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.LinkedList; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
31 import java.util.List; |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
32 import java.util.ListIterator; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
33 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
|
34 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
|
35 |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
36 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
|
37 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
|
38 import org.tmatesoft.hg.repo.HgChangelog; |
154
ba2bf656f00f
Changeset => RawChangeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
39 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
40 import org.tmatesoft.hg.repo.HgDataFile; |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
41 import org.tmatesoft.hg.repo.HgInvalidControlFileException; |
457
d78cb5ca3053
Get rid of ambiguity in method name
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
42 import org.tmatesoft.hg.repo.HgInvalidRevisionException; |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
43 import org.tmatesoft.hg.repo.HgInvalidStateException; |
456
909306e412e2
Refactor LogFacility and SessionContext, better API for both
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
432
diff
changeset
|
44 import org.tmatesoft.hg.repo.HgParentChildMap; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
70
diff
changeset
|
45 import org.tmatesoft.hg.repo.HgRepository; |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
46 import org.tmatesoft.hg.repo.HgRuntimeException; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
47 import org.tmatesoft.hg.repo.HgStatusCollector; |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
48 import org.tmatesoft.hg.util.Adaptable; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 |
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 /** |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
57 * 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
|
58 * |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
59 * <pre> |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
60 * Usage: |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
61 * 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
|
62 * </pre> |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
63 * 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
|
64 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
65 * @author Artem Tikhomirov |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
66 * @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
|
67 */ |
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
|
68 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
|
69 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
70 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
|
71 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
|
72 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
|
73 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
|
74 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
|
75 private Calendar date; |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
76 private Path file; |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
77 /* |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
78 * Whether to iterate file origins, if any. |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
79 * Makes sense only when file != null |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
80 */ |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
81 private boolean followRenames; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
82 /* |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
83 * Whether to track history of the selected file version (based on file revision |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
84 * in working dir parent), follow ancestors only. |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
85 * Note, 'hg log --follow' combines both #followHistory and #followAncestry |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
86 */ |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
87 private boolean followAncestry; |
193
37f3d4a596e4
Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
88 private ChangesetTransformer csetTransform; |
432
1fc0da631200
Revlog.ParentWalker helper class got promoted as TLC, renamed to HgParentChildMap
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
89 private HgParentChildMap<HgChangelog> parentHelper; |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
90 |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
91 public HgLogCommand(HgRepository hgRepo) { |
107 | 92 repo = hgRepo; |
64
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 /** |
148
1a7a9a20e1f9
Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
96 * 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
|
97 * 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
|
98 * @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
|
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 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 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
|
103 if (user == 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 (users == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
107 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
|
108 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
109 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
|
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 /** |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
114 * 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
|
115 * 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
|
116 * 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
|
117 * @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
|
118 * @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
|
119 * @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
|
120 */ |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
121 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
|
122 if (branch == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
123 throw new IllegalArgumentException(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
124 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
125 if (branches == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
126 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
|
127 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
128 branches.add(branch); |
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 // 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
|
133 // multiple? |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
134 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
|
135 this.date = date; |
418
528b6780a8bd
A bit of FIXME cleanup (mostly degraded to TODO post 1.0), comments and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
136 // TODO post-1.0 implement |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
137 // 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
|
138 throw HgRepository.notImplemented(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
139 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
140 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
141 /** |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
142 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
143 * @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
|
144 * @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
|
145 */ |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
146 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
|
147 limit = num; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
148 return this; |
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 |
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 * 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
|
153 * Revision may be specified with {@link HgRepository#TIP} |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
154 * |
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
155 * @param rev1 - local index of start changeset revision |
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
156 * @param rev2 - index of end changeset revision |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
157 * @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
|
158 */ |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
159 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
|
160 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
|
161 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
|
162 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
|
163 } 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
|
164 startRev = rev2; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
165 endRev = rev1; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
166 } else { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
167 startRev = rev1; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
168 endRev = rev2; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
169 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
170 return this; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
171 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
172 |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
173 /** |
253
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
174 * Select specific changeset |
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
175 * |
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
176 * @param nid changeset revision |
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
177 * @return <code>this</code> for convenience |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
178 * @throws HgBadArgumentException if failed to find supplied changeset revision |
253
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
179 */ |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
180 public HgLogCommand changeset(Nodeid nid) throws HgBadArgumentException { |
253
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
181 // XXX perhaps, shall support multiple (...) arguments and extend #execute to handle not only range, but also set of revisions. |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
182 try { |
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
183 final int csetRevIndex = repo.getChangelog().getRevisionIndex(nid); |
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
184 return range(csetRevIndex, csetRevIndex); |
457
d78cb5ca3053
Get rid of ambiguity in method name
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
456
diff
changeset
|
185 } catch (HgInvalidRevisionException ex) { |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
186 throw new HgBadArgumentException("Can't find revision", ex).setRevision(nid); |
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
187 } |
253
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
188 } |
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
189 |
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
190 /** |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
191 * Visit history of a given file only. |
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
192 * @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
|
193 * @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
|
194 */ |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
195 public HgLogCommand file(Path file, boolean followCopyRename) { |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
196 // 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
|
197 this.file = file; |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
198 followRenames = followAncestry = followCopyRename; |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
199 return this; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
200 } |
142
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
201 |
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
202 /** |
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
203 * 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
|
204 */ |
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
205 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
|
206 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
|
207 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
208 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
209 /** |
419
7f136a3fa671
Clean javadoc to fix obvious warnings
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
418
diff
changeset
|
210 * Similar to {@link #execute(HgChangesetHandler)}, collects and return result as a list. |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
211 * |
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
212 * @see #execute(HgChangesetHandler) |
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
213 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
214 */ |
396
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
383
diff
changeset
|
215 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
|
216 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
|
217 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
|
218 execute(collector); |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
219 } catch (HgCallbackTargetException ex) { |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
220 // see below for CanceledException |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
221 HgInvalidStateException t = new HgInvalidStateException("Internal error"); |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
222 t.initCause(ex); |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
223 throw t; |
396
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
383
diff
changeset
|
224 } 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
|
225 // can't happen as long as our CollectHandler doesn't throw any exception |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
226 HgInvalidStateException t = new HgInvalidStateException("Internal error"); |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
227 t.initCause(ex); |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
228 throw t; |
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
|
229 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
230 return collector.getChanges(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
231 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
232 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
233 /** |
402
1fcc7f7b6d65
FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
396
diff
changeset
|
234 * 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
|
235 * |
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
|
236 * @param handler callback to process changesets. |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
237 * @throws HgCallbackTargetException propagated exception from the handler |
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
238 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state |
380
9517df1ef7ec
Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
370
diff
changeset
|
239 * @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
|
240 * @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
|
241 * @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
|
242 */ |
370
a2341e761609
Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
243 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
|
244 if (handler == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
245 throw new IllegalArgumentException(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
246 } |
193
37f3d4a596e4
Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
247 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
|
248 throw new ConcurrentModificationException(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
249 } |
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
|
250 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
|
251 try { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
252 count = 0; |
432
1fc0da631200
Revlog.ParentWalker helper class got promoted as TLC, renamed to HgParentChildMap
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
253 HgParentChildMap<HgChangelog> 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
|
254 // 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
|
255 // 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
|
256 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
|
257 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
|
258 progressHelper.start(endRev - startRev + 1); |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
259 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
|
260 csetTransform.checkFailure(); |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
261 } 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
|
262 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
|
263 HgDataFile fileNode = repo.getFileNode(file); |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
264 if (!fileNode.exists()) { |
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
265 throw new HgPathNotFoundException(String.format("File %s not found in the repository", file), file); |
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
266 } |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
267 // FIXME startRev and endRev ARE CHANGESET REVISIONS, not that of FILE!!! |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
268 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
|
269 csetTransform.checkFailure(); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
270 final HgFileRenameHandlerMixin withCopyHandler = Adaptable.Factory.getAdapter(handler, HgFileRenameHandlerMixin.class, null); |
126
b92a638764be
Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
107
diff
changeset
|
271 if (fileNode.isCopy()) { |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
272 // 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
|
273 do { |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
274 if (withCopyHandler != null) { |
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
|
275 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
|
276 HgFileRevision dst = new HgFileRevision(repo, fileNode.getRevision(0), null, fileNode.getPath(), src.getPath()); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
277 withCopyHandler.copy(src, dst); |
126
b92a638764be
Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
107
diff
changeset
|
278 } |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
279 if (limit > 0 && count >= limit) { |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
280 // if limit reach, follow is useless. |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
281 break; |
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
282 } |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
283 if (followRenames) { |
126
b92a638764be
Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
107
diff
changeset
|
284 fileNode = repo.getFileNode(fileNode.getCopySourceName()); |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
285 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
|
286 csetTransform.checkFailure(); |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
287 } |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
288 } while (followRenames && fileNode.isCopy()); |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
289 } |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
290 } |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
291 } catch (HgRuntimeException ex) { |
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
292 throw new HgLibraryFailureException(ex); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
293 } finally { |
193
37f3d4a596e4
Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
294 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
|
295 progressHelper.done(); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
296 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
297 } |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
298 |
370
a2341e761609
Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
299 /** |
402
1fcc7f7b6d65
FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
396
diff
changeset
|
300 * 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
|
301 * |
1fcc7f7b6d65
FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
396
diff
changeset
|
302 * @param handler callback to process changesets. |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
303 * @throws HgCallbackTargetException propagated exception from the handler |
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
304 * @throws HgException subclass thereof to indicate specific issue with the command arguments or repository state |
380
9517df1ef7ec
Comments/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
370
diff
changeset
|
305 * @throws CancelledException if execution of the command was cancelled |
402
1fcc7f7b6d65
FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
396
diff
changeset
|
306 * @throws IllegalArgumentException if command is not satisfied with its arguments |
1fcc7f7b6d65
FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
396
diff
changeset
|
307 * @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
|
308 */ |
a2341e761609
Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
309 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
|
310 if (handler == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
311 throw new IllegalArgumentException(); |
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 if (csetTransform != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
314 throw new ConcurrentModificationException(); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
315 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
316 if (file == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
317 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
|
318 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
319 final ProgressSupport progressHelper = getProgressSupport(handler); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
320 final CancelSupport cancelHelper = getCancelSupport(handler, true); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
321 final HgFileRenameHandlerMixin renameHandler = Adaptable.Factory.getAdapter(handler, HgFileRenameHandlerMixin.class, null); |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
322 |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
323 // builds tree of nodes according to parents in file's revlog |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
324 final TreeBuildInspector treeBuildInspector = new TreeBuildInspector(followRenames); |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
325 // we iterate separate histories of each filename, need to connect |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
326 // last node of historyA with first node of historyB (A renamed to B case) |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
327 // to make overall history smooth. |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
328 HistoryNode lastFromPrevIteration = null; |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
329 HgFileRevision copiedFrom = null, copiedTo = null; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
330 boolean shallReportRenameAfter1Step = false; |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
331 |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
332 final int CACHE_CSET_IN_ADVANCE_THRESHOLD = 100; /* XXX is it really worth it? */ |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
333 ElementImpl ei = null; |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
334 |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
335 // renamed files in the queue are placed with respect to #iterateDirection |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
336 // i.e. if we iterate from new to old, recent filenames come first |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
337 List<Pair<HgDataFile, Nodeid>> fileRenamesQueue = buildFileRenamesQueue(); |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
338 progressHelper.start(4 * fileRenamesQueue.size()); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
339 for (int namesIndex = 0, renamesQueueSize = fileRenamesQueue.size(); namesIndex < renamesQueueSize; namesIndex++) { |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
340 |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
341 final Pair<HgDataFile, Nodeid> renameInfo = fileRenamesQueue.get(namesIndex); |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
342 cancelHelper.checkCancelled(); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
343 final List<HistoryNode> changeHistory = treeBuildInspector.go(renameInfo.first(), renameInfo.second()); |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
344 assert changeHistory.size() > 0; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
345 progressHelper.worked(1); |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
346 cancelHelper.checkCancelled(); |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
347 final ProgressSupport ph2; |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
348 if (ei == null) { |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
349 // when follow is true, changeHistory.size() of the first revision might be quite short |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
350 // (e.g. bad fname recognized soon), hence ensure at least cache size at once |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
351 ei = new ElementImpl(Math.max(CACHE_CSET_IN_ADVANCE_THRESHOLD, changeHistory.size())); |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
352 } |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
353 if (changeHistory.size() < CACHE_CSET_IN_ADVANCE_THRESHOLD ) { |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
354 int[] commitRevisions = treeBuildInspector.getCommitRevisions(); |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
355 assert changeHistory.size() == commitRevisions.length; |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
356 // read bunch of changesets at once and cache 'em |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
357 ei.initTransform(); |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
358 repo.getChangelog().range(ei, commitRevisions); |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
359 progressHelper.worked(1); |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
360 ph2 = new ProgressSupport.Sub(progressHelper, 2); |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
361 } else { |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
362 ph2 = new ProgressSupport.Sub(progressHelper, 3); |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
363 } |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
364 ph2.start(changeHistory.size()); |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
365 if (lastFromPrevIteration != null) { |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
366 if (iterateDirection == IterateDirection.FromOldToNew) { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
367 // forward, from old to new: |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
368 // A(0..n) -> B(0..m). First, report A(0)..A(n-1) |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
369 // then A(n).bind(B(0)) |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
370 HistoryNode oldestOfTheNextChunk = changeHistory.get(0); // B(0) |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
371 lastFromPrevIteration.bindChild(oldestOfTheNextChunk); // lastFromPrevIteration is A(n) |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
372 changeHistory.add(0, lastFromPrevIteration); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
373 if (renameHandler != null) { // shall report renames |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
374 assert namesIndex > 0; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
375 HgDataFile lastIterationFileNode = fileRenamesQueue.get(namesIndex-1).first(); // A |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
376 copiedFrom = new HgFileRevision(lastIterationFileNode, lastFromPrevIteration.fileRevision, null); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
377 copiedTo = new HgFileRevision(renameInfo.first(), oldestOfTheNextChunk.fileRevision, copiedFrom.getPath()); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
378 shallReportRenameAfter1Step = true; // report rename after A(n) |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
379 } |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
380 } else { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
381 assert iterateDirection == IterateDirection.FromNewToOld; |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
382 // A renamed to B. A(0..n) -> B(0..m). |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
383 // First, report B(m), B(m-1)...B(1), then A(n).bind(B(0)), report B(0), A(n)... |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
384 HistoryNode newestOfNextChunk = changeHistory.get(changeHistory.size() - 1); // A(n) |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
385 newestOfNextChunk.bindChild(lastFromPrevIteration); |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
386 changeHistory.add(lastFromPrevIteration); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
387 if (renameHandler != null) { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
388 assert namesIndex > 0; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
389 // renameInfo points to chunk of name A now, and lastFromPrevIteration (from namesIndex-1) is B |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
390 copiedFrom = new HgFileRevision(renameInfo.first(), newestOfNextChunk.fileRevision, null); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
391 HgDataFile lastIterationFileNode = fileRenamesQueue.get(namesIndex-1).first(); // B |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
392 copiedTo = new HgFileRevision(lastIterationFileNode, lastFromPrevIteration.fileRevision, copiedFrom.getPath()); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
393 shallReportRenameAfter1Step = true; // report rename after B(0) |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
394 } |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
395 } |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
396 } |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
397 if (namesIndex + 1 < renamesQueueSize) { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
398 // there's at least one more name we are going to look at, save |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
399 // one element for later binding |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
400 // |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
401 if (iterateDirection == IterateDirection.FromOldToNew) { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
402 // save newest, and exclude it from this iteration (postpone for next) |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
403 lastFromPrevIteration = changeHistory.remove(changeHistory.size()-1); |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
404 } else { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
405 assert iterateDirection == IterateDirection.FromNewToOld; |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
406 // save oldest, and exclude it from this iteration (postpone for next) |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
407 lastFromPrevIteration = changeHistory.remove(0); |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
408 } |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
409 } else { |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
410 lastFromPrevIteration = null; // just for the sake of no references to old items |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
411 } |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
412 // XXX shall sort changeHistory according to changeset numbers? |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
413 Iterator<HistoryNode> it; |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
414 if (iterateDirection == IterateDirection.FromOldToNew) { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
415 it = changeHistory.listIterator(); |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
416 } else { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
417 assert iterateDirection == IterateDirection.FromNewToOld; |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
418 it = new ReverseIterator<HistoryNode>(changeHistory); |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
419 } |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
420 while(it.hasNext()) { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
421 HistoryNode n = it.next(); |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
422 handler.treeElement(ei.init(n)); |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
423 ph2.worked(1); |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
424 cancelHelper.checkCancelled(); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
425 if (shallReportRenameAfter1Step) { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
426 assert renameHandler != null; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
427 assert copiedFrom != null; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
428 assert copiedTo != null; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
429 renameHandler.copy(copiedFrom, copiedTo); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
430 shallReportRenameAfter1Step = false; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
431 copiedFrom = copiedTo = null; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
432 } |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
433 } |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
434 } // for fileRenamesQueue; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
435 progressHelper.done(); |
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 |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
438 private IterateDirection iterateDirection = IterateDirection.FromOldToNew; |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
439 |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
440 private static class ReverseIterator<E> implements Iterator<E> { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
441 private final ListIterator<E> listIterator; |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
442 |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
443 public ReverseIterator(List<E> list) { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
444 listIterator = list.listIterator(list.size()); |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
445 } |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
446 |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
447 public boolean hasNext() { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
448 return listIterator.hasPrevious(); |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
449 } |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
450 public E next() { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
451 return listIterator.previous(); |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
452 } |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
453 public void remove() { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
454 listIterator.remove(); |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
455 } |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
456 } |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
457 |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
458 /** |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
459 * Follows file renames and build a list of all corresponding file nodes and revisions they were |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
460 * copied/renamed/branched at (IOW, their latest revision to look at). |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
461 * |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
462 * If {@link #followRenames} is <code>false</code>, the list contains one element only, |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
463 * file node with the name of the file as it was specified by the user. |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
464 * |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
465 * For the most recent file revision depends on {@link #followAncestry}, and is file revision from working copy parent |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
466 * in it's true. <code>null</code> indicates file's TIP revision shall be used. |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
467 * |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
468 * TODO may use HgFileRevision (after some refactoring to accept HgDataFile and Nodeid) instead of Pair |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
469 * and possibly reuse this functionality |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
470 * |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
471 * @return list of file renames, ordered with respect to {@link #iterateDirection} |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
472 */ |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
473 private List<Pair<HgDataFile, Nodeid>> buildFileRenamesQueue() { |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
474 LinkedList<Pair<HgDataFile, Nodeid>> rv = new LinkedList<Pair<HgDataFile, Nodeid>>(); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
475 Nodeid startRev = null; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
476 HgDataFile fileNode = repo.getFileNode(file); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
477 if (followAncestry) { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
478 // TODO subject to dedicated method either in HgRepository (getWorkingCopyParentRevisionIndex) |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
479 // or in the HgDataFile (getWorkingCopyOriginRevision) |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
480 Nodeid wdParentChangeset = repo.getWorkingCopyParents().first(); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
481 if (!wdParentChangeset.isNull()) { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
482 int wdParentRevIndex = repo.getChangelog().getRevisionIndex(wdParentChangeset); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
483 startRev = repo.getManifest().getFileRevision(wdParentRevIndex, fileNode.getPath()); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
484 } |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
485 // else fall-through, assume null (eventually, lastRevision()) is ok here |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
486 } |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
487 rv.add(new Pair<HgDataFile, Nodeid>(fileNode, startRev)); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
488 if (!followRenames) { |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
489 return rv; |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
490 } |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
491 while (fileNode.isCopy()) { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
492 Path fp = fileNode.getCopySourceName(); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
493 Nodeid copyRev = fileNode.getCopySourceRevision(); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
494 fileNode = repo.getFileNode(fp); |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
495 Pair<HgDataFile, Nodeid> p = new Pair<HgDataFile, Nodeid>(fileNode, copyRev); |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
496 if (iterateDirection == IterateDirection.FromOldToNew) { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
497 rv.addFirst(p); |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
498 } else { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
499 assert iterateDirection == IterateDirection.FromNewToOld; |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
500 rv.addLast(p); |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
501 } |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
502 }; |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
503 return rv; |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
504 } |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
505 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
506 private static class TreeBuildInspector implements HgChangelog.ParentInspector, HgChangelog.RevisionInspector { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
507 private final boolean followAncestry; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
508 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
509 private HistoryNode[] completeHistory; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
510 private int[] commitRevisions; |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
511 private List<HistoryNode> resultHistory; |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
512 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
513 TreeBuildInspector(boolean _followAncestry) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
514 followAncestry = _followAncestry; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
515 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
516 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
517 public void next(int revisionNumber, Nodeid revision, int linkedRevision) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
518 commitRevisions[revisionNumber] = linkedRevision; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
519 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
520 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
521 public void next(int revisionNumber, Nodeid revision, int parent1, int parent2, Nodeid nidParent1, Nodeid nidParent2) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
522 HistoryNode p1 = null, p2 = null; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
523 if (parent1 != -1) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
524 p1 = completeHistory[parent1]; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
525 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
526 if (parent2!= -1) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
527 p2 = completeHistory[parent2]; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
528 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
529 completeHistory[revisionNumber] = new HistoryNode(commitRevisions[revisionNumber], revision, p1, p2); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
530 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
531 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
532 /** |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
533 * Builds history of file changes (in natural order, from oldest to newest) up to (and including) file revision specified. |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
534 * If {@link TreeBuildInspector} follows ancestry, only elements that are on the line of ancestry of the revision at |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
535 * lastRevisionIndex would be included. |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
536 * |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
537 * @return list of history elements, from oldest to newest. In case {@link #followAncestry} is <code>true</code>, the list |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
538 * is modifiable (to further augment with last/first elements of renamed file histories) |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
539 */ |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
540 List<HistoryNode> go(HgDataFile fileNode, Nodeid fileLastRevisionToVisit) throws HgInvalidControlFileException { |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
541 resultHistory = null; |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
542 int fileLastRevIndexToVisit = fileLastRevisionToVisit == null ? fileNode.getLastRevision() : fileNode.getRevisionIndex(fileLastRevisionToVisit); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
543 completeHistory = new HistoryNode[fileLastRevIndexToVisit+1]; |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
544 commitRevisions = new int[completeHistory.length]; |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
545 fileNode.indexWalk(0, fileLastRevIndexToVisit, this); |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
546 if (!followAncestry) { |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
547 // in case when ancestor not followed, it's safe to return unmodifiable list |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
548 resultHistory = Arrays.asList(completeHistory); |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
549 completeHistory = null; |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
550 // keep commitRevisions initialized, no need to recalculate them |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
551 // as they correspond 1:1 to resultHistory |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
552 return resultHistory; |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
553 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
554 /* |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
555 * Changesets, newest at the top: |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
556 * o <-- cset from working dir parent (as in dirstate), file not changed (file revision recorded points to that from A) |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
557 * | x <-- revision with file changed (B') |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
558 * x / <-- revision with file changed (A) |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
559 * | x <-- revision with file changed (B) |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
560 * |/ |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
561 * o <-- another changeset, where file wasn't changed |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
562 * | |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
563 * x <-- revision with file changed (C) |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
564 * |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
565 * File history: B', A, B, C |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
566 * |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
567 * When "follow", SHALL NOT report B and B', but A and C |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
568 */ |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
569 // strippedHistory: only those HistoryNodes from completeHistory that are on the same |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
570 // line of descendant, in order from older to newer |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
571 LinkedList<HistoryNode> strippedHistoryList = new LinkedList<HistoryNode>(); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
572 LinkedList<HistoryNode> queue = new LinkedList<HistoryNode>(); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
573 // look for ancestors of the selected history node |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
574 queue.add(completeHistory[fileLastRevIndexToVisit]); |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
575 do { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
576 HistoryNode withFileChange = queue.removeFirst(); |
511
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
577 if (strippedHistoryList.contains(withFileChange)) { |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
578 // fork point for the change that was later merged (and we traced |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
579 // both lines of development by now. |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
580 continue; |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
581 } |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
582 if (withFileChange.children != null) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
583 withFileChange.children.retainAll(strippedHistoryList); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
584 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
585 strippedHistoryList.addFirst(withFileChange); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
586 if (withFileChange.parent1 != null) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
587 queue.addLast(withFileChange.parent1); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
588 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
589 if (withFileChange.parent2 != null) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
590 queue.addLast(withFileChange.parent2); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
591 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
592 } while (!queue.isEmpty()); |
511
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
593 Collections.sort(strippedHistoryList, new Comparator<HistoryNode>() { |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
594 |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
595 public int compare(HistoryNode o1, HistoryNode o2) { |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
596 return o1.changeset - o2.changeset; |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
597 } |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
598 }); |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
599 completeHistory = null; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
600 commitRevisions = null; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
601 // collected values are no longer valid - shall |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
602 // strip off elements for missing HistoryNodes, but it's easier just to re-create the array |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
603 // from resultHistory later, once (and if) needed |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
604 return resultHistory = strippedHistoryList; |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
605 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
606 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
607 /** |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
608 * handy access to all HistoryNode[i].changeset values |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
609 */ |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
610 int[] getCommitRevisions() { |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
611 if (commitRevisions == null) { |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
612 commitRevisions = new int[resultHistory.size()]; |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
613 int i = 0; |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
614 for (HistoryNode n : resultHistory) { |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
615 commitRevisions[i++] = n.changeset; |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
616 } |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
617 } |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
618 return commitRevisions; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
619 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
620 }; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
621 |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
490
diff
changeset
|
622 |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
623 // |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
624 |
154
ba2bf656f00f
Changeset => RawChangeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
625 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
|
626 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
|
627 return; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
628 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
629 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
|
630 return; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
631 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
632 if (users != null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
633 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
|
634 boolean found = false; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
635 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
|
636 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
|
637 found = true; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
638 break; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
639 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
640 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
641 if (!found) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
642 return; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
643 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
644 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
645 if (date != null) { |
418
528b6780a8bd
A bit of FIXME cleanup (mostly degraded to TODO post 1.0), comments and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
415
diff
changeset
|
646 // TODO post-1.0 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
|
647 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
648 count++; |
193
37f3d4a596e4
Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
649 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
|
650 } |
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
|
651 |
432
1fc0da631200
Revlog.ParentWalker helper class got promoted as TLC, renamed to HgParentChildMap
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
652 private HgParentChildMap<HgChangelog> 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
|
653 if (parentHelper == null && create) { |
432
1fc0da631200
Revlog.ParentWalker helper class got promoted as TLC, renamed to HgParentChildMap
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
431
diff
changeset
|
654 parentHelper = new HgParentChildMap<HgChangelog>(repo.getChangelog()); |
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
|
655 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
|
656 } |
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
|
657 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
|
658 } |
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
|
659 |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
660 |
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
|
661 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
|
662 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
|
663 |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
126
diff
changeset
|
664 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
|
665 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
|
666 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
667 |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
668 public void cset(HgChangeset changeset) { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
669 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
|
670 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
671 } |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
672 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
673 private static class HistoryNode { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
674 final int changeset; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
675 final Nodeid fileRevision; |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
676 HistoryNode parent1; // there's special case when we can alter it, see #bindChild() |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
677 final HistoryNode parent2; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
678 List<HistoryNode> children; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
679 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
680 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
|
681 changeset = cs; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
682 fileRevision = revision; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
683 parent1 = p1; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
684 parent2 = p2; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
685 if (p1 != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
686 p1.addChild(this); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
687 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
688 if (p2 != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
689 p2.addChild(this); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
690 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
691 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
692 |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
693 private void addChild(HistoryNode child) { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
694 if (children == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
695 children = new ArrayList<HistoryNode>(2); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
696 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
697 children.add(child); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
698 } |
509
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
699 |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
700 /** |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
701 * method to merge two history chunks for renamed file so that |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
702 * this node's history continues with that of child |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
703 * @param child |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
704 */ |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
705 public void bindChild(HistoryNode child) { |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
706 assert child.parent1 == null && child.parent2 == null; |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
707 // for the last element in history empty children are by construction: |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
708 // we don't iterate further than last element of interest in TreeBuildInspector#go |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
709 assert children == null || children.isEmpty(); |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
710 child.parent1 = this; |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
711 addChild(child); |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
712 } |
511
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
713 |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
714 public String toString() { |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
715 return String.format("<cset:%d, parents: %s, %s>", changeset, parent1 == null ? "-" : String.valueOf(parent1.changeset), parent2 == null ? "-" : String.valueOf(parent2.changeset)); |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
716 } |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
717 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
718 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
719 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
|
720 private HistoryNode historyNode; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
721 private Pair<HgChangeset, HgChangeset> parents; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
722 private List<HgChangeset> children; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
723 private IntMap<HgChangeset> cachedChangesets; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
724 private ChangesetTransformer.Transformation transform; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
725 private Nodeid changesetRevision; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
726 private Pair<Nodeid,Nodeid> parentRevisions; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
727 private List<Nodeid> childRevisions; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
728 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
729 public ElementImpl(int total) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
730 cachedChangesets = new IntMap<HgChangeset>(total); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
731 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
732 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
733 ElementImpl init(HistoryNode n) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
734 historyNode = n; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
735 parents = null; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
736 children = null; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
737 changesetRevision = null; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
738 parentRevisions = null; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
739 childRevisions = null; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
740 return this; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
741 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
742 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
743 public Nodeid fileRevision() { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
744 return historyNode.fileRevision; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
745 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
746 |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
747 public HgChangeset changeset() { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
748 return get(historyNode.changeset)[0]; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
749 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
750 |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
751 public Pair<HgChangeset, HgChangeset> parents() { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
752 if (parents != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
753 return parents; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
754 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
755 HistoryNode p; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
756 final int p1, p2; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
757 if ((p = historyNode.parent1) != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
758 p1 = p.changeset; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
759 } else { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
760 p1 = -1; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
761 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
762 if ((p = historyNode.parent2) != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
763 p2 = p.changeset; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
764 } else { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
765 p2 = -1; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
766 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
767 HgChangeset[] r = get(p1, p2); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
768 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
|
769 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
770 |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
771 public Collection<HgChangeset> children() { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
772 if (children != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
773 return children; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
774 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
775 if (historyNode.children == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
776 children = Collections.emptyList(); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
777 } else { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
778 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
|
779 int j = 0; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
780 for (HistoryNode hn : historyNode.children) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
781 childrentChangesetNumbers[j++] = hn.changeset; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
782 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
783 children = Arrays.asList(get(childrentChangesetNumbers)); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
784 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
785 return children; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
786 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
787 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
788 void populate(HgChangeset cs) { |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
789 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
|
790 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
791 |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
792 private HgChangeset[] get(int... changelogRevisionIndex) { |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
793 HgChangeset[] rv = new HgChangeset[changelogRevisionIndex.length]; |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
794 IntVector misses = new IntVector(changelogRevisionIndex.length, -1); |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
795 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
|
796 if (changelogRevisionIndex[i] == -1) { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
797 rv[i] = null; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
798 continue; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
799 } |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
800 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
|
801 if (cached != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
802 rv[i] = cached; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
803 } else { |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
804 misses.add(changelogRevisionIndex[i]); |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
805 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
806 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
807 if (misses.size() > 0) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
808 final int[] changesets2read = misses.toArray(); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
809 initTransform(); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
810 repo.getChangelog().range(this, changesets2read); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
811 for (int changeset2read : changesets2read) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
812 HgChangeset cs = cachedChangesets.get(changeset2read); |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
813 if (cs == null) { |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
814 HgInvalidStateException t = new HgInvalidStateException(String.format("Can't get changeset for revision %d", changeset2read)); |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
815 throw t.setRevisionIndex(changeset2read); |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
816 } |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
817 // 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
|
818 // thus need to find original index |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
819 boolean sanity = false; |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
820 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
|
821 if (changelogRevisionIndex[i] == cs.getRevisionIndex()) { |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
822 rv[i] = cs; |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
823 sanity = true; |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
824 break; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
825 } |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
826 } |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
827 if (!sanity) { |
490
b3c16d1aede0
Refactoring: move HgRepository's implementation aspects to Internals (which is now its imlementation counterpart and primary repository class to be used by other parts of the library)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
457
diff
changeset
|
828 repo.getSessionContext().getLog().dump(getClass(), Error, "Index of revision %d:%s doesn't match any of requested", cs.getRevisionIndex(), cs.getNodeid().shortNotation()); |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
829 } |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
830 assert sanity; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
831 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
832 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
833 return rv; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
834 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
835 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
836 // init only when needed |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
837 void initTransform() throws HgRuntimeException { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
838 if (transform == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
839 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
|
840 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
841 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
842 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
843 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
|
844 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
|
845 populate(cs.clone()); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
846 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
847 |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
848 public Nodeid changesetRevision() { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
849 if (changesetRevision == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
850 changesetRevision = getRevision(historyNode.changeset); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
851 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
852 return changesetRevision; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
853 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
854 |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
855 public Pair<Nodeid, Nodeid> parentRevisions() { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
856 if (parentRevisions == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
857 HistoryNode p; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
858 final Nodeid p1, p2; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
859 if ((p = historyNode.parent1) != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
860 p1 = getRevision(p.changeset); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
861 } else { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
862 p1 = Nodeid.NULL;; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
863 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
864 if ((p = historyNode.parent2) != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
865 p2 = getRevision(p.changeset); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
866 } else { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
867 p2 = Nodeid.NULL; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
868 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
869 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
|
870 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
871 return parentRevisions; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
872 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
873 |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
874 public Collection<Nodeid> childRevisions() { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
875 if (childRevisions != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
876 return childRevisions; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
877 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
878 if (historyNode.children == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
879 childRevisions = Collections.emptyList(); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
880 } else { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
881 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
|
882 for (HistoryNode hn : historyNode.children) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
883 rv.add(getRevision(hn.changeset)); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
884 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
885 childRevisions = Collections.unmodifiableList(rv); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
886 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
887 return childRevisions; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
888 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
889 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
890 // reading nodeid involves reading index only, guess, can afford not to optimize multiple reads |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
891 private Nodeid getRevision(int changelogRevisionNumber) { |
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
419
diff
changeset
|
892 // 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
|
893 HgChangeset cs = cachedChangesets.get(changelogRevisionNumber); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
894 if (cs != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
895 return cs.getNodeid(); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
896 } else { |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
897 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
|
898 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
899 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
900 } |
510
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
901 |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
902 private enum IterateDirection { |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
903 FromOldToNew, FromNewToOld |
90093ee56c0d
Full-fledged test repo to follow file history. Investigating iteration direction alternatives (from new to old in addition to existing old to new)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
509
diff
changeset
|
904 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
905 } |