Search in sources :

Example 1 with HgPushCommand

use of org.zmlx.hg4idea.command.HgPushCommand 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 HgPushCommand

use of org.zmlx.hg4idea.command.HgPushCommand in project intellij-community by JetBrains.

the class HgPushTest method testHgPushCommand.

/**
   * Testing HgPushCommand:
   * 1. Create a file, add to the VCS and commit via ChangeListManager.
   * 2. Push via HgPushCommand.
   * 3. Natively update parent repository.
   * 4. Verify that the changes appeared there.
   */
@Test
public void testHgPushCommand() throws Exception {
    final VirtualFile vf = createFileInCommand(AFILE, "initial content");
    myChangeListManager.addUnversionedFilesToVcs(vf);
    myChangeListManager.checkFilesAreInList(true, vf);
    myChangeListManager.commitFiles(vf);
    new HgPushCommand(myProject, myRepo.getDir(), myParentRepo.getDir().getUrl()).executeInCurrentThread();
    myParentRepo.update();
    assertNotNull(myParentRepo.getDir().findChild(AFILE));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgPushCommand(org.zmlx.hg4idea.command.HgPushCommand) Test(org.testng.annotations.Test)

Aggregations

HgPushCommand (org.zmlx.hg4idea.command.HgPushCommand)2 PushSpec (com.intellij.dvcs.push.PushSpec)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Map (java.util.Map)1 Test (org.testng.annotations.Test)1 HgRepository (org.zmlx.hg4idea.repo.HgRepository)1