use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.
the class HgRealRepositoryReaderTest method testOpenedBranches.
public void testOpenedBranches() {
cd(myRepository);
myRepository.refresh(false, true);
HgRepository hgRepository = HgRepositoryImpl.getInstance(myRepository, myProject, myProject);
hg("up branchA");
hg("commit -m 'close branch' --close-branch");
hgRepository.update();
VcsTestUtil.assertEqualCollections(hgRepository.getOpenedBranches(), Arrays.asList("default", "branchB"));
}
use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.
the class HgReferenceValidatorTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
HgRepository hgRepository = HgRepositoryImpl.getInstance(myRepository, myProject, myProject);
assertNotNull(hgRepository);
myValidator = new HgBranchReferenceValidator(hgRepository);
cd(myRepository);
hg("branch '" + BRANCH_NAME + "'");
String firstFile = "file.txt";
echo(firstFile, BRANCH_NAME);
hg("commit -m 'createdBranch " + BRANCH_NAME + "' ");
hg("branch '" + UNCOMMITTED_BRANCH + "'");
hgRepository.update();
}
use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.
the class HgTaskHandler method mergeAndClose.
@Override
protected void mergeAndClose(@NotNull final String branch, @NotNull final List<HgRepository> repositories) {
String bookmarkRevisionArg = "bookmark(\"" + branch + "\")";
FileDocumentManager.getInstance().saveAllDocuments();
final UpdatedFiles updatedFiles = UpdatedFiles.create();
for (final HgRepository repository : repositories) {
HgMergeCommand.mergeWith(repository, bookmarkRevisionArg, updatedFiles, new Runnable() {
@Override
public void run() {
Project project = repository.getProject();
VirtualFile repositoryRoot = repository.getRoot();
try {
new HgCommitCommand(project, repository, "Automated merge with " + branch).executeInCurrentThread();
HgBookmarkCommand.deleteBookmarkSynchronously(project, repositoryRoot, branch);
} catch (HgCommandException e) {
HgErrorUtil.handleException(project, e);
} catch (VcsException e) {
VcsNotifier.getInstance(project).notifyError("Exception during merge commit with " + branch, e.getMessage());
}
}
});
}
}
use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.
the class HgAbstractGlobalAction method actionPerformed.
public void actionPerformed(@NotNull AnActionEvent event) {
final DataContext dataContext = event.getDataContext();
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
if (project == null) {
return;
}
VirtualFile[] files = event.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY);
final HgRepositoryManager repositoryManager = HgUtil.getRepositoryManager(project);
List<HgRepository> repositories = repositoryManager.getRepositories();
if (!repositories.isEmpty()) {
List<HgRepository> selectedRepositories = files != null ? HgActionUtil.collectRepositoriesFromFiles(repositoryManager, Arrays.asList(files)) : ContainerUtil.<HgRepository>emptyList();
execute(project, repositories, selectedRepositories.isEmpty() ? Collections.singletonList(HgUtil.getCurrentRepository(project)) : selectedRepositories);
}
}
use of org.zmlx.hg4idea.repo.HgRepository 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;
}
Aggregations