annotate test/org/tmatesoft/hg/test/TestHistory.java @ 508:ca5202afea90

Support follow history option when walking file history tree
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 12 Dec 2012 20:52:10 +0100
parents a6435c1a42d0
children a30e74dca193
rev   line source
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
1 /*
423
9c9c442b5f2e Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 282
diff changeset
2 * Copyright (c) 2011-2012 TMate Software Ltd
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
3 *
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
6 * the Free Software Foundation; version 2 of the License.
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
7 *
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
8 * This program is distributed in the hope that it will be useful,
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
11 * GNU General Public License for more details.
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
12 *
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
13 * For information on how to redistribute this software under
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
14 * the terms of a license other than GNU General Public License
102
a3a2e5deb320 Updated contact address to support@hg4j.com
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 101
diff changeset
15 * contact TMate Software at support@hg4j.com
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
16 */
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
17 package org.tmatesoft.hg.test;
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
18
103
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
19 import static org.hamcrest.CoreMatchers.equalTo;
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
20 import static org.hamcrest.CoreMatchers.is;
147
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
21 import static org.junit.Assert.assertTrue;
103
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
22
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
23 import java.util.ArrayList;
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
24 import java.util.Collections;
103
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
25 import java.util.Comparator;
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
26 import java.util.Iterator;
103
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
27 import java.util.LinkedList;
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
28 import java.util.List;
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
29
103
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
30 import org.junit.Rule;
101
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
31 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
32 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
33 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
34 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
35 import org.tmatesoft.hg.core.HgChangesetTreeHandler;
249
4c3b9f679412 Deprecated HgLogCommand.FileRevision gone, top-level HgFileRevision is bright and shiny replacement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 214
diff changeset
36 import org.tmatesoft.hg.core.HgFileRevision;
131
aa1629f36482 Renamed .core classes to start with Hg prefix
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 129
diff changeset
37 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
38 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
39 import org.tmatesoft.hg.core.Nodeid;
101
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
40 import org.tmatesoft.hg.repo.HgLookup;
74
6f1b88693d48 Complete refactoring to org.tmatesoft
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 70
diff changeset
41 import org.tmatesoft.hg.repo.HgRepository;
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
42 import org.tmatesoft.hg.test.LogOutputParser.Record;
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
43 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
44 import org.tmatesoft.hg.util.Path;
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
45
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
46
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
47 /**
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
48 *
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
49 * @author Artem Tikhomirov
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
50 * @author TMate Software Ltd.
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
51 */
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
52 public class TestHistory {
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
53
103
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
54 @Rule
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
55 public ErrorCollectorExt errorCollector = new ErrorCollectorExt();
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
56
147
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
57 private HgRepository repo;
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
58 private final ExecHelper eh;
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
59 private LogOutputParser changelogParser;
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
60
103
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
61 public static void main(String[] args) throws Throwable {
101
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
62 TestHistory th = new TestHistory();
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
63 th.testCompleteLog();
82
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
64 th.testFollowHistory();
103
0b2dcca7de9f ErrorCollector in tests to grab multiple errors
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 102
diff changeset
65 th.errorCollector.verify();
147
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
66 // th.testPerformance();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
67 th.testOriginalTestLogRepo();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
68 th.testUsernames();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
69 th.testBranches();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
70 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
71 th.errorCollector.verify();
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
72 }
101
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
73
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
74 public TestHistory() throws Exception {
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
75 this(new HgLookup().detectFromWorkingDir());
214
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
76 // this(new HgLookup().detect("\\temp\\hg\\hello"));
101
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
77 }
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
78
101
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
79 private TestHistory(HgRepository hgRepo) {
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
80 repo = hgRepo;
282
e51dd9a14b6f Yet another WC status fix, where dirstate parent and base revision are treated right (dirstate parent other than tip and explicit baseRevision are not the same)
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 249
diff changeset
81 eh = new ExecHelper(changelogParser = new LogOutputParser(true), repo.getWorkingDir());
147
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
82
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
83 }
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
84
101
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
85 @Test
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
86 public void testCompleteLog() throws Exception {
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
87 changelogParser.reset();
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
88 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
89 List<HgChangeset> r = new HgLogCommand(repo).execute();
82
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
90 report("hg log - COMPLETE REPO HISTORY", r, true);
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
91 }
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
92
101
777ab7034c1b Switch to JUnit for tests
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 100
diff changeset
93 @Test
82
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
94 public void testFollowHistory() throws Exception {
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
95 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
96 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
97 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
98 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
99
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
100 class H extends CollectHandler implements HgChangesetHandler.WithCopyHistory {
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
101 boolean copyReported = false;
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
102 boolean fromMatched = false;
249
4c3b9f679412 Deprecated HgLogCommand.FileRevision gone, top-level HgFileRevision is bright and shiny replacement
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 214
diff changeset
103 public void copy(HgFileRevision from, HgFileRevision to) {
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
104 copyReported = true;
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
105 fromMatched = "src/com/tmate/hgkit/console/Remote.java".equals(from.getPath().toString());
82
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
106 }
214
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
107 };
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
108 H h = new H();
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
109 new HgLogCommand(repo).file(f, true).execute(h);
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
110 String what = "hg log - FOLLOW FILE HISTORY";
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
111 errorCollector.checkThat(what + "#copyReported ", h.copyReported, is(true));
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
112 errorCollector.checkThat(what + "#copyFromMatched", h.fromMatched, is(true));
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
113 //
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
114 // 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
115 // 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
116 // (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
117 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
118 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
119 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
120 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
121 }
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
122 });
4252faa556cd Use custom timezone identifier to avoid applying daylight savings from the zone guessed
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 202
diff changeset
123 report(what, sorted, false);
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
124 }
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
125
a6435c1a42d0 Test for HgChangesetTreeHandler - make sure nothing is broken prior to adding --follow support
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 468
diff changeset
126 @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
127 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
128 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
129 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
130 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
131 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
132
508
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
133 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
134 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
135 // 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
136 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
137 }
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
138
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
139 @Test
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
140 public void testChangesetTreeFollowRename() throws Exception {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
141 // FIXME better test with more than 1 rename, and renames not from the last revision (somewhere from the middle of the origin change history)
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
142 final String fname = "cmdline/org/tmatesoft/hg/console/Remote.java";
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
143 assertTrue("[sanity]", repo.getFileNode(fname).exists());
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
144 eh.run("hg", "log", "--debug", "--follow", fname);
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
145
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
146 TreeCollectHandler h = new TreeCollectHandler(true);
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
147 new HgLogCommand(repo).file(fname, true).execute(h);
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
148
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
149 report("execute with HgChangesetTreeHandler(follow == true)", h.getResult(), false);
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
150 }
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
151
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
152 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
153 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
154 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
155 }
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
156
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
157 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
158 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
159 if (reverseConsoleResult) {
82
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
160 Collections.reverse(consoleResult);
7255c971dd66 Promitive test for follow file history
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 74
diff changeset
161 }
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
162 errorCollector.checkThat(what + ". Number of changeset reported didn't match", consoleResult.size(), equalTo(hg4jResult.size()));
147
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
163 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
164 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
165 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
166 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
167 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
168 }
147
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
169 Record cr = consoleResultItr.next();
423
9c9c442b5f2e Major refactoring of exception handling. Low-level API uses RuntimeExceptions, while checked are left for higher level
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 282
diff changeset
170 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
171 x |= cs.getDate().toString().equals(cr.date) ? 0x2 : 0;
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
172 x |= cs.getNodeid().toString().equals(cr.changesetNodeid) ? 0x4 : 0;
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
173 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
174 // 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
175 // 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
176 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
177 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
178 consoleResultItr.remove();
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
179 }
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
180 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
181 }
100
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
182
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
183 public void testPerformance() throws Exception {
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
184 final int runs = 10;
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
185 final long start1 = System.currentTimeMillis();
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
186 for (int i = 0; i < runs; i++) {
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
187 changelogParser.reset();
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
188 eh.run("hg", "log", "--debug");
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
189 }
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
190 final long start2 = System.currentTimeMillis();
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
191 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
192 new HgLogCommand(repo).execute();
100
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
193 }
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
194 final long end = System.currentTimeMillis();
b71b3f7d24d4 Primitive performance test
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 95
diff changeset
195 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
196 }
147
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
197
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
198 @Test
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
199 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
200 // 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
201 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
202 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
203 // 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
204 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
205 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
206 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
207 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
208 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
209 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
210 // 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
211 // 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
212 // 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
213 // 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
214 // 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
215 // 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
216
147
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
217 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
218 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
219 eh.run("hg", "log", "--debug", "-f", "e", "--cwd", repo.getLocation());
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
220 report("log -f e", cmd.file("e", true).execute(), false /*#1, below*/);
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
221 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
222 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
223 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
224 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
225 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
226 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
227 //
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
228 // 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
229 // 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
230 // 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
231 // 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
232 /*
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
233 * #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
234 * 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
235 * order of revisions.
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
236 */
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
237
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
238 // 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
239 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
240 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
241 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
242 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
243 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
244 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
245 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
246 report("log -f dir/b", cmd.file("dir/b", true).execute(), false /*#1, below*/);
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
247 //
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
248 // 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
249 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
250 }
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
251
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
252 @Test
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
253 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
254 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
255 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
256 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
257 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
258 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
259 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
260 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
261 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
262 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
263 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
264 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
265 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
266 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
267 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
268 }
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
269
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
270 @Test
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
271 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
272 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
273 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
274 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
275 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
276 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
277 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
278 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
279 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
280 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
281 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
282 //
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
283 changelogParser.reset();
a05145db4d0c Bring test repos along with us to recreate testbench
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 133
diff changeset
284 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
285 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
286 }
508
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
287
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
288 ////
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
289
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
290 private final class TreeCollectHandler implements HgChangesetTreeHandler {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
291 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
292 private final boolean reverseResult;
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
293
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
294 public TreeCollectHandler(boolean _reverseResult) {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
295 this.reverseResult = _reverseResult;
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
296 }
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
297
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
298 public List<HgChangeset> getResult() {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
299 return cmdResult;
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
300 }
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
301
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
302 public void treeElement(TreeElement entry) throws HgCallbackTargetException {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
303 // check consistency
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
304 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
305 errorCollector.assertEquals(entry.changesetRevision(), cset);
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
306 Pair<HgChangeset, HgChangeset> parents_a = entry.parents();
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
307 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
308 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
309 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
310 } else {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
311 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
312 }
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
313 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
314 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
315 } else {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
316 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
317 }
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
318 //
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
319 if (reverseResult) {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
320 cmdResult.addFirst(entry.changeset());
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
321 } else {
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
322 cmdResult.addLast(entry.changeset());
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
323 }
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
324 }
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
325
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
326
ca5202afea90 Support follow history option when walking file history tree
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents: 507
diff changeset
327 }
70
993f6f8e1314 Test for log command
Artem Tikhomirov <tikhomirov.artem@gmail.com>
parents:
diff changeset
328 }