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