Examples of BranchOperation


Examples of org.eclipse.egit.core.op.BranchOperation

  }

  @Test
  public void testCheckoutRemote() throws Exception {
    Repository repo = lookupRepository(clonedRepositoryFile);
    BranchOperation bop = new BranchOperation(repo, "refs/heads/master");
    bop.execute(null);

    assertEquals("master", repo.getBranch());
    SWTBotTree tree = getOrOpenView().bot().tree();

    SWTBotTreeItem item = myRepoViewUtil.getLocalBranchesItem(tree,
View Full Code Here

Examples of org.eclipse.egit.core.op.BranchOperation

   * @param refName
   *            full name of branch
   * @throws CoreException
   */
  public void checkoutBranch(String refName) throws CoreException {
    new BranchOperation(repository, refName).execute(null);
  }
View Full Code Here

Examples of org.eclipse.egit.core.op.BranchOperation

  public void testBranchOperation() throws Exception {
    // create first commit containing a dummy file
    testRepository.createInitialCommit("testBranchOperation\n\nfirst commit\n");
    // create branch test and switch to branch test
    testRepository.createBranch(MASTER, TEST);
    new BranchOperation(repository, TEST).execute(null);
    assertTrue(repository.getFullBranch().equals(TEST));
    // add .project to version control and commit
    String path = project.getProject().getLocation().append(".project").toOSString();
    File file = new File(path);
    testRepository.track(file);
    testRepository.commit("Add .project file");
    // switch back to master branch
    // .project must disappear, related Eclipse project must be deleted
    new BranchOperation(repository, MASTER).execute(null);
    assertFalse(file.exists());
    assertFalse(project.getProject().exists());
    // switch back to master test
    // .project must reappear
    new BranchOperation(repository, TEST).execute(null);
    assertTrue(file.exists());
  }
View Full Code Here

Examples of org.eclipse.egit.core.op.BranchOperation

    String jobname = NLS.bind(UIText.BranchAction_checkingOut, repoName,
        target);

    final boolean restore = Activator.getDefault().getPreferenceStore()
        .getBoolean(UIPreferences.CHECKOUT_PROJECT_RESTORE);
    final BranchOperation bop = new BranchOperation(repository, target,
        !restore);

    Job job = new WorkspaceJob(jobname) {

      @Override
      public IStatus runInWorkspace(IProgressMonitor monitor) {
        try {
          if (restore) {
            final BranchProjectTracker tracker = new BranchProjectTracker(
                repository);
            final AtomicReference<IMemento> memento = new AtomicReference<IMemento>();
            bop.addPreExecuteTask(new PreExecuteTask() {

              public void preExecute(Repository pRepo,
                  IProgressMonitor pMonitor)
                  throws CoreException {
                // Snapshot current projects before checkout
                // begins
                memento.set(tracker.snapshot());
              }
            });
            bop.addPostExecuteTask(new PostExecuteTask() {

              public void postExecute(Repository pRepo,
                  IProgressMonitor pMonitor)
                  throws CoreException {
                IMemento snapshot = memento.get();
                if (snapshot == null)
                  return;
                // Save previous branch's projects and restore
                // current branch's projects
                tracker.save(snapshot).restore(pMonitor);
              }
            });
          }

          bop.execute(monitor);
        } catch (CoreException e) {
          switch (bop.getResult().getStatus()) {
          case CONFLICTS:
          case NONDELETED:
            break;
          default:
            return Activator.createErrorStatus(
                UIText.BranchAction_branchFailed, e);
          }
        } finally {
          GitLightweightDecorator.refresh();
        }
        return Status.OK_STATUS;
      }

      @Override
      public boolean belongsTo(Object family) {
        if (JobFamilies.CHECKOUT.equals(family))
          return true;
        return super.belongsTo(family);
      }
    };
    job.setUser(true);
    // Set scheduling rule to workspace because we may have to re-create
    // projects using BranchProjectTracker.
    if (restore)
      job.setRule(ResourcesPlugin.getWorkspace().getRoot());
    job.addJobChangeListener(new JobChangeAdapter() {
      @Override
      public void done(IJobChangeEvent cevent) {
        show(bop.getResult());
      }
    });
    job.schedule();
  }
View Full Code Here

Examples of org.eclipse.egit.core.op.BranchOperation

    askForTargetIfNecessary();
    if (target == null)
      return;

    BranchOperation bop = new BranchOperation(repository, target);
    bop.execute(monitor);

    show(bop.getResult());
  }
View Full Code Here

Examples of org.eclipse.egit.core.op.BranchOperation

      throws Exception {
    CreateLocalBranchOperation createBranch = new CreateLocalBranchOperation(
        repository, branchName, repository.getRef("master"),
        UpstreamConfig.NONE);
    createBranch.execute(null);
    BranchOperation checkout = new BranchOperation(repository, branchName);
    checkout.execute(null);
  }
View Full Code Here

Examples of org.eclipse.egit.core.op.BranchOperation

    assertFalse(testFile.exists());
    testFile = new File(workdir, newFilePath);
    assertTrue(testFile.exists());

    // check out test and verify the file is there
    BranchOperation bop = new BranchOperation(repository2.getRepository(),
        "refs/heads/test");
    bop.execute(null);
    testFile = new File(workdir2, newFilePath);
    assertTrue(testFile.exists());
  }
View Full Code Here

Examples of org.eclipse.egit.core.op.BranchOperation

      throws Exception {
    CreateLocalBranchOperation createBranch = new CreateLocalBranchOperation(
        repository, branchName, repository.getRef("master"),
        UpstreamConfig.NONE);
    createBranch.execute(null);
    BranchOperation checkout = new BranchOperation(repository, branchName);
    checkout.execute(null);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.