Browse Source

Enable to prepare interactive rebase and then start it explicitly

Add Operation.PROCESS_STEPS to RebaseCommand to enable starting
interactive rebase explicitly after rebase steps have been configured.

Change-Id: I2d6f0de82010ea6523fbce6fb4501e847bdcdddc
Signed-off-by: Tobias Pfeifer <to.pfeifer@web.de>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
tags/v3.2.0.201311130903-m3
Tobias Pfeifer 11 years ago
parent
commit
da9db6b20c

+ 42
- 1
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseCommand.java View File

/** /**
* Aborts and resets the current rebase * Aborts and resets the current rebase
*/ */
ABORT;
ABORT,
/**
* Starts processing steps
*/
PROCESS_STEPS;
} }


private Operation operation = Operation.BEGIN; private Operation operation = Operation.BEGIN;


private InteractiveHandler interactiveHandler; private InteractiveHandler interactiveHandler;


private boolean stopAfterInitialization = false;

/** /**
* @param repo * @param repo
*/ */
} catch (IOException ioe) { } catch (IOException ioe) {
throw new JGitInternalException(ioe.getMessage(), ioe); throw new JGitInternalException(ioe.getMessage(), ioe);
} }
case PROCESS_STEPS:
// fall through
case SKIP: case SKIP:
// fall through // fall through
case CONTINUE: case CONTINUE:
break; break;
case BEGIN: case BEGIN:
RebaseResult res = initFilesAndRewind(); RebaseResult res = initFilesAndRewind();
if (stopAfterInitialization)
return RebaseResult.INTERACTIVE_PREPARED_RESULT;
if (res != null) if (res != null)
return res; return res;
} }
} }


private void checkParameters() throws WrongRepositoryStateException { private void checkParameters() throws WrongRepositoryStateException {
if (this.operation == Operation.PROCESS_STEPS) {
if (rebaseState.getFile(DONE).exists())
throw new WrongRepositoryStateException(MessageFormat.format(
JGitText.get().wrongRepositoryState, repo
.getRepositoryState().name()));
}
if (this.operation != Operation.BEGIN) { if (this.operation != Operation.BEGIN) {
// these operations are only possible while in a rebasing state // these operations are only possible while in a rebasing state
switch (repo.getRepositoryState()) { switch (repo.getRepositoryState()) {


/** /**
* Enables interactive rebase * Enables interactive rebase
* <p>
* Does not stop after initialization of interactive rebase. This is
* equivalent to
* {@link RebaseCommand#runInteractively(InteractiveHandler, boolean)
* runInteractively(handler, false)};
* </p>
* *
* @param handler * @param handler
* @return this * @return this
*/ */
public RebaseCommand runInteractively(InteractiveHandler handler) { public RebaseCommand runInteractively(InteractiveHandler handler) {
return runInteractively(handler, false);
}

/**
* Enables interactive rebase
* <p>
* If stopAfterRebaseInteractiveInitialization is {@code true} the rebase
* stops after initialization of interactive rebase returning
* {@link RebaseResult#INTERACTIVE_PREPARED_RESULT}
* </p>
*
* @param handler
* @param stopAfterRebaseInteractiveInitialization
* if {@code true} the rebase stops after initialization
* @return this instance
*/
public RebaseCommand runInteractively(InteractiveHandler handler,
final boolean stopAfterRebaseInteractiveInitialization) {
this.stopAfterInitialization = stopAfterRebaseInteractiveInitialization;
this.interactiveHandler = handler; this.interactiveHandler = handler;
return this; return this;
} }

+ 14
- 1
org.eclipse.jgit/src/org/eclipse/jgit/api/RebaseResult.java View File

/* /*
* Copyright (C) 2010, Mathias Kinzler <mathias.kinzler@sap.com>
* Copyright (C) 2010, 2013, Mathias Kinzler <mathias.kinzler@sap.com>
* and other copyright owners as documented in the project's IP log. * and other copyright owners as documented in the project's IP log.
* *
* This program and the accompanying materials are made available * This program and the accompanying materials are made available
public boolean isSuccessful() { public boolean isSuccessful() {
return false; return false;
} }
},

/**
* Interactive rebase has been prepared
*/
INTERACTIVE_PREPARED {
@Override
public boolean isSuccessful() {
return false;
}
}; };


/** /**
static final RebaseResult NOTHING_TO_COMMIT_RESULT = new RebaseResult( static final RebaseResult NOTHING_TO_COMMIT_RESULT = new RebaseResult(
Status.NOTHING_TO_COMMIT); Status.NOTHING_TO_COMMIT);


static final RebaseResult INTERACTIVE_PREPARED_RESULT = new RebaseResult(
Status.INTERACTIVE_PREPARED);

private final Status status; private final Status status;


private final RevCommit currentCommit; private final RevCommit currentCommit;

Loading…
Cancel
Save