Mercurial > hg4j
annotate src/org/tmatesoft/hg/core/HgLogCommand.java @ 699:a483b2b68a2e
Provisional APIs and respective implementation for http, https and ssh remote repositories
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 08 Aug 2013 19:18:50 +0200 |
parents | e970b333f284 |
children |
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 /* |
565
78a9e26e670d
Refactor common code to initialize changelog revision for a command into standalone class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
2 s * Copyright (c) 2011-2013 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 |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
19 import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
70
diff
changeset
|
20 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
|
21 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
|
22 |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
23 import java.util.ArrayList; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
24 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
|
25 import java.util.Calendar; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
26 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
|
27 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
|
28 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
|
29 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
|
30 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
|
31 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
|
32 import java.util.List; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
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 |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
36 import org.tmatesoft.hg.internal.AdapterPlug; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
37 import org.tmatesoft.hg.internal.BatchRangeHelper; |
565
78a9e26e670d
Refactor common code to initialize changelog revision for a command into standalone class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
38 import org.tmatesoft.hg.internal.CsetParamKeeper; |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
39 import org.tmatesoft.hg.internal.FileRenameHistory; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
40 import org.tmatesoft.hg.internal.FileRenameHistory.Chunk; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
41 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
|
42 import org.tmatesoft.hg.internal.IntVector; |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
522
diff
changeset
|
43 import org.tmatesoft.hg.internal.Internals; |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
44 import org.tmatesoft.hg.internal.Lifecycle; |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
45 import org.tmatesoft.hg.internal.LifecycleProxy; |
596
43cfa08ff3fd
HgBlameFacility refactoring: extract code to build file history that spans renames
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
571
diff
changeset
|
46 import org.tmatesoft.hg.internal.ReverseIterator; |
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
|
47 import org.tmatesoft.hg.repo.HgChangelog; |
154
ba2bf656f00f
Changeset => RawChangeset
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
148
diff
changeset
|
48 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
49 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
|
50 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
|
51 import org.tmatesoft.hg.repo.HgParentChildMap; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
70
diff
changeset
|
52 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
|
53 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
|
54 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
|
55 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
|
56 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
|
57 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
|
58 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
|
59 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
|
60 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
|
61 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
62 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
63 /** |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
64 * 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
|
65 * |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
66 * <pre> |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
67 * Usage: |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
64
diff
changeset
|
68 * 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
|
69 * </pre> |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
70 * 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
|
71 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
72 * @author Artem Tikhomirov |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
73 * @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
|
74 */ |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
75 public class HgLogCommand extends HgAbstractCommand<HgLogCommand> { |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
76 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
77 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
|
78 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
|
79 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
|
80 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
|
81 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
|
82 private Calendar date; |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
83 private Path file; |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
84 /* |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
85 * 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
|
86 * 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
|
87 */ |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
88 private boolean followRenames; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
89 /* |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
90 * 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
|
91 * 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
|
92 * 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
|
93 */ |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
94 private boolean followAncestry; |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
95 |
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
96 private HgIterateDirection iterateDirection = HgIterateDirection.OldToNew; |
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
97 |
193
37f3d4a596e4
Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
98 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
|
99 private HgParentChildMap<HgChangelog> parentHelper; |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
100 |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
101 public HgLogCommand(HgRepository hgRepo) { |
107 | 102 repo = hgRepo; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
103 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
104 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
105 /** |
148
1a7a9a20e1f9
Exceptions, javadoc. Initial cancel and progress support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
142
diff
changeset
|
106 * 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
|
107 * 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
|
108 * @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
|
109 * @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
|
110 * @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
|
111 */ |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
112 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
|
113 if (user == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
114 throw new IllegalArgumentException(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
115 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
116 if (users == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
117 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
|
118 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
119 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
|
120 return this; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
121 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
122 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
123 /** |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
124 * 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
|
125 * 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
|
126 * 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
|
127 * @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
|
128 * @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
|
129 * @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
|
130 */ |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
131 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
|
132 if (branch == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
133 throw new IllegalArgumentException(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
134 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
135 if (branches == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
136 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
|
137 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
138 branches.add(branch); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
139 return this; |
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 // 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
|
143 // multiple? |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
144 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
|
145 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
|
146 // 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
|
147 // isSet(field) - false => don't use in detection of 'same date' |
526
2f9ed6bcefa2
Initial support for Revert command with accompanying minor refactoring
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
522
diff
changeset
|
148 throw Internals.notImplemented(); |
64
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 * |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
153 * @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
|
154 * @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
|
155 */ |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
156 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
|
157 limit = num; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
158 return this; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
159 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
160 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
161 /** |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
162 * 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
|
163 * 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
|
164 * |
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
|
165 * @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
|
166 * @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
|
167 * @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
|
168 */ |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
169 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
|
170 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
|
171 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
|
172 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
|
173 } 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
|
174 startRev = rev2; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
175 endRev = rev1; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
176 } else { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
177 startRev = rev1; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
178 endRev = rev2; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
179 } |
565
78a9e26e670d
Refactor common code to initialize changelog revision for a command into standalone class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
180 // TODO [2.0 API break] shall throw HgBadArgumentException, like other commands do |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
181 return this; |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
182 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
183 |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
184 /** |
683
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
185 * Limit history to specified range. |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
186 * |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
187 * @see #range(int, int) |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
188 * @param cset1 range start revision |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
189 * @param cset2 range end revision |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
190 * @return <code>this</code> instance for convenience |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
191 * @throws HgBadArgumentException if revisions are not valid changeset identifiers |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
192 */ |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
193 public HgLogCommand range(Nodeid cset1, Nodeid cset2) throws HgBadArgumentException { |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
194 CsetParamKeeper pk = new CsetParamKeeper(repo); |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
195 int r1 = pk.set(cset1).get(); |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
196 int r2 = pk.set(cset2).get(); |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
197 return range(r1, r2); |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
198 } |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
199 |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
200 /** |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
201 * Select specific changeset by index |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
202 * @see #changeset(Nodeid) |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
203 * @param revisionIndex index of changelog revision |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
204 * @return <code>this</code> for convenience |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
205 * @throws HgBadArgumentException if failed to find supplied changeset revision |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
206 */ |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
207 public HgLogCommand changeset(int revisionIndex) throws HgBadArgumentException { |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
208 int ri = new CsetParamKeeper(repo).set(revisionIndex).get(); |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
209 return range(ri, ri); |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
210 } |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
211 |
98ff1fb49abe
Update commands to use changeset Nodeid and int in uniform way, clients of core.* classes shall not go back and forth from int to Nodeid
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
628
diff
changeset
|
212 /** |
253
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
213 * Select specific changeset |
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
214 * |
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
215 * @param nid changeset revision |
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
216 * @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
|
217 * @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
|
218 */ |
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
|
219 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
|
220 // XXX perhaps, shall support multiple (...) arguments and extend #execute to handle not only range, but also set of revisions. |
565
78a9e26e670d
Refactor common code to initialize changelog revision for a command into standalone class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
221 final int csetRevIndex = new CsetParamKeeper(repo).set(nid).get(); |
78a9e26e670d
Refactor common code to initialize changelog revision for a command into standalone class
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
559
diff
changeset
|
222 return range(csetRevIndex, csetRevIndex); |
253
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
223 } |
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
224 |
1874d11054e5
HgLogCommand.changeset(Nodeid) to ease command configuration
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
250
diff
changeset
|
225 /** |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
226 * Visit history of a given file only. Note, unlike native <code>hg log</code> command argument <code>--follow</code>, this method doesn't |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
227 * follow file ancestry, but reports complete file history (with <code>followCopyRenames == true</code>, for each |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
228 * name of the file known in sequence). To achieve output similar to that of <code>hg log --follow filePath</code>, use |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
229 * {@link #file(Path, boolean, boolean) file(filePath, true, true)} alternative. |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
230 * |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
231 * @param filePath path relative to repository root. Pass <code>null</code> to reset. |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
232 * @param followCopyRename true to report changesets of the original file(-s), if copy/rename ever occured to the file. |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
233 * @return <code>this</code> for convenience |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
234 */ |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
235 public HgLogCommand file(Path filePath, boolean followCopyRename) { |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
236 return file(filePath, followCopyRename, false); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
237 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
238 |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
239 /** |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
240 * Full control over file history iteration. |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
241 * |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
242 * @param filePath path relative to repository root. Pass <code>null</code> to reset. |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
243 * @param followCopyRename true to report changesets of the original file(-s), if copy/rename ever occured to the file. |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
244 * @param followFileAncestry true to follow file history starting from revision at working copy parent. Note, only revisions |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
245 * accessible (i.e. on direct parent line) from the selected one will be reported. This is how <code>hg log --follow filePath</code> |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
246 * behaves, with the difference that this method allows separate control whether to follow renames or not. |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
247 * |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
248 * @return <code>this</code> for convenience |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
249 */ |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
250 public HgLogCommand file(Path filePath, boolean followCopyRename, boolean followFileAncestry) { |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
251 file = filePath; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
252 followRenames = followCopyRename; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
253 followAncestry = followFileAncestry; |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
254 return this; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
255 } |
142
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
256 |
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
257 /** |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
258 * Handy analog to {@link #file(Path, boolean)} when clients' paths come from filesystem and need conversion to repository's |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
259 * @return <code>this</code> for convenience |
142
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
260 */ |
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
261 public HgLogCommand file(String file, boolean followCopyRename) { |
571
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
262 Path.Source ps = repo.getSessionContext().getPathFactory(); |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
263 return file(ps.path(repo.getToRepoPathHelper().rewrite(file)), followCopyRename); |
142
37a34044e6bd
More reasonable use of path normalizer and path.source
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
264 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
265 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
266 /** |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
267 * Handy analog to {@link #file(Path, boolean, boolean)} when clients' paths come from filesystem and need conversion to repository's |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
268 * @return <code>this</code> for convenience |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
269 */ |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
270 public HgLogCommand file(String file, boolean followCopyRename, boolean followFileAncestry) { |
571
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
271 Path.Source ps = repo.getSessionContext().getPathFactory(); |
e4ee4bf4c7d0
Let session context control creation of Path instances
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
565
diff
changeset
|
272 return file(ps.path(repo.getToRepoPathHelper().rewrite(file)), followCopyRename, followFileAncestry); |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
273 } |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
274 |
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
275 /** |
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
276 * Specifies order for changesets reported through #execute(...) methods. |
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
277 * By default, command reports changeset in their natural repository order, older first, |
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
278 * newer last (i.e. {@link HgIterateDirection#OldToNew} |
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
279 * |
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
280 * @param order {@link HgIterateDirection#NewToOld} to get newer revisions first |
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
281 * @return <code>this</code> for convenience |
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
282 */ |
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
283 public HgLogCommand order(HgIterateDirection order) { |
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
284 iterateDirection = order; |
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
285 return this; |
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
286 } |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
287 |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
288 /** |
419
7f136a3fa671
Clean javadoc to fix obvious warnings
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
418
diff
changeset
|
289 * 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
|
290 * |
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 * @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
|
292 * @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
|
293 */ |
396
0ae53c32ecef
Straighten out exceptions thrown when file access failed - three is too much
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
383
diff
changeset
|
294 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
|
295 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
|
296 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
|
297 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
|
298 } 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
|
299 // 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
|
300 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
|
301 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
|
302 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
|
303 } 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
|
304 // 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
|
305 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
|
306 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
|
307 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
|
308 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
309 return collector.getChanges(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
310 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
311 |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
312 /** |
402
1fcc7f7b6d65
FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
396
diff
changeset
|
313 * 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
|
314 * |
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
|
315 * @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
|
316 * @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
|
317 * @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
|
318 * @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
|
319 * @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
|
320 * @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
|
321 */ |
370
a2341e761609
Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
322 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
|
323 if (handler == null) { |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
324 throw new IllegalArgumentException(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
325 } |
193
37f3d4a596e4
Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
326 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
|
327 throw new ConcurrentModificationException(); |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
328 } |
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
|
329 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
|
330 try { |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
331 if (repo.getChangelog().getRevisionCount() == 0) { |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
332 return; |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
333 } |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
334 final int firstCset = startRev; |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
335 final int lastCset = endRev == TIP ? repo.getChangelog().getLastRevision() : endRev; |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
336 // XXX pretty much like HgInternals.checkRevlogRange |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
337 if (lastCset < 0 || lastCset > repo.getChangelog().getLastRevision()) { |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
338 throw new HgBadArgumentException(String.format("Bad value %d for end revision", lastCset), null); |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
339 } |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
340 if (firstCset < 0 || firstCset > lastCset) { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
341 throw new HgBadArgumentException(String.format("Bad value %d for start revision for range [%1$d..%d]", firstCset, lastCset), null); |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
342 } |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
343 final int BATCH_SIZE = 100; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
344 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
|
345 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
|
346 // 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
|
347 // 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
|
348 csetTransform = new ChangesetTransformer(repo, handler, pw, progressHelper, getCancelSupport(handler, true)); |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
349 // FilteringInspector is responsible to check command arguments: users, branches, limit, etc. |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
350 // prior to passing cset to next Inspector, which is either (a) collector to reverse cset order, then invokes |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
351 // transformer from (b), below, with alternative cset order or (b) transformer to hi-level csets. |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
352 FilteringInspector filterInsp = new FilteringInspector(); |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
353 filterInsp.changesets(firstCset, lastCset); |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
354 if (file == null) { |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
355 progressHelper.start(lastCset - firstCset + 1); |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
356 if (iterateDirection == HgIterateDirection.OldToNew) { |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
357 filterInsp.delegateTo(csetTransform); |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
358 repo.getChangelog().range(firstCset, lastCset, filterInsp); |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
359 csetTransform.checkFailure(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
360 } else { |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
361 assert iterateDirection == HgIterateDirection.NewToOld; |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
362 BatchRangeHelper brh = new BatchRangeHelper(firstCset, lastCset, BATCH_SIZE, true); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
363 BatchChangesetInspector batchInspector = new BatchChangesetInspector(Math.min(lastCset-firstCset+1, BATCH_SIZE)); |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
364 filterInsp.delegateTo(batchInspector); |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
365 // XXX this batching code is bit verbose, refactor |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
366 while (brh.hasNext()) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
367 brh.next(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
368 repo.getChangelog().range(brh.start(), brh.end(), filterInsp); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
369 for (BatchChangesetInspector.BatchRecord br : batchInspector.iterate(true)) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
370 csetTransform.next(br.csetIndex, br.csetRevision, br.cset); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
371 csetTransform.checkFailure(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
372 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
373 batchInspector.reset(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
374 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
375 } |
77
c677e1593919
Moved RevlogStream implementation into .internal
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
376 } else { |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
377 filterInsp.delegateTo(csetTransform); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
378 final HgFileRenameHandlerMixin withCopyHandler = Adaptable.Factory.getAdapter(handler, HgFileRenameHandlerMixin.class, null); |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
379 FileRenameQueueBuilder frqBuilder = new FileRenameQueueBuilder(); |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
380 List<QueueElement> fileRenames = frqBuilder.buildFileRenamesQueue(firstCset, lastCset); |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
381 progressHelper.start(fileRenames.size()); |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
382 for (int nameIndex = 0, fileRenamesSize = fileRenames.size(); nameIndex < fileRenamesSize; nameIndex++) { |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
383 QueueElement curRename = fileRenames.get(nameIndex); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
384 HgDataFile fileNode = curRename.file(); |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
385 if (followAncestry) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
386 TreeBuildInspector treeBuilder = new TreeBuildInspector(followAncestry); |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
387 @SuppressWarnings("unused") |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
388 List<HistoryNode> fileAncestry = treeBuilder.go(curRename); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
389 int[] commitRevisions = narrowChangesetRange(treeBuilder.getCommitRevisions(), firstCset, lastCset); |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
390 if (iterateDirection == HgIterateDirection.OldToNew) { |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
391 repo.getChangelog().range(filterInsp, commitRevisions); |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
392 csetTransform.checkFailure(); |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
393 } else { |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
394 assert iterateDirection == HgIterateDirection.NewToOld; |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
395 // visit one by one in the opposite direction |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
396 for (int i = commitRevisions.length-1; i >= 0; i--) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
397 int csetWithFileChange = commitRevisions[i]; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
398 repo.getChangelog().range(csetWithFileChange, csetWithFileChange, filterInsp); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
399 } |
126
b92a638764be
Dispatch chnagesets even if Handler is not FileHistoryHandler
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
107
diff
changeset
|
400 } |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
401 } else { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
402 // report complete file history (XXX may narrow range with [startRev, endRev], but need to go from file rev to link rev) |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
403 int fileStartRev = curRename.fileFrom(); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
404 int fileEndRev = curRename.file().getLastRevision(); //curRename.fileTo(); |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
405 if (iterateDirection == HgIterateDirection.OldToNew) { |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
406 fileNode.history(fileStartRev, fileEndRev, filterInsp); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
407 csetTransform.checkFailure(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
408 } else { |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
409 assert iterateDirection == HgIterateDirection.NewToOld; |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
410 BatchRangeHelper brh = new BatchRangeHelper(fileStartRev, fileEndRev, BATCH_SIZE, true); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
411 BatchChangesetInspector batchInspector = new BatchChangesetInspector(Math.min(fileEndRev-fileStartRev+1, BATCH_SIZE)); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
412 filterInsp.delegateTo(batchInspector); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
413 while (brh.hasNext()) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
414 brh.next(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
415 fileNode.history(brh.start(), brh.end(), filterInsp); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
416 for (BatchChangesetInspector.BatchRecord br : batchInspector.iterate(true /*iterateDirection == IterateDirection.FromNewToOld*/)) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
417 csetTransform.next(br.csetIndex, br.csetRevision, br.cset); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
418 csetTransform.checkFailure(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
419 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
420 batchInspector.reset(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
421 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
422 } |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
423 } |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
424 if (withCopyHandler != null && nameIndex + 1 < fileRenamesSize) { |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
425 QueueElement nextRename = fileRenames.get(nameIndex+1); |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
426 HgFileRevision src, dst; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
427 // A -> B |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
428 if (iterateDirection == HgIterateDirection.OldToNew) { |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
429 // curRename: A, nextRename: B |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
430 src = curRename.last(); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
431 dst = nextRename.first(src); |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
432 } else { |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
433 assert iterateDirection == HgIterateDirection.NewToOld; |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
434 // curRename: B, nextRename: A |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
435 src = nextRename.last(); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
436 dst = curRename.first(src); |
80
4222b04f34ee
Follow history of a file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
77
diff
changeset
|
437 } |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
438 withCopyHandler.copy(src, dst); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
439 } |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
440 progressHelper.worked(1); |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
441 } // for renames |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
442 frqBuilder.reportRenameIfNotInQueue(fileRenames, withCopyHandler); |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
443 } // file != null |
427
31a89587eb04
FIXMEs: consistent names, throws for commands and their handlers. Use of checked exceptions in hi-level api
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
424
diff
changeset
|
444 } 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
|
445 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
|
446 } finally { |
193
37f3d4a596e4
Use common low to hi-level changeset api transformer
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
157
diff
changeset
|
447 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
|
448 progressHelper.done(); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
449 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
450 } |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
451 |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
452 private static class BatchChangesetInspector extends AdapterPlug implements HgChangelog.Inspector { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
453 private static class BatchRecord { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
454 public final int csetIndex; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
455 public final Nodeid csetRevision; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
456 public final RawChangeset cset; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
457 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
458 public BatchRecord(int index, Nodeid nodeid, RawChangeset changeset) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
459 csetIndex = index; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
460 csetRevision = nodeid; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
461 cset = changeset; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
462 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
463 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
464 private final ArrayList<BatchRecord> batch; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
465 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
466 public BatchChangesetInspector(int batchSizeHint) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
467 batch = new ArrayList<BatchRecord>(batchSizeHint); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
468 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
469 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
470 public BatchChangesetInspector reset() { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
471 batch.clear(); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
472 return this; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
473 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
474 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
475 public void next(int revisionIndex, Nodeid nodeid, RawChangeset cset) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
476 batch.add(new BatchRecord(revisionIndex, nodeid, cset.clone())); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
477 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
478 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
479 public Iterable<BatchRecord> iterate(final boolean reverse) { |
596
43cfa08ff3fd
HgBlameFacility refactoring: extract code to build file history that spans renames
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
571
diff
changeset
|
480 return reverse ? ReverseIterator.reversed(batch) : batch; |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
481 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
482 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
483 // alternative would be dispatch(HgChangelog.Inspector) and dispatchReverse() |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
484 // methods, but progress and cancellation might get messy then |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
485 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
486 |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
487 // public static void main(String[] args) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
488 // int[] r = new int[] {17, 19, 21, 23, 25, 29}; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
489 // System.out.println(Arrays.toString(narrowChangesetRange(r, 0, 45))); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
490 // System.out.println(Arrays.toString(narrowChangesetRange(r, 0, 25))); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
491 // System.out.println(Arrays.toString(narrowChangesetRange(r, 5, 26))); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
492 // System.out.println(Arrays.toString(narrowChangesetRange(r, 20, 26))); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
493 // System.out.println(Arrays.toString(narrowChangesetRange(r, 26, 28))); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
494 // } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
495 |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
496 private static int[] narrowChangesetRange(int[] csetRange, int startCset, int endCset) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
497 int lastInRange = csetRange[csetRange.length-1]; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
498 assert csetRange.length < 2 || csetRange[0] < lastInRange; // sorted |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
499 assert startCset >= 0 && startCset <= endCset; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
500 if (csetRange[0] >= startCset && lastInRange <= endCset) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
501 // completely fits in |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
502 return csetRange; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
503 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
504 if (csetRange[0] > endCset || lastInRange < startCset) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
505 return new int[0]; // trivial |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
506 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
507 int i = 0; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
508 while (i < csetRange.length && csetRange[i] < startCset) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
509 i++; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
510 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
511 int j = csetRange.length - 1; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
512 while (j > i && csetRange[j] > endCset) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
513 j--; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
514 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
515 if (i == j) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
516 // no values in csetRange fit into [startCset, endCset] |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
517 return new int[0]; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
518 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
519 int[] rv = new int[j-i+1]; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
520 System.arraycopy(csetRange, i, rv, 0, rv.length); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
521 return rv; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
522 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
523 |
370
a2341e761609
Let callback implementations deliver errors (e,g. own exceptions) to client code
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
368
diff
changeset
|
524 /** |
515
e6c8b9b654b2
Provide access to HgDataFile being iterated into HgChangesetTreeHandler.TreeElement to give context for renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
525 * Tree-wise iteration of a file history, with handy access to parent-child relations between changesets. |
e6c8b9b654b2
Provide access to HgDataFile being iterated into HgChangesetTreeHandler.TreeElement to give context for renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
526 * When file history is being followed, handler may additionally implement {@link HgFileRenameHandlerMixin} |
e6c8b9b654b2
Provide access to HgDataFile being iterated into HgChangesetTreeHandler.TreeElement to give context for renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
527 * to get notified about switching between history chunks that belong to different names. |
402
1fcc7f7b6d65
FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
396
diff
changeset
|
528 * |
1fcc7f7b6d65
FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
396
diff
changeset
|
529 * @param handler callback to process changesets. |
515
e6c8b9b654b2
Provide access to HgDataFile being iterated into HgChangesetTreeHandler.TreeElement to give context for renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
530 * @see HgFileRenameHandlerMixin |
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
|
531 * @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
|
532 * @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
|
533 * @throws CancelledException if execution of the command was cancelled |
402
1fcc7f7b6d65
FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
396
diff
changeset
|
534 * @throws IllegalArgumentException if command is not satisfied with its arguments |
1fcc7f7b6d65
FIXMEs/javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
396
diff
changeset
|
535 * @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
|
536 */ |
515
e6c8b9b654b2
Provide access to HgDataFile being iterated into HgChangesetTreeHandler.TreeElement to give context for renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
537 public void execute(final 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
|
538 if (handler == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
539 throw new IllegalArgumentException(); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
540 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
541 if (csetTransform != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
542 throw new ConcurrentModificationException(); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
543 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
544 if (file == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
545 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
|
546 } |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
547 final int firstCset = startRev; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
548 final int lastCset = endRev == TIP ? repo.getChangelog().getLastRevision() : endRev; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
549 // XXX pretty much like HgInternals.checkRevlogRange |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
550 if (lastCset < 0 || lastCset > repo.getChangelog().getLastRevision()) { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
551 throw new HgBadArgumentException(String.format("Bad value %d for end revision", lastCset), null); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
552 } |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
553 if (firstCset < 0 || startRev > lastCset) { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
554 throw new HgBadArgumentException(String.format("Bad value %d for start revision for range [%1$d..%d]", startRev, lastCset), null); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
555 } |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
556 final ProgressSupport progressHelper = getProgressSupport(handler); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
557 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
|
558 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
|
559 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
560 try { |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
561 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
562 // XXX rename. dispatcher is not a proper name (most of the job done - managing history chunk interconnection) |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
563 final HandlerDispatcher dispatcher = new HandlerDispatcher() { |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
564 |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
565 @Override |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
566 protected void once(HistoryNode n) throws HgCallbackTargetException, CancelledException, HgRuntimeException { |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
567 handler.treeElement(ei.init(n, currentFileNode)); |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
568 cancelHelper.checkCancelled(); |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
569 } |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
570 }; |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
571 |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
572 // renamed files in the queue are placed with respect to #iterateDirection |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
573 // i.e. if we iterate from new to old, recent filenames come first |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
574 FileRenameQueueBuilder frqBuilder = new FileRenameQueueBuilder(); |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
575 List<QueueElement> fileRenamesQueue = frqBuilder.buildFileRenamesQueue(firstCset, lastCset); |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
576 // XXX perhaps, makes sense to look at selected file's revision when followAncestry is true |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
577 // to ensure file we attempt to trace is in the WC's parent. Native hg aborts if not. |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
578 progressHelper.start(4 * fileRenamesQueue.size()); |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
579 for (int namesIndex = 0, renamesQueueSize = fileRenamesQueue.size(); namesIndex < renamesQueueSize; namesIndex++) { |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
580 |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
581 final QueueElement renameInfo = fileRenamesQueue.get(namesIndex); |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
582 dispatcher.prepare(progressHelper, renameInfo); |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
583 cancelHelper.checkCancelled(); |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
584 if (namesIndex > 0) { |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
585 dispatcher.connectWithLastJunctionPoint(renameInfo, fileRenamesQueue.get(namesIndex - 1)); |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
586 } |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
587 if (namesIndex + 1 < renamesQueueSize) { |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
588 // there's at least one more name we are going to look at |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
589 dispatcher.updateJunctionPoint(renameInfo, fileRenamesQueue.get(namesIndex+1), renameHandler != null); |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
590 } else { |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
591 dispatcher.clearJunctionPoint(); |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
592 } |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
593 dispatcher.dispatchAllChanges(); |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
594 if (renameHandler != null && namesIndex + 1 < renamesQueueSize) { |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
595 dispatcher.reportRenames(renameHandler); |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
596 } |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
597 } // for fileRenamesQueue; |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
598 frqBuilder.reportRenameIfNotInQueue(fileRenamesQueue, renameHandler); |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
599 } catch (HgRuntimeException ex) { |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
600 throw new HgLibraryFailureException(ex); |
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
601 } |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
602 progressHelper.done(); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
603 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
604 |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
605 private static class QueueElement { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
606 private final HgDataFile df; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
607 private final Nodeid lastRev; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
608 private final int firstRevIndex, lastRevIndex; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
609 |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
610 QueueElement(HgDataFile file, Nodeid fileLastRev) { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
611 df = file; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
612 lastRev = fileLastRev; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
613 firstRevIndex = 0; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
614 lastRevIndex = lastRev == null ? df.getLastRevision() : df.getRevisionIndex(lastRev); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
615 } |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
616 QueueElement(HgDataFile file, int firstFileRev, int lastFileRev) { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
617 df = file; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
618 firstRevIndex = firstFileRev; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
619 lastRevIndex = lastFileRev; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
620 lastRev = null; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
621 } |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
622 HgDataFile file() { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
623 return df; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
624 } |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
625 int fileFrom() { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
626 return firstRevIndex; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
627 } |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
628 int fileTo() { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
629 return lastRevIndex; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
630 } |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
631 // never null |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
632 Nodeid lastFileRev() { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
633 return lastRev == null ? df.getRevision(fileTo()) : lastRev; |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
634 } |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
635 HgFileRevision last() { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
636 return new HgFileRevision(df, lastFileRev(), null); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
637 } |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
638 HgFileRevision first(HgFileRevision from) { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
639 return new HgFileRevision(df, df.getRevision(0), from.getPath()); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
640 } |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
641 } |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
642 |
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
|
643 /** |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
644 * Utility to build sequence of file renames |
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
|
645 */ |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
646 private class FileRenameQueueBuilder { |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
647 |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
648 /** |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
649 * Follows file renames and build a list of all corresponding file nodes and revisions they were |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
650 * copied/renamed/branched at (IOW, their latest revision to look at). |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
651 * |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
652 * @param followRename when <code>false</code>, the list contains one element only, |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
653 * file node with the name of the file as it was specified by the user. |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
654 * |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
655 * @param followAncestry the most recent file revision reported depends on this parameter, |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
656 * and it is file revision from working copy parent in there when it's true. |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
657 * <code>null</code> as Pair's second indicates file's TIP revision shall be used. |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
658 * |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
659 * TODO may use HgFileRevision (after some refactoring to accept HgDataFile and Nodeid) instead of Pair |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
660 * and possibly reuse this functionality |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
661 * |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
662 * @return list of file renames, ordered with respect to {@link #iterateDirection} |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
663 * @throws HgRuntimeException |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
664 */ |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
665 public List<QueueElement> buildFileRenamesQueue(int csetStart, int csetEnd) throws HgPathNotFoundException, HgRuntimeException { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
666 LinkedList<QueueElement> rv = new LinkedList<QueueElement>(); |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
667 Nodeid startRev = null; |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
668 HgDataFile fileNode = repo.getFileNode(file); |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
669 if (!fileNode.exists()) { |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
670 throw new HgPathNotFoundException(String.format("File %s not found in the repository", file), file); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
671 } |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
672 if (followAncestry) { |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
673 // TODO subject to dedicated method either in HgRepository (getWorkingCopyParentRevisionIndex) |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
674 // or in the HgDataFile (getWorkingCopyOriginRevision) |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
675 Nodeid wdParentChangeset = repo.getWorkingCopyParents().first(); |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
676 if (!wdParentChangeset.isNull()) { |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
677 int wdParentRevIndex = repo.getChangelog().getRevisionIndex(wdParentChangeset); |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
678 startRev = repo.getManifest().getFileRevision(wdParentRevIndex, fileNode.getPath()); |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
679 } |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
680 // else fall-through, assume null (eventually, lastRevision()) is ok here |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
681 } |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
682 QueueElement p = new QueueElement(fileNode, startRev); |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
683 if (!followRenames) { |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
684 rv.add(p); |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
685 return rv; |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
686 } |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
687 FileRenameHistory frh = new FileRenameHistory(csetStart, csetEnd); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
688 frh.build(fileNode, p.fileTo()); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
689 for (Chunk c : frh.iterate(iterateDirection)) { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
690 rv.add(new QueueElement(c.file(), c.firstFileRev(), c.lastFileRev())); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
691 } |
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
|
692 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
|
693 } |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
694 |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
695 /** |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
696 * Shall report renames based solely on HgFileRenameHandlerMixin presence, |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
697 * even if queue didn't get rename information due to followRenames == false |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
698 * |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
699 * @param queue value from {@link #buildFileRenamesQueue()} |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
700 * @param renameHandler may be <code>null</code> |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
701 */ |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
702 public void reportRenameIfNotInQueue(List<QueueElement> queue, HgFileRenameHandlerMixin renameHandler) throws HgCallbackTargetException, HgRuntimeException { |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
703 if (renameHandler != null && !followRenames) { |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
704 // If followRenames is true, all the historical names were in the queue and are processed already. |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
705 // Hence, shall process origin explicitly only when renameHandler is present but followRenames is not requested. |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
706 assert queue.size() == 1; // see the way queue is constructed above |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
707 QueueElement curRename = queue.get(0); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
708 if (curRename.file().isCopy(curRename.fileFrom())) { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
709 final HgFileRevision src = curRename.file().getCopySource(curRename.fileFrom()); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
710 HgFileRevision dst = curRename.first(src); |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
711 renameHandler.copy(src, dst); |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
712 } |
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
|
713 } |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
714 } |
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
|
715 } |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
716 |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
717 /** |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
718 * Builds list of {@link HistoryNode HistoryNodes} to visit for a given chunk of file rename history |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
719 */ |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
720 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
|
721 private final boolean followAncestry; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
722 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
723 private HistoryNode[] completeHistory; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
724 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
|
725 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
|
726 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
727 TreeBuildInspector(boolean _followAncestry) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
728 followAncestry = _followAncestry; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
729 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
730 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
731 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
|
732 commitRevisions[revisionNumber] = linkedRevision; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
733 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
734 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
735 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
|
736 HistoryNode p1 = null, p2 = null; |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
737 // IMPORTANT: method #one(), below, doesn't expect this code expects reasonable values at parent indexes |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
738 if (parent1 != -1) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
739 p1 = completeHistory[parent1]; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
740 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
741 if (parent2!= -1) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
742 p2 = completeHistory[parent2]; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
743 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
744 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
|
745 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
746 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
747 HistoryNode one(HgDataFile fileNode, Nodeid fileRevision) throws HgRuntimeException { |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
748 int fileRevIndexToVisit = fileNode.getRevisionIndex(fileRevision); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
749 return one(fileNode, fileRevIndexToVisit); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
750 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
751 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
752 HistoryNode one(HgDataFile fileNode, int fileRevIndexToVisit) throws HgRuntimeException { |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
753 resultHistory = null; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
754 if (fileRevIndexToVisit == HgRepository.TIP) { |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
755 fileRevIndexToVisit = fileNode.getLastRevision(); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
756 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
757 // still, allocate whole array, for #next to be able to get null parent values |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
758 completeHistory = new HistoryNode[fileRevIndexToVisit+1]; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
759 commitRevisions = new int[completeHistory.length]; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
760 fileNode.indexWalk(fileRevIndexToVisit, fileRevIndexToVisit, this); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
761 // it's only single revision, no need to care about followAncestry |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
762 // but won't hurt to keep resultHistory != null and commitRevisions initialized just in case |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
763 HistoryNode rv = completeHistory[fileRevIndexToVisit]; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
764 commitRevisions = new int[] { commitRevisions[fileRevIndexToVisit] }; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
765 completeHistory = null; // no need to keep almost empty array in memory |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
766 resultHistory = Collections.singletonList(rv); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
767 return rv; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
768 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
769 |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
770 /** |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
771 * FIXME pretty much the same as FileRevisionHistoryChunk |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
772 * |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
773 * 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
|
774 * 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
|
775 * 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
|
776 * |
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
|
777 * @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
|
778 * 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
|
779 */ |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
780 List<HistoryNode> go(QueueElement qe) throws HgRuntimeException { |
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
|
781 resultHistory = null; |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
782 HgDataFile fileNode = qe.file(); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
783 // TODO int fileLastRevIndexToVisit = qe.fileTo |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
784 int fileLastRevIndexToVisit = followAncestry ? fileNode.getRevisionIndex(qe.lastFileRev()) : fileNode.getLastRevision(); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
511
diff
changeset
|
785 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
|
786 commitRevisions = new int[completeHistory.length]; |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
787 fileNode.indexWalk(qe.fileFrom(), fileLastRevIndexToVisit, this); |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
788 if (!followAncestry) { |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
789 resultHistory = new ArrayList<HistoryNode>(fileLastRevIndexToVisit - qe.fileFrom() + 1); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
790 // items in completeHistory with index < qe.fileFrom are empty |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
791 for (int i = qe.fileFrom(); i <= fileLastRevIndexToVisit; i++) { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
792 resultHistory.add(completeHistory[i]); |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
793 } |
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
|
794 completeHistory = null; |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
795 commitRevisions = null; |
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
|
796 return resultHistory; |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
797 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
798 /* |
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
|
799 * 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
|
800 * 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
|
801 * | 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
|
802 * 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
|
803 * | 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
|
804 * |/ |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
805 * 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
|
806 * | |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
807 * 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
|
808 * |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
809 * 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
|
810 * |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
811 * 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
|
812 */ |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
813 // 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
|
814 // 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
|
815 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
|
816 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
|
817 // 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
|
818 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
|
819 do { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
820 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
|
821 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
|
822 // 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
|
823 // 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
|
824 continue; |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
825 } |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
826 if (withFileChange.children != null) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
827 withFileChange.children.retainAll(strippedHistoryList); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
828 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
829 strippedHistoryList.addFirst(withFileChange); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
830 if (withFileChange.parent1 != null) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
831 queue.addLast(withFileChange.parent1); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
832 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
833 if (withFileChange.parent2 != null) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
834 queue.addLast(withFileChange.parent2); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
835 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
836 } 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
|
837 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
|
838 |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
839 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
|
840 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
|
841 } |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
842 }); |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
843 completeHistory = null; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
844 commitRevisions = null; |
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
|
845 return resultHistory = strippedHistoryList; |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
846 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
847 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
848 /** |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
849 * 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
|
850 */ |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
851 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
|
852 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
|
853 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
|
854 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
|
855 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
|
856 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
|
857 } |
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
|
858 } |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
859 return commitRevisions; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
860 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
861 }; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
862 |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
863 /** |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
864 * Sends {@link ElementImpl} for each {@link HistoryNode}, and keeps track of junction points - revisions with renames |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
865 */ |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
866 private abstract class HandlerDispatcher { |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
867 private final int CACHE_CSET_IN_ADVANCE_THRESHOLD = 100; /* XXX is it really worth it? */ |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
868 // builds tree of nodes according to parents in file's revlog |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
869 private final TreeBuildInspector treeBuildInspector = new TreeBuildInspector(followAncestry); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
870 private List<HistoryNode> changeHistory; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
871 protected ElementImpl ei = null; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
872 private ProgressSupport progress; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
873 protected HgDataFile currentFileNode; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
874 // node where current file history chunk intersects with same file under other name history |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
875 // either mock of B(0) or A(k), depending on iteration order |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
876 private HistoryNode junctionNode; |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
877 // initialized when there's HgFileRenameHandlerMixin |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
878 private HgFileRevision copiedFrom, copiedTo; |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
879 |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
880 // parentProgress shall be initialized with 4 XXX refactor all this stuff with parentProgress |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
881 public void prepare(ProgressSupport parentProgress, QueueElement renameInfo) throws HgRuntimeException { |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
882 changeHistory = treeBuildInspector.go(renameInfo); |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
883 assert changeHistory.size() > 0; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
884 parentProgress.worked(1); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
885 int historyNodeCount = changeHistory.size(); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
886 if (ei == null) { |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
887 // when follow is true, changeHistory.size() of the first revision might be quite short |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
888 // (e.g. bad fname recognized soon), hence ensure at least cache size at once |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
889 ei = new ElementImpl(Math.max(CACHE_CSET_IN_ADVANCE_THRESHOLD, historyNodeCount)); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
890 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
891 if (historyNodeCount < CACHE_CSET_IN_ADVANCE_THRESHOLD ) { |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
892 int[] commitRevisions = treeBuildInspector.getCommitRevisions(); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
893 assert commitRevisions.length == changeHistory.size(); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
894 // read bunch of changesets at once and cache 'em |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
895 ei.initTransform(); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
896 repo.getChangelog().range(ei, commitRevisions); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
897 parentProgress.worked(1); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
898 progress = new ProgressSupport.Sub(parentProgress, 2); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
899 } else { |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
900 progress = new ProgressSupport.Sub(parentProgress, 3); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
901 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
902 progress.start(historyNodeCount); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
903 // switch to present chunk's file node |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
904 switchTo(renameInfo.file()); |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
905 } |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
906 |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
907 public void updateJunctionPoint(QueueElement curRename, QueueElement nextRename, boolean needCopyFromTo) throws HgRuntimeException { |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
908 copiedFrom = copiedTo = null; |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
909 // |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
910 // A (old) renamed to B(new). A(0..k..n) -> B(0..m). If followAncestry, k == n |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
911 // curRename.second() points to A(k) |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
912 if (iterateDirection == HgIterateDirection.OldToNew) { |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
913 // looking at A chunk (curRename), nextRename points to B |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
914 HistoryNode junctionSrc = findJunctionPointInCurrentChunk(curRename.lastFileRev()); // A(k) |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
915 HistoryNode junctionDestMock = treeBuildInspector.one(nextRename.file(), 0); // B(0) |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
916 // junstionDestMock is mock object, once we iterate next rename, there'd be different HistoryNode |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
917 // for B's first revision. This means we read it twice, but this seems to be reasonable |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
918 // price for simplicity of the code (and opportunity to follow renames while not following ancestry) |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
919 junctionSrc.bindChild(junctionDestMock); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
920 // Save mock A(k) 1) not to keep whole A history in memory 2) Don't need it's parent and children once get to B |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
921 // moreover, children of original A(k) (junctionSrc) would list mock B(0) which is undesired once we iterate over real B |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
922 junctionNode = new HistoryNode(junctionSrc.changeset, junctionSrc.fileRevision, null, null); |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
923 if (needCopyFromTo) { |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
924 copiedFrom = new HgFileRevision(curRename.file(), junctionNode.fileRevision, null); // "A", A(k) |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
925 copiedTo = new HgFileRevision(nextRename.file(), junctionDestMock.fileRevision, copiedFrom.getPath()); // "B", B(0) |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
926 } |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
927 } else { |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
928 assert iterateDirection == HgIterateDirection.NewToOld; |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
929 // looking at B chunk (curRename), nextRename points at A |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
930 HistoryNode junctionDest = changeHistory.get(0); // B(0) |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
931 // prepare mock A(k) |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
932 HistoryNode junctionSrcMock = treeBuildInspector.one(nextRename.file(), nextRename.lastFileRev()); // A(k) |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
933 // B(0) to list A(k) as its parent |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
934 // NOTE, A(k) would be different when we reach A chunk on the next iteration, |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
935 // but we do not care as long as TreeElement needs only parent/child changesets |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
936 // and not other TreeElements; so that it's enough to have mock parent node (just |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
937 // for the sake of parent cset revisions). We have to, indeed, update real A(k), |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
938 // once we get to iteration over A, with B(0) (junctionDest) as one more child. |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
939 junctionSrcMock.bindChild(junctionDest); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
940 // Save mock B(0), for reasons see above for opposite direction |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
941 junctionNode = new HistoryNode(junctionDest.changeset, junctionDest.fileRevision, null, null); |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
942 if (needCopyFromTo) { |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
943 copiedFrom = new HgFileRevision(nextRename.file(), junctionSrcMock.fileRevision, null); // "A", A(k) |
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
944 copiedTo = new HgFileRevision(curRename.file(), junctionNode.fileRevision, copiedFrom.getPath()); // "B", B(0) |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
945 } |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
946 } |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
947 } |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
948 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
949 public void reportRenames(HgFileRenameHandlerMixin renameHandler) throws HgCallbackTargetException, HgRuntimeException { |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
950 if (renameHandler != null) { // shall report renames |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
951 assert copiedFrom != null; |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
952 assert copiedTo != null; |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
953 renameHandler.copy(copiedFrom, copiedTo); |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
954 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
955 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
956 |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
957 public void clearJunctionPoint() { |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
958 junctionNode = null; |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
959 copiedFrom = copiedTo = null; |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
960 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
961 |
528
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
962 /** |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
963 * Replace mock src/dest HistoryNode connected to junctionNode with a real one |
f7fbf48b9383
Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
526
diff
changeset
|
964 */ |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
965 public void connectWithLastJunctionPoint(QueueElement curRename, QueueElement prevRename) { |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
966 assert junctionNode != null; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
967 // A renamed to B. A(0..k..n) -> B(0..m). If followAncestry: k == n |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
968 if (iterateDirection == HgIterateDirection.OldToNew) { |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
969 // forward, from old to new: |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
970 // changeHistory points to B |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
971 // Already reported: A(0)..A(n), A(k) is in junctionNode |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
972 // Shall connect histories: A(k).bind(B(0)) |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
973 HistoryNode junctionDest = changeHistory.get(0); // B(0) |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
974 // junctionNode is A(k) |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
975 junctionNode.bindChild(junctionDest); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
976 } else { |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
977 assert iterateDirection == HgIterateDirection.NewToOld; |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
978 // changeHistory points to A |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
979 // Already reported B(m), B(m-1)...B(0), B(0) is in junctionNode |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
980 // Shall connect histories A(k).bind(B(0)) |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
981 // if followAncestry: A(k) is latest in changeHistory (k == n) |
692
e970b333f284
Refactor HgLogCommand to utilize correct file.isCopy(int)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
683
diff
changeset
|
982 HistoryNode junctionSrc = findJunctionPointInCurrentChunk(curRename.lastFileRev()); // A(k) |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
983 junctionSrc.bindChild(junctionNode); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
984 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
985 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
986 |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
987 private HistoryNode findJunctionPointInCurrentChunk(Nodeid fileRevision) { |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
988 if (followAncestry) { |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
989 // use the fact we don't go past junction point when followAncestry == true |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
990 HistoryNode rv = changeHistory.get(changeHistory.size() - 1); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
991 assert rv.fileRevision.equals(fileRevision); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
992 return rv; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
993 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
994 for (HistoryNode n : changeHistory) { |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
995 if (n.fileRevision.equals(fileRevision)) { |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
996 return n; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
997 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
998 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
999 int csetStart = changeHistory.get(0).changeset; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1000 int csetEnd = changeHistory.get(changeHistory.size() - 1).changeset; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1001 throw new HgInvalidStateException(String.format("For change history (cset[%d..%d]) could not find node for file change %s", csetStart, csetEnd, fileRevision.shortNotation())); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1002 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1003 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
1004 protected abstract void once(HistoryNode n) throws HgCallbackTargetException, CancelledException, HgRuntimeException; |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1005 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
1006 public void dispatchAllChanges() throws HgCallbackTargetException, CancelledException, HgRuntimeException { |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1007 // XXX shall sort changeHistory according to changeset numbers? |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1008 Iterator<HistoryNode> it; |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
1009 if (iterateDirection == HgIterateDirection.OldToNew) { |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1010 it = changeHistory.listIterator(); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1011 } else { |
522
2103388d4010
Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
520
diff
changeset
|
1012 assert iterateDirection == HgIterateDirection.NewToOld; |
516
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1013 it = new ReverseIterator<HistoryNode>(changeHistory); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1014 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1015 while(it.hasNext()) { |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1016 HistoryNode n = it.next(); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1017 once(n); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1018 progress.worked(1); |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1019 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1020 changeHistory = null; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1021 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1022 |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1023 public void switchTo(HgDataFile df) { |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1024 // from now on, use df in TreeElement |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1025 currentFileNode = df; |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1026 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1027 } |
0ae5768081aa
Allow walking file rename history independently from file ancestry (native hg log --follow does both at once)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
515
diff
changeset
|
1028 |
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
|
1029 |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1030 // |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1031 |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1032 private class FilteringInspector extends AdapterPlug implements HgChangelog.Inspector, Adaptable { |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1033 |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1034 private int firstCset = BAD_REVISION, lastCset = BAD_REVISION; |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1035 private HgChangelog.Inspector delegate; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1036 // we use lifecycle to stop when limit is reached. |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1037 // delegate, however, may use lifecycle, too, so give it a chance |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1038 private LifecycleProxy lifecycleProxy; |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1039 |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1040 // limit to changesets in this range only |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1041 public void changesets(int start, int end) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1042 firstCset = start; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1043 lastCset = end; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1044 } |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1045 |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1046 public void delegateTo(HgChangelog.Inspector inspector) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1047 delegate = inspector; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1048 // let delegate control life cycle, too |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1049 if (lifecycleProxy == null) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1050 super.attachAdapter(Lifecycle.class, lifecycleProxy = new LifecycleProxy(inspector)); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1051 } else { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1052 lifecycleProxy.init(inspector); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1053 } |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1054 } |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1055 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
1056 public void next(int revisionNumber, Nodeid nodeid, RawChangeset cset) throws HgRuntimeException { |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1057 if (limit > 0 && count >= limit) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1058 return; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1059 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1060 // XXX may benefit from optional interface with #isInterested(int csetRev) - to avoid |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1061 // RawChangeset instantiation |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1062 if (firstCset != BAD_REVISION && revisionNumber < firstCset) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1063 return; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1064 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1065 if (lastCset != BAD_REVISION && revisionNumber > lastCset) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1066 return; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1067 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1068 if (branches != null && !branches.contains(cset.branch())) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1069 return; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1070 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1071 if (users != null) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1072 String csetUser = cset.user().toLowerCase(); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1073 boolean found = false; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1074 for (String u : users) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1075 if (csetUser.indexOf(u) != -1) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1076 found = true; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1077 break; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1078 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1079 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1080 if (!found) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1081 return; |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1082 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1083 } |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1084 if (date != null) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1085 // TODO post-1.0 implement date support for log |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1086 } |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1087 delegate.next(revisionNumber, nodeid, cset); |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1088 count++; |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1089 if (limit > 0 && count >= limit) { |
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1090 lifecycleProxy.stop(); |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1091 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1092 } |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1093 } |
518
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
1094 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
1095 private HgParentChildMap<HgChangelog> getParentHelper(boolean create) throws HgRuntimeException { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1096 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
|
1097 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
|
1098 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
|
1099 } |
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
|
1100 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
|
1101 } |
520
1ee452f31187
Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
518
diff
changeset
|
1102 |
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
|
1103 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
|
1104 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
|
1105 |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
126
diff
changeset
|
1106 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
|
1107 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
|
1108 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1109 |
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
|
1110 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
|
1111 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
|
1112 } |
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1113 } |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1114 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1115 private static class HistoryNode { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1116 final int changeset; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1117 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
|
1118 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
|
1119 final HistoryNode parent2; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1120 List<HistoryNode> children; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1121 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1122 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
|
1123 changeset = cs; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1124 fileRevision = revision; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1125 parent1 = p1; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1126 parent2 = p2; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1127 if (p1 != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1128 p1.addChild(this); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1129 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1130 if (p2 != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1131 p2.addChild(this); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1132 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1133 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1134 |
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
|
1135 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
|
1136 if (children == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1137 children = new ArrayList<HistoryNode>(2); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1138 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1139 children.add(child); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1140 } |
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
|
1141 |
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
|
1142 /** |
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
|
1143 * method to merge two history chunks for renamed file so that |
517
9922d1f7cb2a
Update test to use new command configuration argument (used to have followAncestry == true by default)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
516
diff
changeset
|
1144 * this node's history continues (or forks, if we don't followAncestry) |
9922d1f7cb2a
Update test to use new command configuration argument (used to have followAncestry == true by default)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
516
diff
changeset
|
1145 * with that of child |
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
|
1146 * @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
|
1147 */ |
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
|
1148 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
|
1149 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
|
1150 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
|
1151 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
|
1152 } |
511
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
1153 |
122e0600799f
Respect multiple joins/forks in a history of a single file
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
1154 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
|
1155 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
|
1156 } |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1157 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1158 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1159 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
|
1160 private HistoryNode historyNode; |
515
e6c8b9b654b2
Provide access to HgDataFile being iterated into HgChangesetTreeHandler.TreeElement to give context for renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
1161 private HgDataFile fileNode; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1162 private Pair<HgChangeset, HgChangeset> parents; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1163 private List<HgChangeset> children; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1164 private IntMap<HgChangeset> cachedChangesets; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1165 private ChangesetTransformer.Transformation transform; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1166 private Nodeid changesetRevision; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1167 private Pair<Nodeid,Nodeid> parentRevisions; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1168 private List<Nodeid> childRevisions; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1169 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1170 public ElementImpl(int total) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1171 cachedChangesets = new IntMap<HgChangeset>(total); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1172 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1173 |
515
e6c8b9b654b2
Provide access to HgDataFile being iterated into HgChangesetTreeHandler.TreeElement to give context for renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
1174 ElementImpl init(HistoryNode n, HgDataFile df) { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1175 historyNode = n; |
515
e6c8b9b654b2
Provide access to HgDataFile being iterated into HgChangesetTreeHandler.TreeElement to give context for renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
1176 fileNode = df; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1177 parents = null; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1178 children = null; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1179 changesetRevision = null; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1180 parentRevisions = null; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1181 childRevisions = null; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1182 return this; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1183 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1184 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1185 public Nodeid fileRevision() { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1186 return historyNode.fileRevision; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1187 } |
515
e6c8b9b654b2
Provide access to HgDataFile being iterated into HgChangesetTreeHandler.TreeElement to give context for renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
1188 |
e6c8b9b654b2
Provide access to HgDataFile being iterated into HgChangesetTreeHandler.TreeElement to give context for renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
1189 public HgDataFile file() { |
e6c8b9b654b2
Provide access to HgDataFile being iterated into HgChangesetTreeHandler.TreeElement to give context for renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
1190 return fileNode; |
e6c8b9b654b2
Provide access to HgDataFile being iterated into HgChangesetTreeHandler.TreeElement to give context for renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
1191 } |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1192 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
1193 public HgChangeset changeset() throws HgRuntimeException { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1194 return get(historyNode.changeset)[0]; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1195 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1196 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
1197 public Pair<HgChangeset, HgChangeset> parents() throws HgRuntimeException { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1198 if (parents != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1199 return parents; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1200 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1201 HistoryNode p; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1202 final int p1, p2; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1203 if ((p = historyNode.parent1) != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1204 p1 = p.changeset; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1205 } else { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1206 p1 = -1; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1207 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1208 if ((p = historyNode.parent2) != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1209 p2 = p.changeset; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1210 } else { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1211 p2 = -1; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1212 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1213 HgChangeset[] r = get(p1, p2); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1214 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
|
1215 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1216 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
1217 public Collection<HgChangeset> children() throws HgRuntimeException { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1218 if (children != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1219 return children; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1220 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1221 if (historyNode.children == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1222 children = Collections.emptyList(); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1223 } else { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1224 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
|
1225 int j = 0; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1226 for (HistoryNode hn : historyNode.children) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1227 childrentChangesetNumbers[j++] = hn.changeset; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1228 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1229 children = Arrays.asList(get(childrentChangesetNumbers)); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1230 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1231 return children; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1232 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1233 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1234 void populate(HgChangeset cs) { |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1235 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
|
1236 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1237 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
1238 private HgChangeset[] get(int... changelogRevisionIndex) throws HgRuntimeException { |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1239 HgChangeset[] rv = new HgChangeset[changelogRevisionIndex.length]; |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1240 IntVector misses = new IntVector(changelogRevisionIndex.length, -1); |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1241 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
|
1242 if (changelogRevisionIndex[i] == -1) { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1243 rv[i] = null; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1244 continue; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1245 } |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1246 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
|
1247 if (cached != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1248 rv[i] = cached; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1249 } else { |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1250 misses.add(changelogRevisionIndex[i]); |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1251 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1252 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1253 if (misses.size() > 0) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1254 final int[] changesets2read = misses.toArray(); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1255 initTransform(); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1256 repo.getChangelog().range(this, changesets2read); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1257 for (int changeset2read : changesets2read) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1258 HgChangeset cs = cachedChangesets.get(changeset2read); |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1259 if (cs == null) { |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
1260 throw new HgInvalidStateException(String.format("Can't get changeset for revision %d", changeset2read)); |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1261 } |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1262 // 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
|
1263 // thus need to find original index |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1264 boolean sanity = false; |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1265 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
|
1266 if (changelogRevisionIndex[i] == cs.getRevisionIndex()) { |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1267 rv[i] = cs; |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1268 sanity = true; |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1269 break; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1270 } |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1271 } |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1272 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
|
1273 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
|
1274 } |
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1275 assert sanity; |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1276 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1277 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1278 return rv; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1279 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1280 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1281 // 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
|
1282 void initTransform() throws HgRuntimeException { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1283 if (transform == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1284 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
|
1285 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1286 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1287 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1288 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
|
1289 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
|
1290 populate(cs.clone()); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1291 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1292 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
1293 public Nodeid changesetRevision() throws HgRuntimeException { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1294 if (changesetRevision == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1295 changesetRevision = getRevision(historyNode.changeset); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1296 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1297 return changesetRevision; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1298 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1299 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
1300 public Pair<Nodeid, Nodeid> parentRevisions() throws HgRuntimeException { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1301 if (parentRevisions == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1302 HistoryNode p; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1303 final Nodeid p1, p2; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1304 if ((p = historyNode.parent1) != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1305 p1 = getRevision(p.changeset); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1306 } else { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1307 p1 = Nodeid.NULL;; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1308 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1309 if ((p = historyNode.parent2) != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1310 p2 = getRevision(p.changeset); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1311 } else { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1312 p2 = Nodeid.NULL; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1313 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1314 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
|
1315 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1316 return parentRevisions; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1317 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1318 |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
1319 public Collection<Nodeid> childRevisions() throws HgRuntimeException { |
328
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1320 if (childRevisions != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1321 return childRevisions; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1322 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1323 if (historyNode.children == null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1324 childRevisions = Collections.emptyList(); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1325 } else { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1326 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
|
1327 for (HistoryNode hn : historyNode.children) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1328 rv.add(getRevision(hn.changeset)); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1329 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1330 childRevisions = Collections.unmodifiableList(rv); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1331 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1332 return childRevisions; |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1333 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1334 |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1335 // reading nodeid involves reading index only, guess, can afford not to optimize multiple reads |
628
6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
596
diff
changeset
|
1336 private Nodeid getRevision(int changelogRevisionNumber) throws HgRuntimeException { |
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
|
1337 // 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
|
1338 HgChangeset cs = cachedChangesets.get(changelogRevisionNumber); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1339 if (cs != null) { |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1340 return cs.getNodeid(); |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1341 } else { |
403
2747b0723867
FIXMEs: work on exceptions and javadoc
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
402
diff
changeset
|
1342 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
|
1343 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1344 } |
a674b8590362
Move file tree history to upper API level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
322
diff
changeset
|
1345 } |
64
19e9e220bf68
Convenient commands constitute hi-level API. org.tmatesoft namespace, GPL2 statement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1346 } |