annotate mercurial-tests/src/jetbrains/buildServer/buildTriggers/vcs/mercurial/MercurialVcsSupportTest.java @ 143:0587a0235612 Eluru-6.0.x

Fix TW-15008. Show changed files in all merge commits.
author Dmitry Neverov <dmitry.neverov@jetbrains.com>
date Thu, 23 Dec 2010 16:51:28 +0300
parents 43dd4142b0f5
children 2e90ef872b68 bcc04a74783d
rev   line source
25
7047f643747f license added, preamble added to source code
Pavel.Sher
parents: 21
diff changeset
1 /*
95
6c1cff1f61cc copyright =>2010
Pavel.Sher
parents: 91
diff changeset
2 * Copyright 2000-2010 JetBrains s.r.o.
25
7047f643747f license added, preamble added to source code
Pavel.Sher
parents: 21
diff changeset
3 *
7047f643747f license added, preamble added to source code
Pavel.Sher
parents: 21
diff changeset
4 * Licensed under the Apache License, Version 2.0 (the "License");
7047f643747f license added, preamble added to source code
Pavel.Sher
parents: 21
diff changeset
5 * you may not use this file except in compliance with the License.
7047f643747f license added, preamble added to source code
Pavel.Sher
parents: 21
diff changeset
6 * You may obtain a copy of the License at
7047f643747f license added, preamble added to source code
Pavel.Sher
parents: 21
diff changeset
7 *
7047f643747f license added, preamble added to source code
Pavel.Sher
parents: 21
diff changeset
8 * http://www.apache.org/licenses/LICENSE-2.0
7047f643747f license added, preamble added to source code
Pavel.Sher
parents: 21
diff changeset
9 *
7047f643747f license added, preamble added to source code
Pavel.Sher
parents: 21
diff changeset
10 * Unless required by applicable law or agreed to in writing, software
7047f643747f license added, preamble added to source code
Pavel.Sher
parents: 21
diff changeset
11 * distributed under the License is distributed on an "AS IS" BASIS,
7047f643747f license added, preamble added to source code
Pavel.Sher
parents: 21
diff changeset
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7047f643747f license added, preamble added to source code
Pavel.Sher
parents: 21
diff changeset
13 * See the License for the specific language governing permissions and
7047f643747f license added, preamble added to source code
Pavel.Sher
parents: 21
diff changeset
14 * limitations under the License.
7047f643747f license added, preamble added to source code
Pavel.Sher
parents: 21
diff changeset
15 */
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
16 package jetbrains.buildServer.buildTriggers.vcs.mercurial;
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
17
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
18 import com.intellij.execution.configurations.GeneralCommandLine;
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
19 import jetbrains.buildServer.ExecResult;
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
20 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.CommandUtil;
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
21 import jetbrains.buildServer.buildTriggers.vcs.mercurial.command.Settings;
103
1b80570ddadf TW-10150
Pavel.Sher
parents: 97
diff changeset
22 import jetbrains.buildServer.serverSide.BuildServerListener;
21
c76d6a2b27f6 proper synchronization for working directories
Pavel.Sher
parents: 16
diff changeset
23 import jetbrains.buildServer.serverSide.SBuildServer;
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
24 import jetbrains.buildServer.serverSide.ServerPaths;
103
1b80570ddadf TW-10150
Pavel.Sher
parents: 97
diff changeset
25 import jetbrains.buildServer.util.EventDispatcher;
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
26 import jetbrains.buildServer.vcs.*;
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
27 import jetbrains.buildServer.vcs.impl.VcsRootImpl;
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
28 import jetbrains.buildServer.vcs.patches.PatchBuilderImpl;
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
29 import junit.framework.Assert;
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
30 import org.jetbrains.annotations.NotNull;
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
31 import org.jmock.Mock;
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
32 import org.testng.annotations.BeforeMethod;
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
33 import org.testng.annotations.Test;
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
34
1
56e7f34ca887 added TeamCity libs, fix tests
Pavel.Sher
parents: 0
diff changeset
35 import java.io.ByteArrayOutputStream;
56e7f34ca887 added TeamCity libs, fix tests
Pavel.Sher
parents: 0
diff changeset
36 import java.io.File;
62
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
37 import java.io.FilenameFilter;
1
56e7f34ca887 added TeamCity libs, fix tests
Pavel.Sher
parents: 0
diff changeset
38 import java.io.IOException;
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
39 import java.util.ArrayList;
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
40 import java.util.Arrays;
1
56e7f34ca887 added TeamCity libs, fix tests
Pavel.Sher
parents: 0
diff changeset
41 import java.util.List;
21
c76d6a2b27f6 proper synchronization for working directories
Pavel.Sher
parents: 16
diff changeset
42 import java.util.concurrent.Executors;
c76d6a2b27f6 proper synchronization for working directories
Pavel.Sher
parents: 16
diff changeset
43 import java.util.concurrent.ScheduledExecutorService;
1
56e7f34ca887 added TeamCity libs, fix tests
Pavel.Sher
parents: 0
diff changeset
44
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
45 @Test
34
0052d368c90c initial working version of agent side checkout + some tests
Pavel.Sher
parents: 25
diff changeset
46 public class MercurialVcsSupportTest extends BaseMercurialTestCase {
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
47 private MercurialVcsSupport myVcs;
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
48 private ServerPaths myServerPaths;
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
49
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
50 @BeforeMethod
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
51 protected void setUp() throws Exception {
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
52 super.setUp();
21
c76d6a2b27f6 proper synchronization for working directories
Pavel.Sher
parents: 16
diff changeset
53
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
54 Mock vcsManagerMock = new Mock(VcsManager.class);
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
55 vcsManagerMock.stubs().method("registerVcsSupport");
21
c76d6a2b27f6 proper synchronization for working directories
Pavel.Sher
parents: 16
diff changeset
56 Mock serverMock = new Mock(SBuildServer.class);
c76d6a2b27f6 proper synchronization for working directories
Pavel.Sher
parents: 16
diff changeset
57 ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
c76d6a2b27f6 proper synchronization for working directories
Pavel.Sher
parents: 16
diff changeset
58 serverMock.stubs().method("getExecutor").will(myMockSupport.returnValue(executor));
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
59
103
1b80570ddadf TW-10150
Pavel.Sher
parents: 97
diff changeset
60 EventDispatcher<BuildServerListener> dispatcher = EventDispatcher.create(BuildServerListener.class);
1b80570ddadf TW-10150
Pavel.Sher
parents: 97
diff changeset
61
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
62 File systemDir = myTempFiles.createTempDir();
77
cfbeaf010bd4 prepare to bundle with TeamCity
Pavel.Sher
parents: 62
diff changeset
63 myServerPaths = new ServerPaths(systemDir.getAbsolutePath(), systemDir.getAbsolutePath(), systemDir.getAbsolutePath());
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
64 assertTrue(new File(myServerPaths.getCachesDir()).mkdirs());
103
1b80570ddadf TW-10150
Pavel.Sher
parents: 97
diff changeset
65 myVcs = new MercurialVcsSupport((VcsManager)vcsManagerMock.proxy(), myServerPaths, (SBuildServer)serverMock.proxy(), dispatcher);
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
66 }
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
67
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
68 protected String getTestDataPath() {
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
69 return "mercurial-tests/testData";
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
70 }
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
71
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
72 public void test_get_current_version() throws Exception {
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
73 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo());
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
74
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
75 assertEquals(myVcs.getCurrentVersion(vcsRoot), "10:9c6a6b4aede0");
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
76 assertEquals("9c6a6b4aede0", myVcs.getVersionDisplayName("10:9c6a6b4aede0", vcsRoot));
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
77
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
78 assertEquals(myVcs.getCurrentVersion(createVcsRoot(simpleRepo(), "test_branch")), "8:04c3ae4c6312");
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
79
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
80 assertEquals(myVcs.getCurrentVersion(createVcsRoot(simpleRepo(), "name with space")), "9:9babcf2d5705");
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
81 }
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
82
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
83 private List<ModificationData> collectChanges(@NotNull VcsRoot vcsRoot, @NotNull String from, @NotNull String to, @NotNull IncludeRule rule) throws VcsException {
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
84 return ((CollectChangesByIncludeRules)myVcs.getCollectChangesPolicy()).getChangeCollector(vcsRoot, from, to).collectChanges(rule);
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
85 }
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
86
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
87 public void test_collect_changes() throws Exception {
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
88 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo());
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
89
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
90 List<ModificationData> changes = collectChanges(vcsRoot, "0:9875b412a788", "3:9522278aa38d", new CheckoutRules("").getIncludeRuleFor(""));
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
91 assertEquals(3, changes.size());
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
92
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
93 ModificationData md1 = changes.get(0);
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
94 ModificationData md2 = changes.get(1);
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
95 ModificationData md3 = changes.get(2);
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
96 assertEquals(md1.getVersion(), "1:1d446e82d356");
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
97 assertEquals(md1.getDescription(), "new file added");
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
98 List<VcsChange> files1 = md1.getChanges();
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
99 assertEquals(1, files1.size());
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
100 assertEquals(VcsChangeInfo.Type.ADDED, files1.get(0).getType());
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
101 assertEquals(normalizePath(files1.get(0).getRelativeFileName()), "dir1/file3.txt");
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
102
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
103 assertEquals(md2.getVersion(), "2:7209b1f1d793");
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
104 assertEquals(md2.getDescription(), "file4.txt added");
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
105 List<VcsChange> files2 = md2.getChanges();
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
106 assertEquals(1, files2.size());
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
107 assertEquals(files2.get(0).getType(), VcsChangeInfo.Type.ADDED);
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
108 assertEquals(normalizePath(files2.get(0).getRelativeFileName()), "dir1/file4.txt");
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
109
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
110 assertEquals(md3.getVersion(), "3:9522278aa38d");
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
111 assertEquals(md3.getDescription(), "file removed");
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
112 List<VcsChange> files3 = md3.getChanges();
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
113 assertEquals(1, files3.size());
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
114 assertEquals(files3.get(0).getType(), VcsChangeInfo.Type.REMOVED);
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
115 assertEquals(normalizePath(files3.get(0).getRelativeFileName()), "dir1/file4.txt");
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
116 }
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
117
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
118 public void test_collect_changes_with_not_empty_include_rule() throws Exception {
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
119 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo());
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
120
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
121 List<ModificationData> changes = collectChanges(vcsRoot, "0:9875b412a788", "5:1d2cc6f3bc29", new IncludeRule("dir1/subdir", "dir1/subdir", null));
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
122 assertEquals(changes.size(), 1, changes.toString());
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
123
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
124 ModificationData md = changes.get(0);
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
125 assertEquals(md.getDescription(), "modified in subdir");
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
126
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
127 List<VcsChange> files = changes.get(0).getChanges();
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
128 assertEquals(files.size(), 1, files.toString());
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
129 assertEquals("dir1/subdir/file2.txt", files.get(0).getFileName());
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
130 assertEquals("file2.txt", files.get(0).getRelativeFileName());
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
131 }
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
132
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
133 private ByteArrayOutputStream buildPatch(VcsRoot vcsRoot, String from, String to, CheckoutRules rules) throws IOException, VcsException {
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
134 final ByteArrayOutputStream output = new ByteArrayOutputStream();
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
135 final PatchBuilderImpl builder = new PatchBuilderImpl(output);
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
136
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
137 ((BuildPatchByCheckoutRules)myVcs.getBuildPatchPolicy()).buildPatch(vcsRoot, from, to, builder, rules);
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
138 builder.close();
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
139 return output;
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
140 }
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
141
62
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
142 @Test
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
143 public void test_build_patch() throws IOException, VcsException {
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
144 setName("cleanPatch1");
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
145 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo());
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
146
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
147 ByteArrayOutputStream output = buildPatch(vcsRoot, null, "4:b06a290a363b", new CheckoutRules(""));
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
148 checkPatchResult(output.toByteArray());
62
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
149
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
150 File clonedReposParentDir = new File(myServerPaths.getCachesDir(), "mercurial");
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
151 assertTrue(clonedReposParentDir.isDirectory());
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
152 assertTrue(1 == clonedReposParentDir.list(new FilenameFilter() {
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
153 public boolean accept(final File dir, final String name) {
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
154 return name.startsWith("hg_");
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
155 }
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
156 }).length);
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
157 }
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
158
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
159 public void test_build_incremental_patch() throws IOException, VcsException {
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
160 setName("patch1");
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
161 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo());
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
162
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
163 ByteArrayOutputStream output = buildPatch(vcsRoot, "3:9522278aa38d", "4:b06a290a363b", new CheckoutRules(""));
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
164
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
165 checkPatchResult(output.toByteArray());
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
166 }
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
167
79
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
168 public void test_build_incremental_patch_checkout_rules() throws IOException, VcsException {
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
169 setName("patch1_checkout_rules");
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
170 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo());
79
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
171
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
172 ByteArrayOutputStream output = buildPatch(vcsRoot, "3:9522278aa38d", "4:b06a290a363b", new CheckoutRules("+:dir1=>path"));
79
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
173
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
174 checkPatchResult(output.toByteArray());
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
175 }
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
176
97
3ac056b1932e TW-10928
Pavel.Sher
parents: 95
diff changeset
177 public void test_build_clean_patch_checkout_rules() throws IOException, VcsException {
3ac056b1932e TW-10928
Pavel.Sher
parents: 95
diff changeset
178 setName("cleanPatch1_checkout_rules");
3ac056b1932e TW-10928
Pavel.Sher
parents: 95
diff changeset
179 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo());
3ac056b1932e TW-10928
Pavel.Sher
parents: 95
diff changeset
180
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
181 ByteArrayOutputStream output = buildPatch(vcsRoot, null, "4:b06a290a363b", new CheckoutRules("+:dir1/subdir=>."));
97
3ac056b1932e TW-10928
Pavel.Sher
parents: 95
diff changeset
182
3ac056b1932e TW-10928
Pavel.Sher
parents: 95
diff changeset
183 checkPatchResult(output.toByteArray());
3ac056b1932e TW-10928
Pavel.Sher
parents: 95
diff changeset
184 }
3ac056b1932e TW-10928
Pavel.Sher
parents: 95
diff changeset
185
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
186 public void test_build_incremental_patch_file_with_space() throws IOException, VcsException {
40
6a535d51079a new test
Pavel.Sher
parents: 34
diff changeset
187 setName("patch2");
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
188 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo());
40
6a535d51079a new test
Pavel.Sher
parents: 34
diff changeset
189
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
190 ByteArrayOutputStream output = buildPatch(vcsRoot, "3:9522278aa38d", "6:b9deb9a1c6f4", new CheckoutRules(""));
40
6a535d51079a new test
Pavel.Sher
parents: 34
diff changeset
191
6a535d51079a new test
Pavel.Sher
parents: 34
diff changeset
192 checkPatchResult(output.toByteArray());
6a535d51079a new test
Pavel.Sher
parents: 34
diff changeset
193 }
6a535d51079a new test
Pavel.Sher
parents: 34
diff changeset
194
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
195 public void test_get_content() throws IOException, VcsException {
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
196 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo());
12
6989ac0f8cac getContent supported
Pavel.Sher
parents: 8
diff changeset
197
6989ac0f8cac getContent supported
Pavel.Sher
parents: 8
diff changeset
198 byte[] content = myVcs.getContent("dir1/subdir/file2.txt", vcsRoot, "4:b06a290a363b");
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
199 assertEquals(new String(content), "bbb");
13
26505742bae5 disable test connection
Pavel.Sher
parents: 12
diff changeset
200 content = myVcs.getContent("dir1/subdir/file2.txt", vcsRoot, "5:1d2cc6f3bc29");
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
201 assertEquals(new String(content), "modified\r\nbbb");
12
6989ac0f8cac getContent supported
Pavel.Sher
parents: 8
diff changeset
202 }
6989ac0f8cac getContent supported
Pavel.Sher
parents: 8
diff changeset
203
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
204 public void test_get_content_in_branch() throws IOException, VcsException {
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
205 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo(), "test_branch");
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
206
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
207 byte[] content = myVcs.getContent("file_in_branch.txt", vcsRoot, "8:04c3ae4c6312");
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
208 assertEquals(new String(content), "file from the test_branch\r\nfile modified");
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
209 }
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
210
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
211 public void test_test_connection() throws IOException, VcsException {
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
212 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo());
16
7aa397165fa0 identify command added, test connection now uses identify command
Pavel.Sher
parents: 13
diff changeset
213
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
214 System.out.println(myVcs.getTestConnectionSupport().testConnection(vcsRoot));
16
7aa397165fa0 identify command added, test connection now uses identify command
Pavel.Sher
parents: 13
diff changeset
215
7aa397165fa0 identify command added, test connection now uses identify command
Pavel.Sher
parents: 13
diff changeset
216 vcsRoot.addProperty(Constants.REPOSITORY_PROP, "/some/non/existent/path");
7aa397165fa0 identify command added, test connection now uses identify command
Pavel.Sher
parents: 13
diff changeset
217 try {
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
218 myVcs.getTestConnectionSupport().testConnection(vcsRoot);
16
7aa397165fa0 identify command added, test connection now uses identify command
Pavel.Sher
parents: 13
diff changeset
219 fail("Exception expected");
7aa397165fa0 identify command added, test connection now uses identify command
Pavel.Sher
parents: 13
diff changeset
220 } catch (VcsException e) {
7aa397165fa0 identify command added, test connection now uses identify command
Pavel.Sher
parents: 13
diff changeset
221 }
7aa397165fa0 identify command added, test connection now uses identify command
Pavel.Sher
parents: 13
diff changeset
222 }
7aa397165fa0 identify command added, test connection now uses identify command
Pavel.Sher
parents: 13
diff changeset
223
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
224 public void test_tag() throws IOException, VcsException {
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
225 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo());
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
226 cleanRepositoryAfterTest(simpleRepo());
44
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
227
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
228 String actualTag = myVcs.label("new:tag", "1:1d446e82d356", vcsRoot, new CheckoutRules(""));
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
229 assertEquals(actualTag, "new_tag");
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
230
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
231 // check the tag is pushed to the parent repository
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
232 GeneralCommandLine cli = new GeneralCommandLine();
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
233 cli.setExePath(vcsRoot.getProperty(Constants.HG_COMMAND_PATH_PROP));
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
234 cli.setWorkDirectory(vcsRoot.getProperty(Constants.REPOSITORY_PROP));
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
235 cli.addParameter("tags");
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
236 ExecResult res = CommandUtil.runCommand(cli);
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
237 assertTrue(res.getStdout().contains("new_tag"));
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
238 assertTrue(res.getStdout().contains("1:1d446e82d356"));
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
239 }
1490e2981799 labeling/tagging support
Pavel.Sher
parents: 42
diff changeset
240
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
241 public void test_tag_in_branch() throws IOException, VcsException {
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
242 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo(), "test_branch");
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
243 cleanRepositoryAfterTest(simpleRepo());
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
244
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
245 String actualTag = myVcs.label("branch_tag", "7:376dcf05cd2a", vcsRoot, new CheckoutRules(""));
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
246 assertEquals(actualTag, "branch_tag");
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
247
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
248 // check the tag is pushed to the parent repository
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
249 GeneralCommandLine cli = new GeneralCommandLine();
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
250 cli.setExePath(vcsRoot.getProperty(Constants.HG_COMMAND_PATH_PROP));
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
251 cli.setWorkDirectory(vcsRoot.getProperty(Constants.REPOSITORY_PROP));
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
252 cli.addParameter("tags");
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
253 ExecResult res = CommandUtil.runCommand(cli);
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
254 assertTrue(res.getStdout().contains("branch_tag"));
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
255 assertTrue(res.getStdout().contains("7:376dcf05cd2a"));
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
256 }
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
257
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
258 public void test_collect_changes_in_branch() throws Exception {
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
259 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo(), "test_branch");
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
260
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
261 // fromVersion(6:b9deb9a1c6f4) is not in the branch (it is in the default branch)
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
262 List<ModificationData> changes = collectChanges(vcsRoot, "6:b9deb9a1c6f4", "7:376dcf05cd2a", IncludeRule.createDefaultInstance());
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
263 assertEquals(1, changes.size());
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
264
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
265 ModificationData md1 = changes.get(0);
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
266 assertEquals(md1.getVersion(), "7:376dcf05cd2a");
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
267 assertEquals(md1.getDescription(), "new file added in the test_branch");
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
268 List<VcsChange> files1 = md1.getChanges();
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
269 assertEquals(1, files1.size());
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
270 assertEquals(VcsChangeInfo.Type.ADDED, files1.get(0).getType());
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
271 assertEquals(normalizePath(files1.get(0).getRelativeFileName()), "file_in_branch.txt");
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
272
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
273 changes = collectChanges(vcsRoot, "7:376dcf05cd2a", "8:04c3ae4c6312", IncludeRule.createDefaultInstance());
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
274 assertEquals(1, changes.size());
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
275
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
276 md1 = changes.get(0);
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
277 assertEquals(md1.getVersion(), "8:04c3ae4c6312");
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
278 assertEquals(md1.getDescription(), "file modified");
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
279 }
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
280
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
281 public void test_full_patch_from_branch() throws IOException, VcsException {
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
282 setName("patch3");
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
283 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo(), "test_branch");
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
284
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
285 ByteArrayOutputStream output = buildPatch(vcsRoot, null, "7:376dcf05cd2a", new CheckoutRules(""));
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
286
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
287 checkPatchResult(output.toByteArray());
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
288 }
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
289
79
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
290 public void test_full_patch_from_branch_with_checkout_rules() throws IOException, VcsException {
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
291 setName("patch3_checkout_rules1");
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
292 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo(), "test_branch");
79
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
293
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
294 ByteArrayOutputStream output = buildPatch(vcsRoot, null, "7:376dcf05cd2a", new CheckoutRules("+:.=>path"));
79
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
295
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
296 checkPatchResult(output.toByteArray());
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
297 }
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
298
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
299 public void test_full_patch_from_branch_with_checkout_rules_mapped_and_skipped() throws IOException, VcsException {
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
300 setName("patch3_checkout_rules2");
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
301 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo(), "test_branch");
79
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
302
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
303 ByteArrayOutputStream output = buildPatch(vcsRoot, null, "7:376dcf05cd2a", new CheckoutRules("+:dir1=>path/dir1\n+:dir with space"));
79
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
304
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
305 checkPatchResult(output.toByteArray());
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
306 }
2e57d4e3f7b7 support checkout rules for server side patch
Pavel.Sher
parents: 77
diff changeset
307
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
308 public void test_incremental_patch_from_branch() throws IOException, VcsException {
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
309 setName("patch4");
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
310 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo(), "test_branch");
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
311
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
312 ByteArrayOutputStream output = buildPatch(vcsRoot, "7:376dcf05cd2a", "8:04c3ae4c6312", new CheckoutRules(""));
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
313
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
314 checkPatchResult(output.toByteArray());
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
315 }
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
316
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
317 @Test(enabled = false)
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
318 public void support_anchor_branch_notation() throws IOException {
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
319 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo());
57
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
320 String repPath = vcsRoot.getProperty(Constants.REPOSITORY_PROP);
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
321 vcsRoot.addProperty(Constants.REPOSITORY_PROP, repPath + "#test_branch");
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
322 Settings settings = new Settings(new File(myServerPaths.getCachesDir()), vcsRoot);
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
323 assertEquals("test_branch", settings.getBranchName());
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
324
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
325 vcsRoot.addProperty(Constants.REPOSITORY_PROP, repPath + "#");
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
326 settings = new Settings(new File(myServerPaths.getCachesDir()), vcsRoot);
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
327 assertEquals("default", settings.getBranchName());
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
328
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
329 vcsRoot.addProperty(Constants.REPOSITORY_PROP, repPath);
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
330 settings = new Settings(new File(myServerPaths.getCachesDir()), vcsRoot);
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
331 assertEquals("default", settings.getBranchName());
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
332 }
99e757f2527b branches support
Pavel.Sher
parents: 55
diff changeset
333
62
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
334 public void build_patch_using_custom_clone_path() throws IOException, VcsException {
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
335 setName("cleanPatch1");
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
336 VcsRootImpl vcsRoot = createVcsRoot(simpleRepo());
62
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
337 File cloneDir = myTempFiles.createTempDir();
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
338 vcsRoot.addProperty(Constants.SERVER_CLONE_PATH_PROP, cloneDir.getAbsolutePath());
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
339
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
340 ByteArrayOutputStream output = buildPatch(vcsRoot, null, "4:b06a290a363b", new CheckoutRules(""));
62
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
341
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
342 checkPatchResult(output.toByteArray());
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
343
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
344 assertTrue(new File(cloneDir, new File(vcsRoot.getProperty(Constants.REPOSITORY_PROP)).getName()).isDirectory());
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
345 }
b328c6b6526d TW-5636: Mercurial plugin can easilly hit Windows MAX_PATH limitations
Pavel.Sher
parents: 57
diff changeset
346
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
347 private String mergeCommittsRepo() {
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
348 return new File("mercurial-tests/testData/rep2").getAbsolutePath();
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
349 }
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
350
91
99fc78c3e8db one more test
Pavel.Sher
parents: 90
diff changeset
351 public void test_collect_changes_merge() throws Exception {
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
352 VcsRootImpl vcsRoot = createVcsRoot(mergeCommittsRepo());
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
353
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
354 List<ModificationData> changes = collectChanges(vcsRoot, "1:a3d15477d297", "4:6eeb8974fe67", IncludeRule.createDefaultInstance());
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
355 assertEquals(changes.size(), 3);
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
356
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
357 assertEquals("2:db8a04d262f3", changes.get(0).getVersion());
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
358 assertEquals("3:2538c02bafeb", changes.get(1).getVersion());
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
359 assertEquals("4:6eeb8974fe67", changes.get(2).getVersion());
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
360
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
361 assertFiles(Arrays.asList("A dir1/file1.txt"), changes.get(0));
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
362 assertFiles(Arrays.asList("A dir2/file2.txt"), changes.get(1));
143
0587a0235612 Fix TW-15008. Show changed files in all merge commits.
Dmitry Neverov <dmitry.neverov@jetbrains.com>
parents: 137
diff changeset
363 assertFiles(Arrays.asList("A dir1/file1.txt", "A dir2/file2.txt"), changes.get(2));
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
364 }
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
365
91
99fc78c3e8db one more test
Pavel.Sher
parents: 90
diff changeset
366 public void test_collect_changes_merge_conflict() throws Exception {
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
367 VcsRootImpl vcsRoot = createVcsRoot(mergeCommittsRepo());
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
368
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
369 List<ModificationData> changes = collectChanges(vcsRoot, "6:6066b677d026", "8:b6e2d176fe8e", IncludeRule.createDefaultInstance());
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
370 assertEquals(changes.size(), 2);
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
371
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
372 assertFiles(Arrays.asList("A dir4/file41.txt"), changes.get(0));
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
373 assertFiles(Arrays.asList("M dir4/file41.txt", "A dir4/file42.txt", "A dir4/file43.txt", "R dir3/file3.txt"), changes.get(1));
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
374 }
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
375
91
99fc78c3e8db one more test
Pavel.Sher
parents: 90
diff changeset
376 public void test_collect_changes_merge_conflict_named_branch() throws Exception {
99fc78c3e8db one more test
Pavel.Sher
parents: 90
diff changeset
377 VcsRootImpl vcsRoot = createVcsRoot(mergeCommittsRepo());
99fc78c3e8db one more test
Pavel.Sher
parents: 90
diff changeset
378
106
8587a9c22d55 switch to new API
Pavel.Sher
parents: 103
diff changeset
379 List<ModificationData> changes = collectChanges(vcsRoot, "8:b6e2d176fe8e", "12:1e620196c4b6", IncludeRule.createDefaultInstance());
91
99fc78c3e8db one more test
Pavel.Sher
parents: 90
diff changeset
380 assertEquals(changes.size(), 2);
99fc78c3e8db one more test
Pavel.Sher
parents: 90
diff changeset
381
99fc78c3e8db one more test
Pavel.Sher
parents: 90
diff changeset
382 assertFiles(Arrays.asList("A dir6/file6.txt"), changes.get(0));
99fc78c3e8db one more test
Pavel.Sher
parents: 90
diff changeset
383 assertFiles(Arrays.asList("M dir6/file6.txt", "A dir5/file5.txt"), changes.get(1));
99fc78c3e8db one more test
Pavel.Sher
parents: 90
diff changeset
384 }
99fc78c3e8db one more test
Pavel.Sher
parents: 90
diff changeset
385
90
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
386 private void assertFiles(final List<String> expectedFiles, final ModificationData modificationData) {
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
387 List<String> actualFiles = new ArrayList<String>();
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
388 for (VcsChange vc: modificationData.getChanges()) {
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
389 actualFiles.add(toFileStatus(vc.getType()) + " " + vc.getRelativeFileName());
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
390 }
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
391 Assert.assertEquals("Actual files: " + actualFiles.toString(), expectedFiles, actualFiles);
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
392 }
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
393
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
394 private String toFileStatus(VcsChange.Type type) {
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
395 switch (type) {
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
396 case ADDED:
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
397 return "A";
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
398 case REMOVED:
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
399 return "R";
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
400 case CHANGED:
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
401 return "M";
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
402 }
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
403 return "?";
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
404 }
5d9c34cb543a improving merge commits reporting
Pavel.Sher
parents: 88
diff changeset
405
0
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
406 private Object normalizePath(final String path) {
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
407 return path.replace(File.separatorChar, '/');
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
408 }
a530ea876f55 mercurial support sources added
Pavel.Sher
parents:
diff changeset
409 }