Search in sources :

Example 21 with HgRevisionNumber

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);
}
Also used : HgRevisionNumber(org.zmlx.hg4idea.HgRevisionNumber) Test(org.testng.annotations.Test)

Example 22 with HgRevisionNumber

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);
}
Also used : HgRevisionNumber(org.zmlx.hg4idea.HgRevisionNumber) VcsException(com.intellij.openapi.vcs.VcsException) Test(org.testng.annotations.Test)

Example 23 with HgRevisionNumber

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());
}
Also used : FilePath(com.intellij.openapi.vcs.FilePath) HgFile(org.zmlx.hg4idea.HgFile) HgRevisionNumber(org.zmlx.hg4idea.HgRevisionNumber) HgFileRevision(org.zmlx.hg4idea.HgFileRevision) Change(com.intellij.openapi.vcs.changes.Change) HgFile(org.zmlx.hg4idea.HgFile) File(java.io.File)

Example 24 with HgRevisionNumber

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");
}
Also used : HgRevisionNumber(org.zmlx.hg4idea.HgRevisionNumber) HgDiffProvider(org.zmlx.hg4idea.provider.HgDiffProvider) Test(org.testng.annotations.Test)

Aggregations

HgRevisionNumber (org.zmlx.hg4idea.HgRevisionNumber)24 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 Test (org.testng.annotations.Test)8 HgFile (org.zmlx.hg4idea.HgFile)6 VcsException (com.intellij.openapi.vcs.VcsException)5 NotNull (org.jetbrains.annotations.NotNull)5 File (java.io.File)4 ArrayList (java.util.ArrayList)4 HgWorkingCopyRevisionsCommand (org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand)4 HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)4 FilePath (com.intellij.openapi.vcs.FilePath)3 HgFileRevision (org.zmlx.hg4idea.HgFileRevision)3 Change (com.intellij.openapi.vcs.changes.Change)2 ItemLatestState (com.intellij.openapi.vcs.diff.ItemLatestState)2 Nullable (org.jetbrains.annotations.Nullable)2 FileAnnotation (com.intellij.openapi.vcs.annotate.FileAnnotation)1 MergeData (com.intellij.openapi.vcs.merge.MergeData)1 SmartList (com.intellij.util.SmartList)1 Hash (com.intellij.vcs.log.Hash)1 VcsRunnable (com.intellij.vcsUtil.VcsRunnable)1