Search in sources :

Example 1 with PushSpec

use of com.intellij.dvcs.push.PushSpec 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 PushSpec

use of com.intellij.dvcs.push.PushSpec in project intellij-community by JetBrains.

the class GitPusher method rememberTargets.

private void rememberTargets(@NotNull Map<GitRepository, PushSpec<GitPushSource, GitPushTarget>> pushSpecs) {
    for (Map.Entry<GitRepository, PushSpec<GitPushSource, GitPushTarget>> entry : pushSpecs.entrySet()) {
        GitRepository repository = entry.getKey();
        GitPushSource source = entry.getValue().getSource();
        GitPushTarget target = entry.getValue().getTarget();
        GitPushTarget defaultTarget = myPushSupport.getDefaultTarget(repository);
        if (defaultTarget == null || !target.getBranch().equals(defaultTarget.getBranch())) {
            mySettings.setPushTarget(repository, source.getBranch().getName(), target.getBranch().getRemote().getName(), target.getBranch().getNameForRemoteOperations());
        }
    }
}
Also used : PushSpec(com.intellij.dvcs.push.PushSpec) GitRepository(git4idea.repo.GitRepository) Map(java.util.Map)

Aggregations

PushSpec (com.intellij.dvcs.push.PushSpec)2 Map (java.util.Map)2 Project (com.intellij.openapi.project.Project)1 GitRepository (git4idea.repo.GitRepository)1 HgPushCommand (org.zmlx.hg4idea.command.HgPushCommand)1 HgRepository (org.zmlx.hg4idea.repo.HgRepository)1