Search in sources :

Example 1 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.

the class HgPusher method push.

@Override
public void push(@NotNull Map<HgRepository, PushSpec<HgPushSource, HgTarget>> pushSpecs, @Nullable VcsPushOptionValue vcsPushOptionValue, boolean force) {
    for (Map.Entry<HgRepository, PushSpec<HgPushSource, HgTarget>> entry : pushSpecs.entrySet()) {
        HgRepository repository = entry.getKey();
        PushSpec<HgPushSource, HgTarget> hgSpec = entry.getValue();
        HgTarget destination = hgSpec.getTarget();
        HgPushSource source = hgSpec.getSource();
        Project project = repository.getProject();
        final HgPushCommand pushCommand = new HgPushCommand(project, repository.getRoot(), destination.myTarget);
        // set always true, because it just allow mercurial to create a new one if needed
        pushCommand.setIsNewBranch(true);
        pushCommand.setForce(force);
        String branchName = source.getBranch();
        if (branchName.equals(repository.getCurrentBookmark())) {
            if (vcsPushOptionValue == HgVcsPushOptionValue.Current) {
                pushCommand.setBookmarkName(branchName);
            } else {
                pushCommand.setRevision(branchName);
            }
        } else {
            pushCommand.setBranchName(branchName);
        }
        pushSynchronously(project, pushCommand);
    }
}
Also used : PushSpec(com.intellij.dvcs.push.PushSpec) HgPushCommand(org.zmlx.hg4idea.command.HgPushCommand) Project(com.intellij.openapi.project.Project) HgRepository(org.zmlx.hg4idea.repo.HgRepository) Map(java.util.Map)

Example 2 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.

the class HgUtil method sortByHgRoots.

@NotNull
public static Map<VirtualFile, Collection<VirtualFile>> sortByHgRoots(@NotNull Project project, @NotNull Collection<VirtualFile> files) {
    Map<VirtualFile, Collection<VirtualFile>> sorted = new HashMap<>();
    HgRepositoryManager repositoryManager = getRepositoryManager(project);
    for (VirtualFile file : files) {
        HgRepository repo = repositoryManager.getRepositoryForFile(file);
        if (repo == null) {
            continue;
        }
        Collection<VirtualFile> filesForRoot = sorted.get(repo.getRoot());
        if (filesForRoot == null) {
            filesForRoot = new HashSet<>();
            sorted.put(repo.getRoot(), filesForRoot);
        }
        filesForRoot.add(file);
    }
    return sorted;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) AbstractVcsVirtualFile(com.intellij.openapi.vcs.vfs.AbstractVcsVirtualFile) HgRepositoryManager(org.zmlx.hg4idea.repo.HgRepositoryManager) HgRepository(org.zmlx.hg4idea.repo.HgRepository) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.

the class HgEncodingTest method testCommitUtfMessage.

//test for  default EncodingProject settings
public void testCommitUtfMessage() throws HgCommandException, VcsException {
    cd(myRepository);
    echo("file.txt", "lalala");
    HgRepository hgRepo = HgRepositoryImpl.getInstance(myRepository, myProject, myProject);
    HgCommitCommand commitCommand = new HgCommitCommand(myProject, hgRepo, "сообщение");
    commitCommand.executeInCurrentThread();
}
Also used : HgCommitCommand(org.zmlx.hg4idea.command.HgCommitCommand) HgRepository(org.zmlx.hg4idea.repo.HgRepository)

Example 4 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.

the class HgEncodingTest method testUtfMessageInHistoryWithSpecialCharacters.

//test SpecialCharacters in commit message for default EncodingProject settings
public void testUtfMessageInHistoryWithSpecialCharacters() throws HgCommandException, VcsException {
    cd(myRepository);
    String fileName = "file.txt";
    echo(fileName, "lalala");
    Charset charset = HgEncodingUtil.getDefaultCharset(myProject);
    String comment = "öäüß";
    HgRepository hgRepo = HgRepositoryImpl.getInstance(myRepository, myProject, myProject);
    HgCommitCommand commitCommand = new HgCommitCommand(myProject, hgRepo, comment);
    commitCommand.executeInCurrentThread();
    HgLogCommand logCommand = new HgLogCommand(myProject);
    myRepository.refresh(false, true);
    VirtualFile file = myRepository.findChild(fileName);
    assert file != null;
    List<HgFileRevision> revisions = logCommand.execute(new HgFile(myProject, file), 1, false);
    HgFileRevision rev = revisions.get(0);
    assertEquals(new String(comment.getBytes(charset)), rev.getCommitMessage());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgFile(org.zmlx.hg4idea.HgFile) HgCommitCommand(org.zmlx.hg4idea.command.HgCommitCommand) HgFileRevision(org.zmlx.hg4idea.HgFileRevision) Charset(java.nio.charset.Charset) HgRepository(org.zmlx.hg4idea.repo.HgRepository) HgLogCommand(org.zmlx.hg4idea.command.HgLogCommand)

Example 5 with HgRepository

use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.

the class HgPlatformTest method updateRepoConfig.

protected static void updateRepoConfig(@NotNull Project project, @Nullable VirtualFile repo) {
    HgRepository hgRepository = HgUtil.getRepositoryManager(project).getRepositoryForRoot(repo);
    assertNotNull(hgRepository);
    hgRepository.updateConfig();
}
Also used : HgRepository(org.zmlx.hg4idea.repo.HgRepository)

Aggregations

HgRepository (org.zmlx.hg4idea.repo.HgRepository)36 NotNull (org.jetbrains.annotations.NotNull)11 VirtualFile (com.intellij.openapi.vfs.VirtualFile)10 Project (com.intellij.openapi.project.Project)7 VcsException (com.intellij.openapi.vcs.VcsException)5 FilePath (com.intellij.openapi.vcs.FilePath)4 HgCommitCommand (org.zmlx.hg4idea.command.HgCommitCommand)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 File (java.io.File)3 HgFile (org.zmlx.hg4idea.HgFile)3 HgCommandException (org.zmlx.hg4idea.execution.HgCommandException)3 Task (com.intellij.openapi.progress.Task)2 AbstractVcsVirtualFile (com.intellij.openapi.vcs.vfs.AbstractVcsVirtualFile)2 VcsVirtualFile (com.intellij.openapi.vcs.vfs.VcsVirtualFile)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Nullable (org.jetbrains.annotations.Nullable)2 HgFileRevision (org.zmlx.hg4idea.HgFileRevision)2 HgNameWithHashInfo (org.zmlx.hg4idea.HgNameWithHashInfo)2 HgLogCommand (org.zmlx.hg4idea.command.HgLogCommand)2