List of usage examples for org.eclipse.jgit.lib RepositoryState REBASING_INTERACTIVE
RepositoryState REBASING_INTERACTIVE
To view the source code for org.eclipse.jgit.lib RepositoryState REBASING_INTERACTIVE.
Click Source Link
From source file:com.mangosolutions.rcloud.rawgist.repository.git.BareCommitCommand.java
private boolean isMergeDuringRebase(RepositoryState state) { if (state != RepositoryState.REBASING_INTERACTIVE && state != RepositoryState.REBASING_MERGE) { return false; }//from w w w .j a va 2 s. c om try { return repo.readMergeHeads() != null; } catch (IOException e) { throw new JGitInternalException(MessageFormat .format(JGitText.get().exceptionOccurredDuringReadingOfGIT_DIR, Constants.MERGE_HEAD, e), e); } }
From source file:org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.java
License:Open Source License
/** * @return true if repository state is//ww w .j av a 2 s . c om * {@link RepositoryState#REBASING_INTERACTIVE} */ public boolean isRebasingInteractive() { Repository repository = getRepository(); return repository != null && repository.getRepositoryState() == RepositoryState.REBASING_INTERACTIVE; }
From source file:org.eclipse.egit.core.internal.rebase.RebaseInteractivePlan.java
License:Open Source License
/** * Writes the plan to the FS./*w w w. j a va2s . c o m*/ * <p> * Only {@link PlanElement Elements} of {@link ElementType#TODO} are * persisted. * * @param repository * the plan belongs to * * @return true if the todo file has been written successfully, otherwise * false */ private boolean persist(Repository repository) { if (repository == null || repository.getRepositoryState() != RepositoryState.REBASING_INTERACTIVE) { return false; } List<RebaseTodoLine> todoLines = new LinkedList<RebaseTodoLine>(); for (PlanElement element : planList.getSecondList()) todoLines.add(element.getRebaseTodoLine()); try { repository.writeRebaseTodoFile(REBASE_TODO, todoLines, false); } catch (IOException e) { Activator.logError(CoreText.RebaseInteractivePlan_WriteRebaseTodoFailed, e); throw new RuntimeException(e); } return true; }
From source file:org.eclipse.egit.core.test.op.EditCommitOperationTest.java
License:Open Source License
@Test public void edit() throws Exception { EditCommitOperation op = new EditCommitOperation(testRepository.getRepository(), firstCommit); op.execute(new NullProgressMonitor()); assertEquals(RepositoryState.REBASING_INTERACTIVE, testRepository.getRepository().getRepositoryState()); List<RebaseTodoLine> todos = testRepository.getRepository().readRebaseTodo(GIT_REBASE_TODO, false); assertEquals(1, todos.size());//from www. j a va 2s . c o m assertEquals(RebaseTodoLine.Action.PICK, todos.get(0).getAction()); assertTrue(secondCommit.getId().startsWith(todos.get(0).getCommit())); ObjectId headId = testRepository.getRepository().resolve(Constants.HEAD); assertEquals(firstCommit.getId(), headId); }
From source file:org.eclipse.egit.ui.internal.merge.GitMergeEditorInput.java
License:Open Source License
@Override protected Object prepareInput(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { final Set<IFile> files = new HashSet<IFile>(); List<IContainer> folders = new ArrayList<IContainer>(); Set<IProject> projects = new HashSet<IProject>(); // collect all projects and sort the selected // resources into files and folders; skip // ignored resources for (IResource res : resources) { projects.add(res.getProject());//ww w. ja v a 2s . com if (Team.isIgnoredHint(res)) continue; if (res.getType() == IResource.FILE) files.add((IFile) res); else folders.add((IContainer) res); } if (monitor.isCanceled()) throw new InterruptedException(); // make sure all resources belong to the same repository Repository repo = null; for (IProject project : projects) { RepositoryMapping map = RepositoryMapping.getMapping(project); if (repo != null && repo != map.getRepository()) throw new InvocationTargetException( new IllegalStateException(UIText.AbstractHistoryCommanndHandler_NoUniqueRepository)); repo = map.getRepository(); } if (repo == null) throw new InvocationTargetException( new IllegalStateException(UIText.AbstractHistoryCommanndHandler_NoUniqueRepository)); if (monitor.isCanceled()) throw new InterruptedException(); // collect all file children of the selected folders IResourceVisitor fileCollector = new IResourceVisitor() { public boolean visit(IResource resource) throws CoreException { if (Team.isIgnoredHint(resource)) return false; if (resource.getType() == IResource.FILE) { files.add((IFile) resource); } return true; } }; for (IContainer cont : folders) { try { cont.accept(fileCollector); } catch (CoreException e) { // ignore here } } if (monitor.isCanceled()) throw new InterruptedException(); // our root node this.compareResult = new DiffNode(Differencer.CONFLICTING); final RevWalk rw = new RevWalk(repo); // get the "right" side (MERGE_HEAD for merge, ORIG_HEAD for rebase) final RevCommit rightCommit; try { String target; if (repo.getRepositoryState().equals(RepositoryState.MERGING)) target = Constants.MERGE_HEAD; else if (repo.getRepositoryState().equals(RepositoryState.REBASING_INTERACTIVE)) target = readFile(repo.getDirectory(), RebaseCommand.REBASE_MERGE + File.separatorChar + RebaseCommand.STOPPED_SHA); else target = Constants.ORIG_HEAD; ObjectId mergeHead = repo.resolve(target); if (mergeHead == null) throw new IOException(NLS.bind(UIText.ValidationUtils_CanNotResolveRefMessage, target)); rightCommit = rw.parseCommit(mergeHead); } catch (IOException e) { throw new InvocationTargetException(e); } // we need the HEAD, also to determine the common // ancestor final RevCommit headCommit; try { ObjectId head = repo.resolve(Constants.HEAD); if (head == null) throw new IOException(NLS.bind(UIText.ValidationUtils_CanNotResolveRefMessage, Constants.HEAD)); headCommit = rw.parseCommit(head); } catch (IOException e) { throw new InvocationTargetException(e); } final String fullBranch; try { fullBranch = repo.getFullBranch(); } catch (IOException e) { throw new InvocationTargetException(e); } // try to obtain the common ancestor List<RevCommit> startPoints = new ArrayList<RevCommit>(); rw.setRevFilter(RevFilter.MERGE_BASE); startPoints.add(rightCommit); startPoints.add(headCommit); RevCommit ancestorCommit; try { rw.markStart(startPoints); ancestorCommit = rw.next(); } catch (Exception e) { ancestorCommit = null; } if (monitor.isCanceled()) throw new InterruptedException(); // set the labels CompareConfiguration config = getCompareConfiguration(); config.setRightLabel(NLS.bind(LABELPATTERN, rightCommit.getShortMessage(), rightCommit.name())); if (!useWorkspace) config.setLeftLabel(NLS.bind(LABELPATTERN, headCommit.getShortMessage(), headCommit.name())); else config.setLeftLabel(UIText.GitMergeEditorInput_WorkspaceHeader); if (ancestorCommit != null) config.setAncestorLabel( NLS.bind(LABELPATTERN, ancestorCommit.getShortMessage(), ancestorCommit.name())); // set title and icon setTitle(NLS.bind(UIText.GitMergeEditorInput_MergeEditorTitle, new Object[] { Activator.getDefault().getRepositoryUtil().getRepositoryName(repo), rightCommit.getShortMessage(), fullBranch })); // now we calculate the nodes containing the compare information try { for (IFile file : files) { if (monitor.isCanceled()) throw new InterruptedException(); monitor.setTaskName(file.getFullPath().toString()); RepositoryMapping map = RepositoryMapping.getMapping(file); String gitPath = map.getRepoRelativePath(file); if (gitPath == null) continue; // ignore everything in .git if (gitPath.startsWith(Constants.DOT_GIT)) continue; fileToDiffNode(file, gitPath, map, this.compareResult, rightCommit, headCommit, ancestorCommit, rw, monitor); } } catch (IOException e) { throw new InvocationTargetException(e); } return compareResult; }
From source file:org.eclipse.emf.compare.egit.ui.internal.merge.ModelGitMergeEditorInput.java
License:Open Source License
private RevCommit getRightCommit(RevWalk revWalk, Repository repository) throws InvocationTargetException { try {/*from ww w . j a va 2s.c o m*/ String target; if (repository.getRepositoryState().equals(RepositoryState.MERGING)) { target = Constants.MERGE_HEAD; } else if (repository.getRepositoryState().equals(RepositoryState.CHERRY_PICKING)) { target = Constants.CHERRY_PICK_HEAD; } else if (repository.getRepositoryState().equals(RepositoryState.REBASING_INTERACTIVE)) { target = readFile(repository.getDirectory(), RebaseCommand.REBASE_MERGE + File.separatorChar + RebaseCommand.STOPPED_SHA); } else { target = Constants.ORIG_HEAD; } ObjectId mergeHead = repository.resolve(target); if (mergeHead == null) { throw new IOException(NLS.bind(UIText.ValidationUtils_CanNotResolveRefMessage, target)); } return revWalk.parseCommit(mergeHead); } catch (IOException e) { throw new InvocationTargetException(e); } }