use of org.zmlx.hg4idea.HgRevisionNumber in project intellij-community by JetBrains.
the class HgUpdateTest method updateShouldNotMergeIfMultipleHeadsBeforeUpdate.
@Test
public void updateShouldNotMergeIfMultipleHeadsBeforeUpdate() throws Exception {
changeFile_A_AndCommitInRemoteRepository();
createAndCommitNewFileInLocalRepository();
//create multiple heads locally
HgUpdateCommand updateCommand = new HgUpdateCommand(myProject, projectRepoVirtualFile);
HgRevisionNumber parent = new HgParentsCommand(myProject).executeInCurrentThread(projectRepoVirtualFile).get(0);
HgParentsCommand parentsCommand = new HgParentsCommand(myProject);
parentsCommand.setRevision(parent);
List<HgRevisionNumber> parents = parentsCommand.executeInCurrentThread(projectRepoVirtualFile);
updateCommand.setRevision(parents.get(0).getChangeset());
updateCommand.execute();
createFileInCommand(projectRepoVirtualFile.findChild("com"), "c.txt", "updated content");
runHg(projectRepo, "commit", "-m", "creating new local head");
List<HgRevisionNumber> branchHeads = new HgHeadsCommand(myProject, projectRepoVirtualFile).executeInCurrentThread();
assertEquals(branchHeads.size(), 2);
HgRevisionNumber parentBeforeUpdate = new HgWorkingCopyRevisionsCommand(myProject).identify(projectRepoVirtualFile).getFirst();
assertUpdateThroughPluginFails();
HgRevisionNumber parentAfterUpdate = new HgWorkingCopyRevisionsCommand(myProject).identify(projectRepoVirtualFile).getFirst();
List<HgRevisionNumber> branchHeadsAfterUpdate = new HgHeadsCommand(myProject, projectRepoVirtualFile).executeInCurrentThread();
assertEquals(branchHeadsAfterUpdate.size(), 3);
assertEquals(parentBeforeUpdate, parentAfterUpdate);
}
use of org.zmlx.hg4idea.HgRevisionNumber in project intellij-community by JetBrains.
the class HgUpdateTest method updateShouldMergeAndCommitChanges.
@Test
public void updateShouldMergeAndCommitChanges() throws Exception {
changeFile_A_AndCommitInRemoteRepository();
createAndCommitNewFileInLocalRepository();
//we've got diverging heads in remote and local now
PreUpdateInformation preUpdateInformation = new PreUpdateInformation().getPreUpdateInformation();
HgRevisionNumber incomingHead = preUpdateInformation.getIncomingHead();
HgRevisionNumber headBeforeUpdate = preUpdateInformation.getHeadBeforeUpdate();
List<VcsException> warnings = updateThroughPlugin();
assertEquals(warnings.size(), 0, "Plain update should not generate warnings");
assertCurrentHeadIsMerge(incomingHead, headBeforeUpdate);
}
use of org.zmlx.hg4idea.HgRevisionNumber in project intellij-community by JetBrains.
the class HgGetDiffForDirTest method testDiffForDir.
public void testDiffForDir() {
cd(myRepository);
touch("A.txt", "dsfdfdsf");
hg("add A.txt");
touch("B.txt");
hg("add B.txt");
hg("commit -m 2files_added");
File dirFile = mkdir("dir");
cd("dir");
touch("C.txt");
touch("D.txt");
hg("add C.txt");
hg("add D.txt");
hg("commit -m createDir");
String[] hash1 = hg("log -l 1 --template=" + SHORT_TEMPLATE_REVISION).split(":");
HgRevisionNumber r1number = HgRevisionNumber.getInstance(hash1[0], hash1[1]);
HgFileRevision rev1 = new HgFileRevision(myProject, new HgFile(myRepository, dirFile), r1number, "", null, "", "", null, null, null, null);
echo("C.txt", "aaaa");
echo("D.txt", "dddd");
hg("commit -m modifyDir");
String[] hash2 = hg("log -l 1 --template=" + SHORT_TEMPLATE_REVISION).split(":");
HgRevisionNumber r2number = HgRevisionNumber.getInstance(hash2[0], hash2[1]);
HgFileRevision rev2 = new HgFileRevision(myProject, new HgFile(myRepository, dirFile), r2number, "", null, "", "", null, null, null, null);
FilePath dirPath = VcsUtil.getFilePath(dirFile, true);
List<Change> changes = HgUtil.getDiff(myProject, myRepository, dirPath, rev1.getRevisionNumber(), rev2.getRevisionNumber());
assertEquals(2, changes.size());
}
use of org.zmlx.hg4idea.HgRevisionNumber in project intellij-community by JetBrains.
the class HgDiffProviderTest method currentRevisionShouldBeTheRevisionInWhichTheFileLastChanged.
@Test
public void currentRevisionShouldBeTheRevisionInWhichTheFileLastChanged() throws Exception {
fillFile(myProjectDir, new String[] { AFILE }, INITIAL_FILE_CONTENT);
addAll();
commitAll("initial content");
fillFile(myProjectDir, new String[] { AFILE }, UPDATED_FILE_CONTENT);
commitAll("updated content");
fillFile(myProjectDir, new String[] { BFILE }, INITIAL_FILE_CONTENT);
commitAll("added new file");
refreshVfs();
HgDiffProvider diffProvider = new HgDiffProvider(myProject);
HgRevisionNumber currentRevision = (HgRevisionNumber) diffProvider.getCurrentRevision(myWorkingCopyDir.findChild(AFILE));
assertNotNull(currentRevision, "The current revision for AFILE should be found");
assertEquals(currentRevision.getRevision(), "1", "The diff provider should return the revision in which AFILE was last changed");
}
Aggregations