1 // Copyright 2008-2010 Victor Iacoban
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software distributed under
10 // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 // either express or implied. See the License for the specific language governing permissions and
12 // limitations under the License.
13 package org.zmlx.hg4idea.test;
15 import com.intellij.openapi.vfs.VirtualFile;
16 import org.testng.Assert;
17 import org.testng.annotations.Test;
18 import org.zmlx.hg4idea.command.HgResolveCommand;
20 public class HgResolveConflictTestCase extends HgSingleUserTestCase {
22 public static final String BASE = "one\n" +
26 public static final String HEAD_ONE = "one\n" +
27 "conflicting in one\n" +
30 public static final String HEAD_TWO = "one\n" +
31 "conflicting in two\n" +
36 public void testMergeDataIsCorrect() throws Exception {
37 createFileInCommand("conflicting", BASE);
38 runHgOnProjectRepo("commit", "-m", "initial version");
40 createFileInCommand("conflicting", HEAD_ONE);
41 runHgOnProjectRepo("commit", "-m", "first head");
43 //revert to the first commit
44 runHgOnProjectRepo("up", "--clean", "0");
45 createFileInCommand("conflicting", HEAD_TWO);
46 runHgOnProjectRepo("commit", "-m", "second head");
48 runHgOnProjectRepo("--config", "ui.merge=internal:merge", "merge");
50 VirtualFile repoFile = makeFile(myProjectDir);
51 HgResolveCommand.MergeData data = new HgResolveCommand(myProject).getResolveData(repoFile, repoFile.findChild("conflicting"));
53 Assert.assertEquals(data.getBase(), BASE.getBytes(),
54 "The base merge information should correspond to the common ancestor");
55 Assert.assertEquals(data.getLocal(), HEAD_TWO.getBytes(),
56 "The local merge information should correspond to the original parent before the merge");
57 Assert.assertEquals(data.getOther(), HEAD_ONE.getBytes(),
58 "The 'remote' merge information should correspond to the merged in head");