use of org.zmlx.hg4idea.HgRevisionNumber in project intellij-community by JetBrains.
the class HgAnnotationTest method checkAnnotation.
private void checkAnnotation(String name, String revisionNum, String expectedContent) throws VcsException {
FileAnnotation fileAnnotation = myHgAnnotationProvider.annotate(VcsUtil.getFilePath(new File(myRepository.getPath(), name)), HgRevisionNumber.getInstance(revisionNum, revisionNum));
final HgRevisionNumber actualRevisionNumber = (HgRevisionNumber) fileAnnotation.getLineRevisionNumber(0);
assert actualRevisionNumber != null;
assertEquals(revisionNum, actualRevisionNumber.getRevision());
assertEquals(expectedContent, fileAnnotation.getAnnotatedContent());
}
use of org.zmlx.hg4idea.HgRevisionNumber in project intellij-community by JetBrains.
the class HgCompareWithBranchAction method getDiffChanges.
@Override
@NotNull
protected Collection<Change> getDiffChanges(@NotNull Project project, @NotNull VirtualFile file, @NotNull String branchToCompare) throws VcsException {
HgRepository repository = getRepositoryManager(project).getRepositoryForFile(file);
if (repository == null) {
throw new VcsException("Couldn't find repository for " + file.getName());
}
final FilePath filePath = VcsUtil.getFilePath(file);
final VirtualFile repositoryRoot = repository.getRoot();
final HgFile hgFile = new HgFile(repositoryRoot, filePath);
Hash refHashToCompare = detectActiveHashByName(repository, branchToCompare);
if (refHashToCompare == null) {
throw new VcsException(String.format("Couldn't detect commit related to %s name for %s.", branchToCompare, file));
}
final HgRevisionNumber compareWithRevisionNumber = HgRevisionNumber.getInstance(branchToCompare, refHashToCompare.toString());
List<Change> changes = HgUtil.getDiff(project, repositoryRoot, filePath, compareWithRevisionNumber, null);
if (changes.isEmpty() && !existInBranch(repository, filePath, compareWithRevisionNumber)) {
throw new VcsException(fileDoesntExistInBranchError(file, branchToCompare));
}
return changes.isEmpty() && !filePath.isDirectory() ? createChangesWithCurrentContentForFile(filePath, HgContentRevision.create(project, hgFile, compareWithRevisionNumber)) : changes;
}
use of org.zmlx.hg4idea.HgRevisionNumber in project intellij-community by JetBrains.
the class HgUpdateTest method assertCurrentHeadIsMerge.
private void assertCurrentHeadIsMerge(HgRevisionNumber incomingHead, HgRevisionNumber headBeforeUpdate) {
List<HgRevisionNumber> newHeads = new HgHeadsCommand(myProject, projectRepoVirtualFile).executeInCurrentThread();
assertEquals(newHeads.size(), 1, "After updating, there should be only one head because the remote heads should have been merged");
HgRevisionNumber newHead = newHeads.get(0);
HgParentsCommand parents = new HgParentsCommand(myProject);
parents.setRevision(newHead);
List<HgRevisionNumber> parentRevisions = parents.executeInCurrentThread(projectRepoVirtualFile);
assertEquals(parentRevisions.size(), 2);
assertTrue(parentRevisions.contains(incomingHead));
assertTrue(parentRevisions.contains(headBeforeUpdate));
}
use of org.zmlx.hg4idea.HgRevisionNumber in project intellij-community by JetBrains.
the class HgUpdateTest method updateKeepsWorkingAfterPull.
@Test
public void updateKeepsWorkingAfterPull() throws Exception {
changeFile_A_AndCommitInRemoteRepository();
//do a simple pull without an update
HgPullCommand pull = new HgPullCommand(myProject, projectRepoVirtualFile);
pull.setSource(HgUtil.getRepositoryDefaultPath(myProject, projectRepoVirtualFile));
pull.executeInCurrentThread();
assertEquals(determineNumberOfIncomingChanges(projectRepo), 0, "The update operation should have pulled the incoming changes from the default repository.");
updateThroughPlugin();
HgRevisionNumber parentRevision = new HgWorkingCopyRevisionsCommand(myProject).firstParent(projectRepoVirtualFile);
assertEquals(parentRevision.getRevision(), "1", "The working directory should have been updated to the latest version");
}
use of org.zmlx.hg4idea.HgRevisionNumber in project intellij-community by JetBrains.
the class HgUpdateTest method updateShouldMergeButNotCommitWithConflicts.
@Test
public void updateShouldMergeButNotCommitWithConflicts() throws Exception {
changeFile_A_AndCommitInRemoteRepository();
VirtualFile commonFile = projectRepoVirtualFile.findChild("com").findChild("a.txt");
assertNotNull(commonFile);
VcsTestUtil.editFileInCommand(myProject, commonFile, "conflicting content");
runHg(projectRepo, "commit", "-m", "adding conflicting history to local repository");
PreUpdateInformation preUpdateInformation = new PreUpdateInformation().getPreUpdateInformation();
HgRevisionNumber incomingHead = preUpdateInformation.getIncomingHead();
HgRevisionNumber headBeforeUpdate = preUpdateInformation.getHeadBeforeUpdate();
List<VcsException> warnings = updateThroughPlugin();
assertFalse(warnings.isEmpty());
assertTrue(warnings.get(warnings.size() - 1).getMessage().contains("conflicts"));
assertTrue(warnings.get(warnings.size() - 1).getMessage().contains("commit"));
List<HgRevisionNumber> parents = new HgWorkingCopyRevisionsCommand(myProject).parents(projectRepoVirtualFile);
assertEquals(parents.size(), 2);
assertTrue(parents.contains(incomingHead));
assertTrue(parents.contains(headBeforeUpdate));
}
Aggregations