use of org.zmlx.hg4idea.HgFileRevision in project intellij-community by JetBrains.
the class HgLogTest method parseCopied.
private void parseCopied(@NotNull String sourceFileName) throws HgCommandException {
cd(myRepository);
String copiedFileName = "copy".concat(sourceFileName);
touch(sourceFileName);
myRepository.refresh(false, true);
hg("add " + sourceFileName);
hg("commit -m a ");
hg("cp " + sourceFileName + " " + copiedFileName);
myRepository.refresh(false, true);
hg("commit -m a ");
HgLogCommand logCommand = new HgLogCommand(myProject);
logCommand.setFollowCopies(false);
VirtualFile copiedFile = myRepository.findChild(copiedFileName);
assert copiedFile != null;
final HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(copiedFile));
List<HgFileRevision> revisions = logCommand.execute(hgFile, 1, true);
HgFileRevision rev = revisions.get(0);
assertTrue(!rev.getAddedFiles().isEmpty());
}
use of org.zmlx.hg4idea.HgFileRevision in project intellij-community by JetBrains.
the class HgLogTest method testCommitMessagesWithMultipleLines.
@Test
public void testCommitMessagesWithMultipleLines() throws Exception {
fillFile(myProjectDir, new String[] { "file.txt" }, "initial contents");
runHgOnProjectRepo("add", ".");
runHgOnProjectRepo("commit", "-m", "initial\ncontents");
fillFile(myProjectDir, new String[] { "file.txt" }, "updated contents");
runHgOnProjectRepo("commit", "-m", "updated\ncontents");
List<HgFileRevision> fileLog = new HgLogCommand(myProject).execute(getHgFile("file.txt"), 10, false);
assertEquals(fileLog.size(), 2, "The file history should show two entries");
}
use of org.zmlx.hg4idea.HgFileRevision in project intellij-community by JetBrains.
the class HgAnnotationProvider method annotate.
@NotNull
public FileAnnotation annotate(@NotNull VirtualFile file, VcsFileRevision revision) throws VcsException {
final VirtualFile vcsRoot = VcsUtil.getVcsRootFor(myProject, VcsUtil.getFilePath(file.getPath()));
if (vcsRoot == null) {
throw new VcsException("vcs root is null for " + file);
}
HgRevisionNumber revisionNumber = revision != null ? (HgRevisionNumber) revision.getRevisionNumber() : null;
final HgFile hgFile = new HgFile(vcsRoot, VfsUtilCore.virtualToIoFile(file));
HgFile fileToAnnotate = revision instanceof HgFileRevision ? HgUtil.getFileNameInTargetRevision(myProject, revisionNumber, hgFile) : new HgFile(vcsRoot, HgUtil.getOriginalFileName(hgFile.toFilePath(), ChangeListManager.getInstance(myProject)));
final List<HgAnnotationLine> annotationResult = (new HgAnnotateCommand(myProject)).execute(fileToAnnotate, revisionNumber);
//for uncommitted renamed file we should provide local name otherwise --follow will fail
final List<HgFileRevision> logResult = HgHistoryProvider.getHistory(revision == null ? hgFile.toFilePath() : fileToAnnotate.toFilePath(), vcsRoot, myProject, null, -1);
return new HgAnnotation(myProject, hgFile, annotationResult, logResult, revisionNumber != null ? revisionNumber : new HgWorkingCopyRevisionsCommand(myProject).tip(vcsRoot));
}
use of org.zmlx.hg4idea.HgFileRevision in project intellij-community by JetBrains.
the class HgAnnotationProvider method annotate.
@NotNull
@Override
public FileAnnotation annotate(@NotNull FilePath path, @NotNull VcsRevisionNumber revision) throws VcsException {
final VirtualFile vcsRoot = VcsUtil.getVcsRootFor(myProject, path);
if (vcsRoot == null) {
throw new VcsException("vcs root is null for " + path);
}
final HgFile hgFile = new HgFile(vcsRoot, path);
final List<HgAnnotationLine> annotationResult = (new HgAnnotateCommand(myProject)).execute(hgFile, (HgRevisionNumber) revision);
final List<HgFileRevision> logResult = HgHistoryProvider.getHistory(hgFile.toFilePath(), vcsRoot, myProject, (HgRevisionNumber) revision, -1);
return new HgAnnotation(myProject, hgFile, annotationResult, logResult, revision);
}
use of org.zmlx.hg4idea.HgFileRevision in project intellij-community by JetBrains.
the class HgHistoryProvider method reportAppendableHistory.
public void reportAppendableHistory(FilePath filePath, final VcsAppendableHistorySessionPartner partner) throws VcsException {
final VirtualFile vcsRoot = HgUtil.getHgRootOrThrow(myProject, filePath);
final List<HgFileRevision> history = getHistory(filePath, vcsRoot, myProject);
if (history.size() == 0)
return;
final VcsAbstractHistorySession emptySession = createAppendableSession(vcsRoot, Collections.emptyList(), null);
partner.reportCreatedEmptySession(emptySession);
for (HgFileRevision hgFileRevision : history) {
partner.acceptRevision(hgFileRevision);
}
partner.finished();
}
Aggregations