Mercurial > hg4j
annotate test/org/tmatesoft/hg/test/TestHistory.java @ 518:0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 20 Dec 2012 19:55:45 +0100 |
parents | 9922d1f7cb2a |
children | 1ee452f31187 |
rev | line source |
---|---|
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
1 /* |
423
9c9c442b5f2e
Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
282
diff
changeset
|
2 * Copyright (c) 2011-2012 TMate Software Ltd |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
3 * |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or modify |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
6 * the Free Software Foundation; version 2 of the License. |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
7 * |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
8 * This program is distributed in the hope that it will be useful, |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
11 * GNU General Public License for more details. |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
12 * |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
13 * For information on how to redistribute this software under |
993f6f8e1314
Test for log command
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:
101
diff
changeset
|
15 * contact TMate Software at support@hg4j.com |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
16 */ |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
17 package org.tmatesoft.hg.test; |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
18 |
103
0b2dcca7de9f
ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
19 import static org.hamcrest.CoreMatchers.equalTo; |
0b2dcca7de9f
ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
20 import static org.hamcrest.CoreMatchers.is; |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
21 import static org.junit.Assert.assertEquals; |
147
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
22 import static org.junit.Assert.assertTrue; |
103
0b2dcca7de9f
ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
23 |
202
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
24 import java.util.ArrayList; |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
25 import java.util.Collections; |
103
0b2dcca7de9f
ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
26 import java.util.Comparator; |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
27 import java.util.HashMap; |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
28 import java.util.Iterator; |
103
0b2dcca7de9f
ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
29 import java.util.LinkedList; |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
30 import java.util.List; |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
31 import java.util.Map; |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
32 |
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
|
33 import org.junit.Assert; |
103
0b2dcca7de9f
ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
34 import org.junit.Rule; |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
100
diff
changeset
|
35 import org.junit.Test; |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
468
diff
changeset
|
36 import org.tmatesoft.hg.core.HgCallbackTargetException; |
129
645829962785
core.Cset renamed to HgChangeset; repo.Changeset moved into HgChangelog
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
103
diff
changeset
|
37 import org.tmatesoft.hg.core.HgChangeset; |
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:
423
diff
changeset
|
38 import org.tmatesoft.hg.core.HgChangesetHandler; |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
468
diff
changeset
|
39 import org.tmatesoft.hg.core.HgChangesetTreeHandler; |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
40 import org.tmatesoft.hg.core.HgFileRenameHandlerMixin; |
249
4c3b9f679412
Deprecated HgLogCommand.FileRevision gone, top-level HgFileRevision is bright and shiny replacement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
214
diff
changeset
|
41 import org.tmatesoft.hg.core.HgFileRevision; |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
42 import org.tmatesoft.hg.core.HgLogCommand; |
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
43 import org.tmatesoft.hg.core.HgLogCommand.CollectHandler; |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
468
diff
changeset
|
44 import org.tmatesoft.hg.core.Nodeid; |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
100
diff
changeset
|
45 import org.tmatesoft.hg.repo.HgLookup; |
74
6f1b88693d48
Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
70
diff
changeset
|
46 import org.tmatesoft.hg.repo.HgRepository; |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
47 import org.tmatesoft.hg.test.LogOutputParser.Record; |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
48 import org.tmatesoft.hg.util.Adaptable; |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
468
diff
changeset
|
49 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
|
50 import org.tmatesoft.hg.util.Path; |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
51 |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
52 |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
53 /** |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
54 * |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
55 * @author Artem Tikhomirov |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
56 * @author TMate Software Ltd. |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
57 */ |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
58 public class TestHistory { |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
59 |
103
0b2dcca7de9f
ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
60 @Rule |
0b2dcca7de9f
ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
61 public ErrorCollectorExt errorCollector = new ErrorCollectorExt(); |
0b2dcca7de9f
ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
62 |
147
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
63 private HgRepository repo; |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
64 private final ExecHelper eh; |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
65 private LogOutputParser changelogParser; |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
66 |
103
0b2dcca7de9f
ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
67 public static void main(String[] args) throws Throwable { |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
100
diff
changeset
|
68 TestHistory th = new TestHistory(); |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
69 th.testCompleteLog(); |
82
7255c971dd66
Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
70 th.testFollowHistory(); |
103
0b2dcca7de9f
ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
102
diff
changeset
|
71 th.errorCollector.verify(); |
147
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
72 // th.testPerformance(); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
73 th.testOriginalTestLogRepo(); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
74 th.testUsernames(); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
75 th.testBranches(); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
76 // |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
77 th.errorCollector.verify(); |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
78 } |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
100
diff
changeset
|
79 |
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
100
diff
changeset
|
80 public TestHistory() throws Exception { |
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
100
diff
changeset
|
81 this(new HgLookup().detectFromWorkingDir()); |
214
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
82 // this(new HgLookup().detect("\\temp\\hg\\hello")); |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
100
diff
changeset
|
83 } |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
84 |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
100
diff
changeset
|
85 private TestHistory(HgRepository hgRepo) { |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
86 repo = hgRepo; |
282
e51dd9a14b6f
Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
249
diff
changeset
|
87 eh = new ExecHelper(changelogParser = new LogOutputParser(true), repo.getWorkingDir()); |
147
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
88 |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
89 } |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
90 |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
100
diff
changeset
|
91 @Test |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
92 public void testCompleteLog() throws Exception { |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
93 changelogParser.reset(); |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
94 eh.run("hg", "log", "--debug"); |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
95 List<HgChangeset> r = new HgLogCommand(repo).execute(); |
82
7255c971dd66
Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
96 report("hg log - COMPLETE REPO HISTORY", r, true); |
7255c971dd66
Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
97 } |
7255c971dd66
Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
98 |
101
777ab7034c1b
Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
100
diff
changeset
|
99 @Test |
82
7255c971dd66
Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
100 public void testFollowHistory() throws Exception { |
7255c971dd66
Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
101 final Path f = Path.create("cmdline/org/tmatesoft/hg/console/Remote.java"); |
214
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
102 assertTrue(repo.getFileNode(f).exists()); |
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
103 changelogParser.reset(); |
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
104 eh.run("hg", "log", "--debug", "--follow", f.toString()); |
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
105 |
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
|
106 CollectWithRenameHandler h = new CollectWithRenameHandler(); |
214
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
107 new HgLogCommand(repo).file(f, true).execute(h); |
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
|
108 errorCollector.assertEquals(1, h.renames.size()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
109 HgFileRevision from = h.renames.get(0).first(); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
110 boolean fromMatched = "src/com/tmate/hgkit/console/Remote.java".equals(from.getPath().toString()); |
214
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
111 String what = "hg log - FOLLOW FILE HISTORY"; |
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
112 errorCollector.checkThat(what + "#copyReported ", h.copyReported, is(true)); |
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
|
113 errorCollector.checkThat(what + "#copyFromMatched", fromMatched, is(true)); |
214
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
114 // |
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
115 // cmdline always gives in changesets in order from newest (bigger rev number) to oldest. |
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
116 // LogCommand does other way round, from oldest to newest, follewed by revisions of copy source, if any |
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
117 // (apparently older than oldest of the copy target). Hence need to sort Java results according to rev numbers |
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
118 final LinkedList<HgChangeset> sorted = new LinkedList<HgChangeset>(h.getChanges()); |
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
119 Collections.sort(sorted, new Comparator<HgChangeset>() { |
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
120 public int compare(HgChangeset cs1, HgChangeset cs2) { |
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:
282
diff
changeset
|
121 return cs1.getRevisionIndex() < cs2.getRevisionIndex() ? 1 : -1; |
214
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
122 } |
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
123 }); |
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
124 report(what, sorted, false); |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
125 } |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
468
diff
changeset
|
126 |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
468
diff
changeset
|
127 @Test |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
468
diff
changeset
|
128 public void testChangesetTree() throws Exception { |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
468
diff
changeset
|
129 repo = Configuration.get().find("branches-1"); |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
468
diff
changeset
|
130 final String fname = "file1"; |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
468
diff
changeset
|
131 assertTrue("[sanity]", repo.getFileNode(fname).exists()); |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
468
diff
changeset
|
132 eh.run("hg", "log", "--debug", fname, "--cwd", repo.getLocation()); |
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
468
diff
changeset
|
133 |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
134 TreeCollectHandler h = new TreeCollectHandler(false); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
135 new HgLogCommand(repo).file(fname, false).execute(h); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
136 // since we use TreeCollectHandler with natural order (older to newer), shall reverse console result in report() |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
137 report("execute with HgChangesetTreeHandler(follow == false)", h.getResult(), true); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
138 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
139 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
140 @Test |
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
|
141 public void testChangesetTreeFollowRenameAndAncestry() throws Exception { |
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
|
142 repo = Configuration.get().find("log-follow"); |
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
|
143 final String fname = "file1_b"; |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
144 assertTrue("[sanity]", repo.getFileNode(fname).exists()); |
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
|
145 eh.run("hg", "log", "--debug", "--follow", fname, "--cwd", repo.getLocation()); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
146 |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
147 final Map<Path,Path> renames = new HashMap<Path, Path>(); |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
148 TreeCollectHandler h = new TreeCollectHandler(true); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
149 h.attachAdapter(HgFileRenameHandlerMixin.class, new HgFileRenameHandlerMixin() { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
150 |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
151 public void copy(HgFileRevision from, HgFileRevision to) throws HgCallbackTargetException { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
152 renames.put(from.getPath(), to.getPath()); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
153 } |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
154 }); |
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
|
155 h.checkPrevInParents = true; |
517
9922d1f7cb2a
Update test to use new command configuration argument (used to have followAncestry == true by default)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
156 new HgLogCommand(repo).file(fname, true, true).execute(h); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
157 |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
158 assertEquals(1, h.getAdapterUse(HgFileRenameHandlerMixin.class)); |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
159 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
160 report("execute with HgChangesetTreeHandler(follow == true)", h.getResult(), false); |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
161 |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
162 assertEquals(1, renames.size()); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
163 assertEquals(Path.create(fname), renames.get(Path.create("file1_a"))); |
507
a6435c1a42d0
Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
468
diff
changeset
|
164 } |
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
|
165 |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
166 /** |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
167 * Few tests to check newly introduced followAncestry parameter to HgLogCommand: |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
168 * followRename: true, followAncestry: 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
|
169 * followRename: false, followAncestry: 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
|
170 * followRename: true, followAncestry: 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
|
171 * Perhaps, shall be merged with {@link #testFollowHistory()} |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
172 */ |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
173 @Test |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
174 public void testFollowRenamesNotAncestry() throws Exception { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
175 repo = Configuration.get().find("log-follow"); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
176 final String fname1 = "file1_a"; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
177 final String fname2 = "file1_b"; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
178 assertTrue("[sanity]", repo.getFileNode(fname2).exists()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
179 // no --follow, but two names we know have been the same file (fname1 renamed to fname2) |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
180 // sequentially gives follow rename semantics without ancestry |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
181 eh.run("hg", "log", "--debug", fname2, fname1, "--cwd", repo.getLocation()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
182 |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
183 CollectWithRenameHandler h = new CollectWithRenameHandler(); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
184 new HgLogCommand(repo).file(fname2, true, false).execute(h); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
185 errorCollector.assertEquals(1, h.renames.size()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
186 Pair<HgFileRevision, HgFileRevision> rename = h.renames.get(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
|
187 errorCollector.assertEquals(fname1, rename.first().getPath().toString()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
188 errorCollector.assertEquals(fname2, rename.second().getPath().toString()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
189 // Ensure rename info came in the right moment |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
190 errorCollector.assertEquals(1, h.lastChangesetReportedAtRename.size()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
191 // Command iterates old to new, rename comes after last fname1 revision. Since we don't follow |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
192 // ancestry, it's the very last revision in fname1 history |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
193 String lastRevOfFname1 = "369c0882d477c11424a62eb4b791e86d1d4b6769"; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
194 errorCollector.assertEquals(lastRevOfFname1, h.lastChangesetReportedAtRename.get(0).getNodeid().toString()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
195 report("HgChangesetHandler(renames: true, ancestry:false)", h.getChanges(), 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
|
196 |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
197 // TODO 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
|
198 // TODO TreeChangeHandler |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
199 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
200 |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
201 @Test |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
202 public void testFollowAncestryNotRenames() throws Exception { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
203 repo = Configuration.get().find("log-follow"); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
204 final String fname2 = "file1_b"; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
205 assertTrue("[sanity]", repo.getFileNode(fname2).exists()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
206 // to get "followed" history of fname2 only (without fname1 origin), |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
207 // get the complete history and keep there only elements that match fname2 own history |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
208 eh.run("hg", "log", "--debug", "--follow", fname2, "--cwd", repo.getLocation()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
209 final List<Record> fname2Follow = new LinkedList<LogOutputParser.Record>(changelogParser.getResult()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
210 changelogParser.reset(); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
211 eh.run("hg", "log", "--debug", fname2, "--cwd", repo.getLocation()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
212 // fname2Follow.retainAll(changelogParser.getResult()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
213 for (Iterator<Record> it = fname2Follow.iterator(); it.hasNext();) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
214 Record r = it.next(); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
215 boolean belongsToSoleFname2History = 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
|
216 for (Record d : changelogParser.getResult()) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
217 if (d.changesetIndex == r.changesetIndex) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
218 assert d.changesetNodeid.equals(r.changesetNodeid) : "[sanity]"; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
219 belongsToSoleFname2History = 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
|
220 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
|
221 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
222 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
223 if (!belongsToSoleFname2History) { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
224 it.remove(); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
225 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
226 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
227 CollectWithRenameHandler h = new CollectWithRenameHandler(); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
228 new HgLogCommand(repo).file(fname2, false, true).execute(h); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
229 errorCollector.assertEquals(0, h.renames.size()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
230 report("HgChangesetHandler(renames: false, ancestry:true)", h.getChanges(), fname2Follow, true, errorCollector); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
231 |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
232 // TODO 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
|
233 // TODO TreeChangeHandler |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
234 } |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
235 |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
236 /** |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
237 * output identical to that of "hg log --follow" |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
238 */ |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
239 @Test |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
240 public void testFollowBothRenameAndAncestry() throws Exception { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
241 repo = Configuration.get().find("log-follow"); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
242 final String fname1 = "file1_a"; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
243 final String fname2 = "file1_b"; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
244 assertTrue("[sanity]", repo.getFileNode(fname2).exists()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
245 eh.run("hg", "log", "--debug", "--follow", fname2, "--cwd", repo.getLocation()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
246 |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
247 CollectWithRenameHandler h = new CollectWithRenameHandler(); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
248 new HgLogCommand(repo).file(fname2, true, true).execute(h); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
249 errorCollector.assertEquals(1, h.renames.size()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
250 Pair<HgFileRevision, HgFileRevision> rename = h.renames.get(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
|
251 errorCollector.assertEquals(fname1, rename.first().getPath().toString()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
252 errorCollector.assertEquals(fname2, rename.second().getPath().toString()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
253 // Ensure rename info came in the right moment |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
254 errorCollector.assertEquals(1, h.lastChangesetReportedAtRename.size()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
255 String fname1BranchRevision = "6e668ff2940acb250c8627843f8116166fe5d5cd"; |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
256 errorCollector.assertEquals(fname1BranchRevision, h.lastChangesetReportedAtRename.get(0).getNodeid().toString()); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
257 // finally, match output |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
258 report("HgChangesetHandler(renames: true, ancestry:true)", h.getChanges(), 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
|
259 // TODO 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
|
260 // TreeChangeHandler in #testChangesetTreeFollowRenameAndAncestry |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
261 } |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
262 |
202
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
263 private void report(String what, List<HgChangeset> r, boolean reverseConsoleResult) { |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
264 final List<Record> consoleResult = changelogParser.getResult(); |
202
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
265 report(what, r, consoleResult, reverseConsoleResult, errorCollector); |
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
266 } |
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
267 |
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
268 static void report(String what, List<HgChangeset> hg4jResult, List<Record> consoleResult, boolean reverseConsoleResult, ErrorCollectorExt errorCollector) { |
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
269 consoleResult = new ArrayList<Record>(consoleResult); // need a copy in case callee would use result again |
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
270 if (reverseConsoleResult) { |
82
7255c971dd66
Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
271 Collections.reverse(consoleResult); |
7255c971dd66
Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
74
diff
changeset
|
272 } |
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
|
273 errorCollector.checkThat(what + ". Number of changeset reported didn't match", hg4jResult.size(), equalTo(consoleResult.size())); |
147
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
274 Iterator<Record> consoleResultItr = consoleResult.iterator(); |
202
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
275 for (HgChangeset cs : hg4jResult) { |
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
276 if (!consoleResultItr.hasNext()) { |
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
277 errorCollector.addError(new AssertionError("Ran out of console results while there are still hg4j results")); |
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
278 break; |
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
279 } |
147
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
280 Record cr = consoleResultItr.next(); |
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:
282
diff
changeset
|
281 int x = cs.getRevisionIndex() == cr.changesetIndex ? 0x1 : 0; |
214
4252faa556cd
Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
202
diff
changeset
|
282 x |= cs.getDate().toString().equals(cr.date) ? 0x2 : 0; |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
283 x |= cs.getNodeid().toString().equals(cr.changesetNodeid) ? 0x4 : 0; |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
284 x |= cs.getUser().equals(cr.user) ? 0x8 : 0; |
202
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
285 // need to do trim() on comment because command-line template does, and there are |
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
286 // repositories that have couple of newlines in the end of the comment (e.g. hello sample repo from the book) |
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
287 x |= cs.getComment().trim().equals(cr.description) ? 0x10 : 0; |
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:
282
diff
changeset
|
288 errorCollector.checkThat(String.format(what + ". Mismatch (0x%x) in %d hg4j rev comparing to %d cmdline's.", x, cs.getRevisionIndex(), cr.changesetIndex), x, equalTo(0x1f)); |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
289 consoleResultItr.remove(); |
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
290 } |
202
706bcc7cfee4
Basic test for HgIncomingCommand. Fix RepositoryComparator for cases when whole repository is unknown. Respect freshly initialized (empty) repositories in general.
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
147
diff
changeset
|
291 errorCollector.checkThat(what + ". Unprocessed results in console left (insufficient from hg4j)", consoleResultItr.hasNext(), equalTo(false)); |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
292 } |
100
b71b3f7d24d4
Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
95
diff
changeset
|
293 |
b71b3f7d24d4
Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
95
diff
changeset
|
294 public void testPerformance() throws Exception { |
b71b3f7d24d4
Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
95
diff
changeset
|
295 final int runs = 10; |
b71b3f7d24d4
Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
95
diff
changeset
|
296 final long start1 = System.currentTimeMillis(); |
b71b3f7d24d4
Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
95
diff
changeset
|
297 for (int i = 0; i < runs; i++) { |
b71b3f7d24d4
Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
95
diff
changeset
|
298 changelogParser.reset(); |
b71b3f7d24d4
Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
95
diff
changeset
|
299 eh.run("hg", "log", "--debug"); |
b71b3f7d24d4
Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
95
diff
changeset
|
300 } |
b71b3f7d24d4
Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
95
diff
changeset
|
301 final long start2 = System.currentTimeMillis(); |
b71b3f7d24d4
Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
95
diff
changeset
|
302 for (int i = 0; i < runs; i++) { |
131
aa1629f36482
Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
129
diff
changeset
|
303 new HgLogCommand(repo).execute(); |
100
b71b3f7d24d4
Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
95
diff
changeset
|
304 } |
b71b3f7d24d4
Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
95
diff
changeset
|
305 final long end = System.currentTimeMillis(); |
b71b3f7d24d4
Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
95
diff
changeset
|
306 System.out.printf("'hg log --debug', %d runs: Native client total %d (%d per run), Java client %d (%d)\n", runs, start2-start1, (start2-start1)/runs, end-start2, (end-start2)/runs); |
b71b3f7d24d4
Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
95
diff
changeset
|
307 } |
147
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
308 |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
309 @Test |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
310 public void testOriginalTestLogRepo() throws Exception { |
462
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
311 // tests fro mercurial distribution, test-log.t |
147
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
312 repo = Configuration.get().find("log-1"); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
313 HgLogCommand cmd = new HgLogCommand(repo); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
314 // funny enough, but hg log -vf a -R c:\temp\hg\test-log\a doesn't work, while --cwd <same> works fine |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
315 // |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
316 changelogParser.reset(); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
317 eh.run("hg", "log", "--debug", "a", "--cwd", repo.getLocation()); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
318 report("log a", cmd.file("a", false).execute(), true); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
319 // |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
320 changelogParser.reset(); |
462
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
321 // fails with Mercurial 2.2.1, @see http://selenic.com/pipermail/mercurial-devel/2012-February/038249.html |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
322 // and http://www.selenic.com/hg/rev/60101427d618?rev= |
468
3ca4ae7bdd38
Clean experimental marks and deprecation code. Update version number to release
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
462
diff
changeset
|
323 // fix for the test (replacement) is available below |
3ca4ae7bdd38
Clean experimental marks and deprecation code. Update version number to release
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
462
diff
changeset
|
324 // eh.run("hg", "log", "--debug", "-f", "a", "--cwd", repo.getLocation()); |
3ca4ae7bdd38
Clean experimental marks and deprecation code. Update version number to release
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
462
diff
changeset
|
325 // List<HgChangeset> r = cmd.file("a", true).execute(); |
3ca4ae7bdd38
Clean experimental marks and deprecation code. Update version number to release
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
462
diff
changeset
|
326 // report("log -f a", r, true); |
3ca4ae7bdd38
Clean experimental marks and deprecation code. Update version number to release
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
462
diff
changeset
|
327 |
147
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
328 // |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
329 changelogParser.reset(); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
330 eh.run("hg", "log", "--debug", "-f", "e", "--cwd", repo.getLocation()); |
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
|
331 report("log -f e", cmd.file("e", true).execute(), true); |
147
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
332 // |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
333 changelogParser.reset(); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
334 eh.run("hg", "log", "--debug", "dir/b", "--cwd", repo.getLocation()); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
335 report("log dir/b", cmd.file("dir/b", false).execute(), true); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
336 // |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
337 changelogParser.reset(); |
462
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
338 // |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
339 // Commented out for the same reason as above hg log -f a - newly introduced error message in Mercurial 2.2 |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
340 // when files are not part of the parent revision |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
341 // eh.run("hg", "log", "--debug", "-f", "dir/b", "--cwd", repo.getLocation()); |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
342 // report("log -f dir/b", cmd.file("dir/b", true).execute(), false /*#1, below*/); |
147
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
343 /* |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
344 * #1: false works because presently commands dispatches history of the queried file, and then history |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
345 * of it's origin. With history comprising of renames only, this effectively gives reversed (newest to oldest) |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
346 * order of revisions. |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
347 */ |
462
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
348 |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
349 // commented tests from above updated to work in 2.2 - update repo to revision where files are present |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
350 eh.run("hg", "update", "-q", "-r", "2", "--cwd", repo.getLocation()); |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
351 changelogParser.reset(); |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
352 eh.run("hg", "log", "--debug", "-f", "a", "--cwd", repo.getLocation()); |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
353 List<HgChangeset> r = cmd.file("a", true).execute(); |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
354 report("log -f a", r, true); |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
355 changelogParser.reset(); |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
356 eh.run("hg", "log", "--debug", "-f", "dir/b", "--cwd", repo.getLocation()); |
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
|
357 report("log -f dir/b", cmd.file("dir/b", true).execute(), true); |
462
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
358 // |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
359 // get repo back into clear state, up to the tip |
ad0322a4af20
Update tests not to fail with Mercurial 2.2 changes, run tests with gradle
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
427
diff
changeset
|
360 eh.run("hg", "update", "-q", "--cwd", repo.getLocation()); |
147
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
361 } |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
362 |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
363 @Test |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
364 public void testUsernames() throws Exception { |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
365 repo = Configuration.get().find("log-users"); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
366 final String user1 = "User One <user1@example.org>"; |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
367 // |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
368 changelogParser.reset(); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
369 eh.run("hg", "log", "--debug", "-u", user1, "--cwd", repo.getLocation()); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
370 report("log -u " + user1, new HgLogCommand(repo).user(user1).execute(), true); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
371 // |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
372 changelogParser.reset(); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
373 eh.run("hg", "log", "--debug", "-u", "user1", "-u", "user2", "--cwd", repo.getLocation()); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
374 report("log -u user1 -u user2", new HgLogCommand(repo).user("user1").user("user2").execute(), true); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
375 // |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
376 changelogParser.reset(); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
377 eh.run("hg", "log", "--debug", "-u", "user3", "--cwd", repo.getLocation()); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
378 report("log -u user3", new HgLogCommand(repo).user("user3").execute(), true); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
379 } |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
380 |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
381 @Test |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
382 public void testBranches() throws Exception { |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
383 repo = Configuration.get().find("log-branches"); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
384 changelogParser.reset(); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
385 eh.run("hg", "log", "--debug", "-b", "default", "--cwd", repo.getLocation()); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
386 report("log -b default" , new HgLogCommand(repo).branch("default").execute(), true); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
387 // |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
388 changelogParser.reset(); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
389 eh.run("hg", "log", "--debug", "-b", "test", "--cwd", repo.getLocation()); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
390 report("log -b test" , new HgLogCommand(repo).branch("test").execute(), true); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
391 // |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
392 assertTrue("log -b dummy shall yeild empty result", new HgLogCommand(repo).branch("dummy").execute().isEmpty()); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
393 // |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
394 changelogParser.reset(); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
395 eh.run("hg", "log", "--debug", "-b", "default", "-b", "test", "--cwd", repo.getLocation()); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
396 report("log -b default -b test" , new HgLogCommand(repo).branch("default").branch("test").execute(), true); |
a05145db4d0c
Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
133
diff
changeset
|
397 } |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
398 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
399 //// |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
400 |
514
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
401 private static class AdapterPlug implements Adaptable { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
402 private final Map<Class<?>, Object> adapters = new HashMap<Class<?>, Object>(); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
403 private final List<Class<?>> adapterUses = new ArrayList<Class<?>>(); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
404 |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
405 public <T> void attachAdapter(Class<T> adapterClass, T instance) { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
406 adapters.put(adapterClass, instance); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
407 } |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
408 |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
409 public <T> T getAdapter(Class<T> adapterClass) { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
410 Object instance = adapters.get(adapterClass); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
411 if (instance != null) { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
412 adapterUses.add(adapterClass); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
413 return adapterClass.cast(instance); |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
414 } |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
415 return null; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
416 } |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
417 |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
418 public int getAdapterUse(Class<?> adapterClass) { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
419 int uses = 0; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
420 for (Class<?> c : adapterUses) { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
421 if (c == adapterClass) { |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
422 uses++; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
423 } |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
424 } |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
425 return uses; |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
426 } |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
427 } |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
428 |
5dcb4581c8ef
Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
510
diff
changeset
|
429 private final class TreeCollectHandler extends AdapterPlug implements HgChangesetTreeHandler { |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
430 private final LinkedList<HgChangeset> cmdResult = new LinkedList<HgChangeset>(); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
431 private final boolean reverseResult; |
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
|
432 boolean checkPrevInChildren = false; |
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
|
433 boolean checkPrevInParents = false; |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
434 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
435 public TreeCollectHandler(boolean _reverseResult) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
436 this.reverseResult = _reverseResult; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
437 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
438 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
439 public List<HgChangeset> getResult() { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
440 return cmdResult; |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
441 } |
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
|
442 |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
443 |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
444 public void treeElement(TreeElement entry) throws HgCallbackTargetException { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
445 // check consistency |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
446 Nodeid cset = entry.changeset().getNodeid(); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
447 errorCollector.assertEquals(entry.changesetRevision(), cset); |
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
|
448 Pair<HgChangeset, HgChangeset> p = entry.parents(); |
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
|
449 Pair<HgChangeset, HgChangeset> parents_a = p; |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
450 Pair<Nodeid, Nodeid> parents_b = entry.parentRevisions(); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
451 if (parents_b.first().isNull()) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
452 errorCollector.assertTrue(parents_a.first() == null); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
453 } else { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
454 errorCollector.assertEquals(parents_b.first(), parents_a.first().getNodeid()); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
455 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
456 if (parents_b.second().isNull()) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
457 errorCollector.assertTrue(parents_a.second() == null); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
458 } else { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
459 errorCollector.assertEquals(parents_b.second(), parents_a.second().getNodeid()); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
460 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
461 // |
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
|
462 if (checkPrevInChildren && !cmdResult.isEmpty()) { |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
463 HgChangeset prevChangeset = reverseResult ? cmdResult.getFirst() : cmdResult.getLast(); |
517
9922d1f7cb2a
Update test to use new command configuration argument (used to have followAncestry == true by default)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
464 String msg = String.format("No parent-child bind between revisions %d and %d", prevChangeset.getRevisionIndex(), entry.changeset().getRevisionIndex()); |
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
|
465 errorCollector.assertTrue(msg, entry.children().contains(prevChangeset)); |
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
|
466 } |
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
|
467 if (checkPrevInParents && !cmdResult.isEmpty()) { |
a30e74dca193
Establish parent-child between first and last elements of history chunks for two renamed files
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
508
diff
changeset
|
468 HgChangeset prevChangeset = reverseResult ? cmdResult.getFirst() : cmdResult.getLast(); |
517
9922d1f7cb2a
Update test to use new command configuration argument (used to have followAncestry == true by default)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
514
diff
changeset
|
469 String msg = String.format("No parent-child bind between revisions %d and %d", prevChangeset.getRevisionIndex(), entry.changeset().getRevisionIndex()); |
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
|
470 errorCollector.assertTrue(msg, p.first() == prevChangeset || p.second() == prevChangeset); |
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
|
471 } |
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
|
472 // |
508
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
473 if (reverseResult) { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
474 cmdResult.addFirst(entry.changeset()); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
475 } else { |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
476 cmdResult.addLast(entry.changeset()); |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
477 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
478 } |
ca5202afea90
Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
507
diff
changeset
|
479 } |
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
|
480 |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
481 private static class CollectWithRenameHandler extends CollectHandler implements HgChangesetHandler.WithCopyHistory { |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
482 public boolean copyReported = 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
|
483 public List<Pair<HgFileRevision, HgFileRevision>> renames = new LinkedList<Pair<HgFileRevision,HgFileRevision>>(); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
484 public List<HgChangeset> lastChangesetReportedAtRename = new LinkedList<HgChangeset>(); |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
485 |
0d5e1ea7955e
Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
517
diff
changeset
|
486 public void copy(HgFileRevision from, HgFileRevision to) { |
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 copyReported = 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
|
488 Assert.assertTrue("Renames couldn't be reported prior to any change", getChanges().size() > 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
|
489 HgChangeset lastKnown = getChanges().get(getChanges().size() - 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
|
490 lastChangesetReportedAtRename.add(lastKnown); |
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 renames.add(new Pair<HgFileRevision, HgFileRevision>(from, to)); |
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 } |
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 }; |
70
993f6f8e1314
Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff
changeset
|
494 } |