annotate test/org/tmatesoft/hg/test/TestHistory.java @ 713:661e77dc88ba tip

Mac support: respect Mac alternatives of command-line arguments for common unix tools
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sun, 03 Aug 2014 18:09:00 +0200
parents 72fc7774b87e
children
rev   line source
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
628
6526d8adbc0f Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 528
diff changeset
2 * Copyright (c) 2011-2013 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;
522
2103388d4010 Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 521
diff changeset
23 import static org.tmatesoft.hg.core.HgIterateDirection.NewToOld;
691
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
24 import static org.tmatesoft.hg.core.HgIterateDirection.OldToNew;
103
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
25
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
26 import java.util.ArrayList;
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
27 import java.util.Collections;
103
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
28 import java.util.Comparator;
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29 import java.util.Iterator;
103
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
30 import java.util.LinkedList;
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
31 import java.util.List;
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;
528
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
42 import org.tmatesoft.hg.core.HgIterateDirection;
131
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;
aa1629f36482 Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 129
diff changeset
44 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
45 import org.tmatesoft.hg.core.Nodeid;
520
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
46 import org.tmatesoft.hg.internal.AdapterPlug;
101
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
47 import org.tmatesoft.hg.repo.HgLookup;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 70
diff changeset
48 import org.tmatesoft.hg.repo.HgRepository;
628
6526d8adbc0f Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 528
diff changeset
49 import org.tmatesoft.hg.repo.HgRuntimeException;
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
50 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
51 import org.tmatesoft.hg.util.Adaptable;
520
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
52 import org.tmatesoft.hg.util.CancelSupport;
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
53 import org.tmatesoft.hg.util.CancelledException;
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
54 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
55 import org.tmatesoft.hg.util.Path;
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
56
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 /**
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
59 *
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
60 * @author Artem Tikhomirov
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
61 * @author TMate Software Ltd.
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
62 */
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
63 public class TestHistory {
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
64
103
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
65 @Rule
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
66 public ErrorCollectorExt errorCollector = new ErrorCollectorExt();
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
67
147
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
68 private HgRepository repo;
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
69 private final ExecHelper eh;
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
70 private LogOutputParser changelogParser;
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
71
103
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
72 public static void main(String[] args) throws Throwable {
691
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
73 TestHistory th = new TestHistory(new HgLookup().detectFromWorkingDir());
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
74 th.testCompleteLog();
82
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
75 th.testFollowHistory();
103
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
76 th.errorCollector.verify();
147
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
77 // th.testPerformance();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
78 th.testOriginalTestLogRepo();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
79 th.testUsernames();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
80 th.testBranches();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
81 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
82 th.errorCollector.verify();
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
83 }
101
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
84
691
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
85 public TestHistory() {
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
86 eh = new ExecHelper(changelogParser = new LogOutputParser(true), null);
101
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
87 }
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
88
101
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
89 private TestHistory(HgRepository hgRepo) {
691
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
90 this();
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
91 repo = hgRepo;
691
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
92 eh.cwd(repo.getWorkingDir());
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
93 }
691
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
94
101
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
95 @Test
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
96 public void testCompleteLog() throws Exception {
691
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
97 if (repo == null) {
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
98 repo = Configuration.get().own();
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
99 eh.cwd(repo.getWorkingDir());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
100 }
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
101 changelogParser.reset();
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
102 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
103 List<HgChangeset> r = new HgLogCommand(repo).execute();
520
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
104 report("hg log - COMPLETE REPO HISTORY", r, true);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
105
522
2103388d4010 Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 521
diff changeset
106 r = new HgLogCommand(repo).order(NewToOld).execute();
520
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
107 report("hg log - COMPLETE REPO HISTORY, FROM NEW TO OLD", r, false);
82
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
108 }
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
109
101
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
110 @Test
82
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
111 public void testFollowHistory() throws Exception {
691
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
112 if (repo == null) {
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
113 repo = Configuration.get().own();
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
114 eh.cwd(repo.getWorkingDir());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
115 }
82
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
116 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
117 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
118 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
119 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
120
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
121 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
122 new HgLogCommand(repo).file(f, true).execute(h);
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
123 errorCollector.assertEquals(1, h.rh.renames.size());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
124 HgFileRevision from = h.rh.renames.get(0).first();
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
125 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
126 String what = "hg log - FOLLOW FILE HISTORY";
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
127 errorCollector.checkThat(what + "#copyReported ", h.rh.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
128 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
129 //
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
130 // 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
131 // 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
132 // (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
133 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
134 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
135 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
136 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
137 }
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
138 });
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
139 report(what, sorted, false);
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
140 }
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
141
a6435c1a42d0 Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
142 @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
143 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
144 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
145 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
146 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
147 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
148
508
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
149 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
150 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
151 // 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
152 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
153 }
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
154
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
155 /**
0d5e1ea7955e Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 517
diff changeset
156 * 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
157 * 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
158 * 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
159 * 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
160 * 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
161 */
0d5e1ea7955e Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 517
diff changeset
162 @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
163 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
164 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
165 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
166 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
167 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
168 // 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
169 // 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
170 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
171
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 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
173 new HgLogCommand(repo).file(fname2, true, false).execute(h);
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
174 errorCollector.assertEquals(1, h.rh.renames.size());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
175 Pair<HgFileRevision, HgFileRevision> rename = h.rh.renames.get(0);
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
176 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
177 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
178 // 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
179 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
180 // 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
181 // 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
182 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
183 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
184 report("HgChangesetHandler(renames: true, ancestry:false)", h.getChanges(), true);
520
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
185 //
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
186 // Direction
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
187 h = new CollectWithRenameHandler();
522
2103388d4010 Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 521
diff changeset
188 new HgLogCommand(repo).file(fname2, true, false).order(NewToOld).execute(h);
520
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
189 // Identical rename shall be reported, at the same moment
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
190 errorCollector.assertEquals(1, h.rh.renames.size());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
191 rename = h.rh.renames.get(0);
520
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
192 errorCollector.assertEquals(fname1, rename.first().getPath().toString());
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
193 errorCollector.assertEquals(fname2, rename.second().getPath().toString());
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
194 errorCollector.assertEquals(1, h.lastChangesetReportedAtRename.size());
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
195 // new to old, recently reported would be the very first revision fname2 pops up
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
196 String firstRevOfFname2 = "27e7a69373b74d42e75f3211e56510ff17d01370";
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
197 errorCollector.assertEquals(firstRevOfFname2, h.lastChangesetReportedAtRename.get(0).getNodeid().toString());
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
198 report("HgChangesetHandler(renames: true, ancestry:false)", h.getChanges(), false);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
199 //
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
200 // TreeChangeHandler - in #testChangesetTreeFollowRenamesNotAncestry
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
201 }
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
202
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
203 @Test
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
204 public void testChangesetTreeFollowRenamesNotAncestry() throws Exception {
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
205 repo = Configuration.get().find("log-follow");
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
206 final String fname1 = "file1_a";
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
207 final String fname2 = "file1_b";
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
208 assertTrue("[sanity]", repo.getFileNode(fname2).exists());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
209 // no --follow, but two names we know have been the same file (fname1 renamed to fname2)
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
210 // sequentially gives follow rename semantics without ancestry
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
211 eh.run("hg", "log", "--debug", fname2, fname1, "--cwd", repo.getLocation());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
212
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
213 TreeCollectHandler h = new TreeCollectHandler(true);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
214 RenameCollector rh = new RenameCollector(h);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
215 // can't check that prev revision is in parent because there are forks in
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
216 // file history (e.g. rev2 and rev3 (that comes next) both have rev0 as their parent
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
217 // and followAncestry is false
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
218 // h.checkPrevInParents = true;
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
219 new HgLogCommand(repo).file(fname2, true, false).execute(h);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
220 errorCollector.assertEquals(1, rh.renames.size());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
221 Pair<HgFileRevision, HgFileRevision> rename = rh.renames.get(0);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
222 errorCollector.assertEquals(fname1, rename.first().getPath().toString());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
223 errorCollector.assertEquals(fname2, rename.second().getPath().toString());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
224 report("HgChangesetTreeHandler(renames: true, ancestry:false)", h.getResult(), false);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
225
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
226 // Direction
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
227 h = new TreeCollectHandler(false);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
228 rh = new RenameCollector(h);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
229 // h.checkPrevInChildren = true; see above
522
2103388d4010 Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 521
diff changeset
230 new HgLogCommand(repo).file(fname2, true, false).order(NewToOld).execute(h);
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
231 errorCollector.assertEquals(1, rh.renames.size());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
232 rename = rh.renames.get(0);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
233 errorCollector.assertEquals(fname1, rename.first().getPath().toString());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
234 errorCollector.assertEquals(fname2, rename.second().getPath().toString());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
235 report("HgChangesetTreeHandler(renames: true, ancestry:false)", h.getResult(), false);
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
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
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 @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
239 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
240 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
241 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
242 assertTrue("[sanity]", repo.getFileNode(fname2).exists());
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
243 final List<Record> fname2Follow = getAncestryWithoutRenamesFromCmdline(fname2);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
244
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
245 CollectWithRenameHandler h = new CollectWithRenameHandler();
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
246 new HgLogCommand(repo).file(fname2, false, true).execute(h);
528
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
247 // renames are reported regardless of followRenames parameter, but
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
248 // solely based on HgFileRenameHandlerMixin
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
249 errorCollector.assertEquals(1, h.rh.renames.size());
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
250 report("HgChangesetHandler(renames: false, ancestry:true)", h.getChanges(), fname2Follow, true, errorCollector);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
251 //
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
252 // Direction
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
253 h = new CollectWithRenameHandler();
522
2103388d4010 Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 521
diff changeset
254 new HgLogCommand(repo).file(fname2, false, true).order(NewToOld).execute(h);
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
255 report("HgChangesetHandler(renames: false, ancestry:true)", h.getChanges(), fname2Follow, false/*!!!*/, errorCollector);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
256 //
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
257 // TreeChangeHandler - in #testChangesetTreeFollowAncestryNotRenames
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
258 }
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
259
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
260 @Test
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
261 public void testChangesetTreeFollowAncestryNotRenames() throws Exception {
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
262 repo = Configuration.get().find("log-follow");
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
263 final String fname2 = "file1_b";
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
264 final List<Record> fname2Follow = getAncestryWithoutRenamesFromCmdline(fname2);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
265
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
266 TreeCollectHandler h = new TreeCollectHandler(false);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
267 h.checkPrevInParents = true;
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
268 new HgLogCommand(repo).file(fname2, false, true).execute(h);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
269 report("HgChangesetTreeHandler(renames: false, ancestry:true)", h.getResult(), fname2Follow, true, errorCollector);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
270
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
271 // Direction
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
272 h = new TreeCollectHandler(false);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
273 h.checkPrevInChildren = true;
522
2103388d4010 Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 521
diff changeset
274 new HgLogCommand(repo).file(fname2, false, true).order(NewToOld).execute(h);
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
275 report("HgChangesetTreeHandler(renames: false, ancestry:true)", h.getResult(), fname2Follow, false, errorCollector);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
276 }
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
277
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
278
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
279 private List<Record> getAncestryWithoutRenamesFromCmdline(String fname2) throws Exception {
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
280 // 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
281 // 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
282 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
283 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
284 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
285 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
286 // 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
287 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
288 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
289 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
290 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
291 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
292 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
293 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
294 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
295 }
0d5e1ea7955e Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 517
diff changeset
296 }
0d5e1ea7955e Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 517
diff changeset
297 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
298 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
299 }
0d5e1ea7955e Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 517
diff changeset
300 }
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
301 return fname2Follow;
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
302 }
0d5e1ea7955e Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 517
diff changeset
303
0d5e1ea7955e Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 517
diff changeset
304 /**
0d5e1ea7955e Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 517
diff changeset
305 * 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
306 */
0d5e1ea7955e Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 517
diff changeset
307 @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
308 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
309 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
310 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
311 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
312 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
313 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
314
0d5e1ea7955e Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 517
diff changeset
315 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
316 new HgLogCommand(repo).file(fname2, true, true).execute(h);
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
317 errorCollector.assertEquals(1, h.rh.renames.size());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
318 Pair<HgFileRevision, HgFileRevision> rename = h.rh.renames.get(0);
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
319 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
320 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
321 // 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
322 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
323 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
324 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
325 // 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
326 report("HgChangesetHandler(renames: true, ancestry:true)", h.getChanges(), true);
520
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
327 //
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
328 // Switch direction and compare, order shall match that from console
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
329 h = new CollectWithRenameHandler();
522
2103388d4010 Expose option to report changesets in reversed order
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 521
diff changeset
330 new HgLogCommand(repo).file(fname2, true, true).order(NewToOld).execute(h);
520
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
331 // Identical rename event shall be reported
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
332 errorCollector.assertEquals(1, h.rh.renames.size());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
333 rename = h.rh.renames.get(0);
520
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
334 errorCollector.assertEquals(fname1, rename.first().getPath().toString());
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
335 errorCollector.assertEquals(fname2, rename.second().getPath().toString());
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
336 // new to old, recently reported would be the very first revision fname2 pops up
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
337 String firstRevOfFname2 = "27e7a69373b74d42e75f3211e56510ff17d01370";
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
338 errorCollector.assertEquals(firstRevOfFname2, h.lastChangesetReportedAtRename.get(0).getNodeid().toString());
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
339 report("HgChangesetHandler(renames: true, ancestry:true)", h.getChanges(), false /*do not reorder console results !!!*/);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
340 //
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
341 // 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
342 }
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
343
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
344 @Test
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
345 public void testChangesetTreeFollowRenameAndAncestry() throws Exception {
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
346 repo = Configuration.get().find("log-follow");
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
347 final String fname = "file1_b";
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
348 assertTrue("[sanity]", repo.getFileNode(fname).exists());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
349 eh.run("hg", "log", "--debug", "--follow", fname, "--cwd", repo.getLocation());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
350
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
351 TreeCollectHandler h = new TreeCollectHandler(true);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
352 RenameCollector rh = new RenameCollector(h);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
353 h.checkPrevInParents = true;
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
354 new HgLogCommand(repo).file(fname, true, true).execute(h);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
355
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
356 assertEquals(1, h.getAdapterUse(HgFileRenameHandlerMixin.class));
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
357
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
358 report("execute with HgChangesetTreeHandler(follow == true)", h.getResult(), false);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
359
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
360 assertEquals(1, rh.renames.size());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
361 assertEquals(Path.create(fname), rh.renames.get(0).second().getPath());
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
362 }
528
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
363
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
364 /**
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
365 * Ensure {@link HgFileRenameHandlerMixin} is always notified, even
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
366 * if followRename is false.
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
367 * Shall check:
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
368 * both {@link HgLogCommand#execute(HgChangesetHandler)} and {@link HgLogCommand#execute(HgChangesetTreeHandler)}
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
369 * and for both iteration directions in each case
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
370 */
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
371 @Test
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
372 public void testRenameHandlerNotifiedEvenIfNotFollowRename() throws Exception {
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
373 repo = Configuration.get().find("log-follow");
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
374 final String fname1 = "file1_a";
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
375 final String fname2 = "file1_b";
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
376 final String fnameNoRename = "file2";
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
377 assertTrue("[sanity]", repo.getFileNode(fnameNoRename).exists());
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
378
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
379 // first, check that file without renames doesn't report any accidentally
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
380 CollectWithRenameHandler h1 = new CollectWithRenameHandler();
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
381 HgLogCommand cmd = new HgLogCommand(repo).file(fnameNoRename, false, false);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
382 cmd.execute(h1);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
383 errorCollector.assertEquals(0, h1.rh.renames.size());
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
384 TreeCollectHandler h2 = new TreeCollectHandler(false);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
385 RenameCollector rh = new RenameCollector(h2);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
386 cmd.execute(h2);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
387 errorCollector.assertEquals(0, rh.renames.size());
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
388
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
389 // check default iterate direction
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
390 cmd = new HgLogCommand(repo).file(fname2, false, false);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
391 cmd.execute(h1 = new CollectWithRenameHandler());
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
392 errorCollector.assertEquals(1, h1.rh.renames.size());
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
393 assertRename(fname1, fname2, h1.rh.renames.get(0));
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
394
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
395 h2 = new TreeCollectHandler(false);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
396 rh = new RenameCollector(h2);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
397 cmd.execute(h2);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
398 errorCollector.assertEquals(1, rh.renames.size());
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
399 assertRename(fname1, fname2, rh.renames.get(0));
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
400
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
401 eh.run("hg", "log", "--debug", fname2, "--cwd", repo.getLocation());
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
402 report("HgChangesetHandler+RenameHandler with followRenames = false, default iteration order", h1.getChanges(), true);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
403 report("HgChangesetTreeHandler+RenameHandler with followRenames = false, default iteration order", h2.getResult(), true);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
404
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
405 //
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
406 // Now, check that iteration in opposite direction (new to old)
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
407 // still reports renames (and correct revisions, too)
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
408 cmd.order(HgIterateDirection.NewToOld);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
409 cmd.execute(h1 = new CollectWithRenameHandler());
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
410 errorCollector.assertEquals(1, h1.rh.renames.size());
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
411 assertRename(fname1, fname2, h1.rh.renames.get(0));
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
412 h2 = new TreeCollectHandler(false);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
413 rh = new RenameCollector(h2);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
414 cmd.execute(h2);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
415 errorCollector.assertEquals(1, rh.renames.size());
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
416 assertRename(fname1, fname2, rh.renames.get(0));
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
417 report("HgChangesetHandler+RenameHandler with followRenames = false, new2old iteration order", h1.getChanges(), false);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
418 report("HgChangesetTreeHandler+RenameHandler with followRenames = false, new2old iteration order", h2.getResult(), false);
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
419 }
691
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
420
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
421 @Test
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
422 public void testFollowMultipleRenames() throws Exception {
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
423 repo = Configuration.get().find("log-renames");
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
424 String fname = "a";
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
425 eh.run("hg", "log", "--debug", "--follow", fname, "--cwd", repo.getLocation());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
426 HgLogCommand cmd = new HgLogCommand(repo);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
427 cmd.file(fname, true, true);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
428 CollectWithRenameHandler h1;
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
429 //
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
430 cmd.order(OldToNew).execute(h1 = new CollectWithRenameHandler());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
431 errorCollector.assertEquals(2, h1.rh.renames.size());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
432 report("Follow a->c->b, old2new:", h1.getChanges(), true);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
433 //
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
434 cmd.order(NewToOld).execute(h1 = new CollectWithRenameHandler());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
435 errorCollector.assertEquals(2, h1.rh.renames.size());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
436 report("Follow a->c->b, new2old:", h1.getChanges(), false);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
437 //
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
438 //
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
439 TreeCollectHandler h2 = new TreeCollectHandler(false);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
440 RenameCollector rh = new RenameCollector(h2);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
441 cmd.order(OldToNew).execute(h2);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
442 errorCollector.assertEquals(2, rh.renames.size());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
443 report("Tree. Follow a->c->b, old2new:", h2.getResult(), true);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
444 //
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
445 h2 = new TreeCollectHandler(false);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
446 rh = new RenameCollector(h2);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
447 cmd.order(NewToOld).execute(h2);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
448 errorCollector.assertEquals(2, rh.renames.size());
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
449 report("Tree. Follow a->c->b, new2old:", h2.getResult(), false);
72fc7774b87e Fix file.isCopy() for blame/annotate. Refactor status and blame to use newly introduced FileHistory helper that builds file rename history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 628
diff changeset
450 }
528
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
451
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
452 private void assertRename(String fnameFrom, String fnameTo, Pair<HgFileRevision, HgFileRevision> rename) {
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
453 errorCollector.assertEquals(fnameFrom, rename.first().getPath().toString());
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
454 errorCollector.assertEquals(fnameTo, rename.second().getPath().toString());
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
455 }
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
456
520
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
457 /**
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
458 * @see TestAuxUtilities#testChangelogCancelSupport()
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
459 */
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
460 @Test
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
461 public void testLogCommandCancelSupport() throws Exception {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
462 repo = Configuration.get().find("branches-1"); // any repo with more revisions
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
463 class BaseCancel extends TestAuxUtilities.CancelAtValue implements HgChangesetHandler {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
464 BaseCancel(int limit) {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
465 super(limit);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
466 }
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
467 public void cset(HgChangeset changeset) throws HgCallbackTargetException {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
468 nextValue(changeset.getRevisionIndex());
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
469 }
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
470 };
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
471 class ImplementsCancel extends BaseCancel implements CancelSupport {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
472 ImplementsCancel(int limit) {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
473 super(limit);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
474 }
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
475 public void checkCancelled() throws CancelledException {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
476 cancelImpl.checkCancelled();
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
477 }
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
478 };
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
479 class AdaptsToCancel extends BaseCancel implements Adaptable {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
480 AdaptsToCancel(int limit) {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
481 super(limit);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
482 }
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
483 public <T> T getAdapter(Class<T> adapterClass) {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
484 if (adapterClass == CancelSupport.class) {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
485 return adapterClass.cast(cancelImpl);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
486 }
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
487 return null;
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
488 }
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
489 }
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
490
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
491 BaseCancel insp = new ImplementsCancel(3);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
492 try {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
493 new HgLogCommand(repo).execute(insp);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
494 errorCollector.fail("CancelSupport as implemented iface");
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
495 } catch (CancelledException ex) {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
496 errorCollector.assertEquals("CancelSupport as implemented iface", insp.stopValue, insp.lastSeen);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
497 }
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
498 insp = new AdaptsToCancel(5);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
499 try {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
500 new HgLogCommand(repo).execute(insp);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
501 errorCollector.fail("Adaptable to CancelSupport");
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
502 } catch (CancelledException ex) {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
503 errorCollector.assertEquals("Adaptable to CancelSupport", insp.stopValue, insp.lastSeen);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
504 }
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
505 insp = new BaseCancel(9);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
506 try {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
507 new HgLogCommand(repo).set(insp.cancelImpl).execute(insp);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
508 errorCollector.fail("cmd#set(CancelSupport)");
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
509 } catch (CancelledException e) {
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
510 errorCollector.assertEquals("cmd#set(CancelSupport)", insp.stopValue, insp.lastSeen);
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
511 }
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
512 }
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
513
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
514 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
515 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
516 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
517 }
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
518
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
519 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
520 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
521 if (reverseConsoleResult) {
82
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
522 Collections.reverse(consoleResult);
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
523 }
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
524 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
525 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
526 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
527 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
528 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
529 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
530 }
147
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
531 Record cr = consoleResultItr.next();
520
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
532 // flags, not separate checkThat() because when lists are large, and do not match,
1ee452f31187 Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 518
diff changeset
533 // number of failures may slow down test process significantly
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
534 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
535 x |= cs.getDate().toString().equals(cr.date) ? 0x2 : 0;
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
536 x |= cs.getNodeid().toString().equals(cr.changesetNodeid) ? 0x4 : 0;
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
537 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
538 // 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
539 // 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
540 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
541 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
542 consoleResultItr.remove();
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
543 }
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
544 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
545 }
100
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
546
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
547 public void testPerformance() throws Exception {
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
548 final int runs = 10;
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
549 final long start1 = System.currentTimeMillis();
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
550 for (int i = 0; i < runs; i++) {
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
551 changelogParser.reset();
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
552 eh.run("hg", "log", "--debug");
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
553 }
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
554 final long start2 = System.currentTimeMillis();
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
555 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
556 new HgLogCommand(repo).execute();
100
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
557 }
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
558 final long end = System.currentTimeMillis();
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
559 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
560 }
147
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
561
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
562 @Test
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
563 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
564 // 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
565 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
566 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
567 // 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
568 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
569 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
570 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
571 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
572 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
573 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
574 // 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
575 // 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
576 // 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
577 // 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
578 // 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
579 // 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
580
147
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
581 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
582 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
583 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
584 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
585 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
586 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
587 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
588 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
589 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
590 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
591 //
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
592 // 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
593 // 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
594 // 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
595 // 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
596 /*
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
597 * #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
598 * 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
599 * order of revisions.
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
600 */
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
601
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
602 // 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
603 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
604 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
605 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
606 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
607 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
608 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
609 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
610 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
611 //
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
612 // 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
613 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
614 }
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
615
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
616 @Test
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
617 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
618 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
619 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
620 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
621 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
622 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
623 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
624 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
625 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
626 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
627 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
628 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
629 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
630 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
631 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
632 }
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
633
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
634 @Test
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
635 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
636 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
637 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
638 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
639 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
640 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
641 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
642 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
643 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
644 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
645 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
646 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
647 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
648 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
649 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
650 }
508
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
651
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
652 ////
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
653
514
5dcb4581c8ef Report renames when following file history tree with HgFileRenameHandlerMixin
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 510
diff changeset
654 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
655 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
656 private final boolean reverseResult;
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
657 boolean checkPrevInChildren = false; // true when iterating new to old
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
658 boolean checkPrevInParents = false; // true when iterating old to new
508
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
659
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
660 public TreeCollectHandler(boolean _reverseResult) {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
661 this.reverseResult = _reverseResult;
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
662 }
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
663
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
664 public List<HgChangeset> getResult() {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
665 return cmdResult;
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
666 }
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
667
508
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
668
628
6526d8adbc0f Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 528
diff changeset
669 public void treeElement(TreeElement entry) throws HgCallbackTargetException, HgRuntimeException {
508
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
670 // check consistency
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
671 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
672 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
673 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
674 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
675 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
676 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
677 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
678 } else {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
679 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
680 }
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
681 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
682 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
683 } else {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
684 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
685 }
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
686 //
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
687 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
688 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
689 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
690 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
691 }
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
692 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
693 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
694 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
695 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
696 }
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
697 //
508
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
698 if (reverseResult) {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
699 cmdResult.addFirst(entry.changeset());
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
700 } else {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
701 cmdResult.addLast(entry.changeset());
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
702 }
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
703 }
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
704 }
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
705
0d5e1ea7955e Tests for HgLogCommand#execute(HgChangesetHandler) with various combination of follow renames and ancestry
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 517
diff changeset
706 private static class CollectWithRenameHandler extends CollectHandler implements HgChangesetHandler.WithCopyHistory {
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
707 public final RenameCollector rh = new RenameCollector();
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
708 public List<HgChangeset> lastChangesetReportedAtRename = new LinkedList<HgChangeset>();
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
709
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
710 public void copy(HgFileRevision from, HgFileRevision to) throws HgCallbackTargetException {
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
711 Assert.assertTrue("Renames couldn't be reported prior to any change", getChanges().size() > 0);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
712 HgChangeset lastKnown = getChanges().get(getChanges().size() - 1);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
713 lastChangesetReportedAtRename.add(lastKnown);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
714 rh.copy(from, to);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
715 }
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
716 };
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
717
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
718 private static class RenameCollector implements HgFileRenameHandlerMixin {
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
719 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
720 public List<Pair<HgFileRevision, HgFileRevision>> renames = new LinkedList<Pair<HgFileRevision,HgFileRevision>>();
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
721
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
722 public RenameCollector() {
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
723 }
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
724
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
725 public RenameCollector(AdapterPlug ap) {
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
726 ap.attachAdapter(HgFileRenameHandlerMixin.class, this);
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
727 }
528
f7fbf48b9383 Report rename when walking file history regardless of followRenames parameter, solely based on HgFileRenameHandlerMixin presence
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 522
diff changeset
728
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
729 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
730 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
731 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
732 }
521
59e555c85da0 Cover ChangesetTreeHandler with various followRename, followAncestry and direction
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 520
diff changeset
733 }
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
734 }