예제 #1
0
  /**
   * @param newRefName
   * @param checkoutNewBranch
   * @param monitor
   * @throws CoreException
   * @throws IOException
   */
  public void createBranch(String newRefName, boolean checkoutNewBranch, IProgressMonitor monitor)
      throws CoreException, IOException {
    monitor.beginTask(UIText.CreateBranchPage_CreatingBranchMessage, IProgressMonitor.UNKNOWN);

    final CreateLocalBranchOperation cbop;

    if (myBaseCommit != null && this.sourceRefName.equals(myBaseCommit.name()))
      cbop = new CreateLocalBranchOperation(myRepository, newRefName, myBaseCommit);
    else
      cbop =
          new CreateLocalBranchOperation(
              myRepository, newRefName, myRepository.getRef(this.sourceRefName), upstreamConfig);

    cbop.execute(monitor);

    if (checkoutNewBranch) {
      if (monitor.isCanceled()) return;
      monitor.beginTask(UIText.CreateBranchPage_CheckingOutMessage, IProgressMonitor.UNKNOWN);
      BranchOperationUI.checkout(myRepository, Constants.R_HEADS + newRefName).run(monitor);
    }
  }
예제 #2
0
  private void checkout(RevCommit commit, IProgressMonitor monitor) throws CoreException {
    monitor.setTaskName(UIText.FetchGerritChangePage_CheckingOutTaskName);
    BranchOperationUI.checkout(repository, commit.name()).run(monitor);

    monitor.worked(1);
  }