@Test public void localChangesShouldBeAllowedWithFastForwardUpdate() throws Exception { createFileInCommand(projectRepoVirtualFile.findChild("com"), "b.txt", "other file"); runHg(projectRepo, "commit", "-m", "adding second file"); runHg(projectRepo, "push"); runHg(remoteRepo, "update"); changeFile_A_AndCommitInRemoteRepository(); fillFile(projectRepo, new String[] {"com", "b.txt"}, "local change"); createFileInCommand(projectRepoVirtualFile.findChild("com"), "c.txt", "other file"); assertIsChanged(HgFileStatusEnum.MODIFIED, "com", "b.txt"); assertIsChanged(HgFileStatusEnum.ADDED, "com", "c.txt"); PreUpdateInformation information = new PreUpdateInformation().getPreUpdateInformation(); HgRevisionNumber incomingHead = information.getIncomingHead(); List<VcsException> nonFatalWarnings = updateThroughPlugin(); assertTrue(nonFatalWarnings.isEmpty()); HgRevisionNumber parentAfterUpdate = new HgParentsCommand(myProject).execute(projectRepoVirtualFile).get(0); assertEquals(incomingHead, parentAfterUpdate); assertIsChanged(HgFileStatusEnum.MODIFIED, "com", "b.txt"); assertIsChanged(HgFileStatusEnum.ADDED, "com", "c.txt"); }
@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).execute(projectRepoVirtualFile).get(0); HgParentsCommand parentsCommand = new HgParentsCommand(myProject); parentsCommand.setRevision(parent); List<HgRevisionNumber> parents = parentsCommand.execute(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).execute(); 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).execute(); assertEquals(branchHeadsAfterUpdate.size(), 3); assertEquals(parentBeforeUpdate, parentAfterUpdate); }
private void createAndCommitNewFileInLocalRepository() throws IOException { createFileInCommand(projectRepoVirtualFile.findChild("com"), "b.txt", "other file"); runHg(projectRepo, "commit", "-m", "adding non-conflicting history to local repository"); }