[git] Branch API, step 4: move repositories to methods signature instead of the constructor.

This will be more suitable for the API.
This commit is contained in:
Kirill Likhodedov
2012-10-04 13:26:30 +04:00
parent 6b2f9cc7c4
commit ea2f59d4f9
7 changed files with 117 additions and 95 deletions
@@ -19,6 +19,8 @@ import git4idea.repo.GitRepository;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* <p>Executes various operations on Git branches: checkout, create new branch, merge, delete, compare.</p>
* <p>All operations can be called from the EDT: the GitBrancher will take care of starting a background task.</p>
@@ -36,19 +38,22 @@ public interface GitBrancher {
* do this before calling this method, otherwise a standard error dialog will be shown.</p>
* <p>Equivalent to {@code git checkout <name>}</p>
*
* @param name Name of the new branch to check out.
* @param name name of the new branch to check out.
* @param repositories repositories to operate on.
*/
void checkoutNewBranch(@NotNull String name);
void checkoutNewBranch(@NotNull String name, @NotNull List<GitRepository> repositories);
/**
* <p>Creates new tag on the selected reference.</p>
*
* @param name the name of new tag.
* @param reference the reference which tag will point to.
* @param repositories repositories to operate on.
* @param callInAwtLater the Runnable that should be called after execution of the method (both successful and unsuccessful).
* If given, it will be called in the EDT {@link javax.swing.SwingUtilities#invokeLater(Runnable) later}.
*/
void createNewTag(@NotNull String name, @NotNull String reference, @Nullable Runnable callInAwtLater);
void createNewTag(@NotNull String name, @NotNull String reference, @NotNull List<GitRepository> repositories,
@Nullable Runnable callInAwtLater);
/**
* <p>Checks out the given reference (a branch, or a reference name, or a commit hash).
@@ -56,23 +61,26 @@ public interface GitBrancher {
* stash-checkout-unstash.</p>
* <p>Doesn't check the reference for validity.</p>
*
* @param reference reference to be checked out.
* @param reference reference to be checked out.
* @param repositories repositories to operate on.
* @param callInAwtLater the Runnable that should be called after execution of the method (both successful and unsuccessful).
* If given, it will be called in the EDT {@link javax.swing.SwingUtilities#invokeLater(Runnable) later}.
*/
void checkout(@NotNull String reference, @Nullable Runnable callInAwtLater);
void checkout(@NotNull String reference, @NotNull List<GitRepository> repositories, @Nullable Runnable callInAwtLater);
/**
* Creates and checks out a new local branch starting from the given reference:
* {@code git checkout -b <branchname> <start-point>}. <br/>
* Provides the "smart checkout" procedure the same as in {@link #checkout(String, Runnable)}.
*
* @param newBranchName the name of the new local branch.
* @param startPoint the reference to checkout.
* @param newBranchName the name of the new local branch.
* @param startPoint the reference to checkout.
* @param repositories repositories to operate on.
* @param callInAwtLater the Runnable that should be called after execution of the method (both successful and unsuccessful).
* If given, it will be called in the EDT {@link javax.swing.SwingUtilities#invokeLater(Runnable) later}.
*/
void checkoutNewBranchStartingFrom(@NotNull String newBranchName, @NotNull String startPoint, @Nullable Runnable callInAwtLater);
void checkoutNewBranchStartingFrom(@NotNull String newBranchName, @NotNull String startPoint, @NotNull List<GitRepository> repositories,
@Nullable Runnable callInAwtLater);
/**
* <p>Deletes the branch with the specified name.</p>
@@ -81,26 +89,30 @@ public interface GitBrancher {
* displays a dialog showing commits that are not merged and proposing to execute force deletion:</p>
* <p>{@code git branch -D <name>}</p>
*
* @param branchName the name of the branch to be deleted.
* @param branchName the name of the branch to be deleted.
* @param repositories repositories to operate on.
*/
void deleteBranch(String branchName);
void deleteBranch(@NotNull String branchName, @NotNull List<GitRepository> repositories);
/**
* <p>Deletes the remote branch:</p>
* <p>{@code git push <remote> :<name>}</p>
* @param branchName name of the remote branch to delete.
*
* @param branchName name of the remote branch to delete.
* @param repositories Repositories to operate on.
*/
void deleteRemoteBranch(@NotNull String branchName);
void deleteRemoteBranch(@NotNull String branchName, @NotNull List<GitRepository> repositories);
/**
* Compares the HEAD with the specified branch - shows a dialog with the differences.
*
* @param branchName name of the branch to compare with.
* @param repositories repositories to operate on.
* @param selectedRepository current or selected repository.
* The list of commits is displayed for the repository selected from the combobox.
* This parameter tells which repository should be pre-selected in the combobox.
*/
void compare(@NotNull String branchName, @NotNull GitRepository selectedRepository);
void compare(@NotNull String branchName, @NotNull List<GitRepository> repositories, @NotNull GitRepository selectedRepository);
/**
* <p>Merges the given branch to the HEAD.</p>
@@ -108,11 +120,12 @@ public interface GitBrancher {
* <p>If local changes prevent merging, proposes the "Smart merge" procedure (stash-merge-unstash).</p>
* <p>If untracked files prevent merging, shows them in an error dialog.</p>
*
* @param branchName the branch to be merged into HEAD.
* @param localBranch true indicates that the merged branch is a local branch, false - that it is a remote branch.
* After a local branch is merged, the IDE proposes to delete it at once (common feature branches workflow),
* but it is not done for remote branches and for master.
* @param branchName the branch to be merged into HEAD.
* @param localBranch true indicates that the merged branch is a local branch, false - that it is a remote branch.
* After a local branch is merged, the IDE proposes to delete it at once (common feature branches workflow),
* but it is not done for remote branches and for master.
* @param repositories repositories to operate on.
*/
void merge(@NotNull String branchName, boolean localBranch);
void merge(@NotNull String branchName, boolean localBranch, @NotNull List<GitRepository> repositories);
}
@@ -59,116 +59,117 @@ public final class GitBrancherImpl implements GitBrancher {
private static final Logger LOG = Logger.getInstance(GitBrancherImpl.class);
private final Project myProject;
private final List<GitRepository> myRepositories;
private final Git myGit;
@NotNull private final Project myProject;
@NotNull private final Git myGit;
public GitBrancherImpl(@NotNull GitRepository repository) {
this(repository.getProject(), Collections.singletonList(repository));
}
public GitBrancherImpl(@NotNull Project project, @NotNull List<GitRepository> repositories) {
public GitBrancherImpl(@NotNull Project project) {
myProject = project;
myRepositories = repositories;
myGit = ServiceManager.getService(Git.class);
}
@NotNull
private String getCurrentBranchOrRev() {
if (myRepositories.size() > 1) {
GitMultiRootBranchConfig multiRootBranchConfig = new GitMultiRootBranchConfig(myRepositories);
private static String getCurrentBranchOrRev(@NotNull List<GitRepository> repositories) {
if (repositories.size() > 1) {
GitMultiRootBranchConfig multiRootBranchConfig = new GitMultiRootBranchConfig(repositories);
String currentBranch = multiRootBranchConfig.getCurrentBranch();
LOG.assertTrue(currentBranch != null, "Repositories have unexpectedly diverged. " + multiRootBranchConfig);
return currentBranch;
}
else {
assert !myRepositories.isEmpty() : "No repositories passed to GitBranchOperationsProcessor.";
GitRepository repository = myRepositories.iterator().next();
assert !repositories.isEmpty() : "No repositories passed to GitBranchOperationsProcessor.";
GitRepository repository = repositories.iterator().next();
return GitBranchUiUtil.getBranchNameOrRev(repository);
}
}
@Override
public void checkoutNewBranch(@NotNull final String name) {
public void checkoutNewBranch(@NotNull final String name, @NotNull final List<GitRepository> repositories) {
new CommonBackgroundTask(myProject, "Checking out new branch " + name, null) {
@Override public void execute(@NotNull ProgressIndicator indicator) {
doCheckoutNewBranch(name, indicator);
doCheckoutNewBranch(name, repositories, indicator);
}
}.runInBackground();
}
@Override
public void createNewTag(@NotNull final String name, @NotNull final String reference, @Nullable Runnable callInAwtLater) {
public void createNewTag(@NotNull final String name, @NotNull final String reference, @NotNull final List<GitRepository> repositories,
@Nullable Runnable callInAwtLater) {
new CommonBackgroundTask(myProject, "Checking out new branch " + name, callInAwtLater) {
@Override public void execute(@NotNull ProgressIndicator indicator) {
for (GitRepository repository : myRepositories) {
for (GitRepository repository : repositories) {
myGit.createNewTag(repository, name, null, reference);
}
}
}.runInBackground();
}
private void doCheckoutNewBranch(@NotNull final String name, @NotNull ProgressIndicator indicator) {
new GitCheckoutNewBranchOperation(myProject, myGit, myRepositories, name, getCurrentBranchOrRev(), indicator).execute();
private void doCheckoutNewBranch(@NotNull final String name, @NotNull List<GitRepository> repositories,
@NotNull ProgressIndicator indicator) {
new GitCheckoutNewBranchOperation(myProject, myGit, repositories, name, getCurrentBranchOrRev(repositories), indicator).execute();
}
@Override
public void checkoutNewBranchStartingFrom(@NotNull String newBranchName, @NotNull String startPoint, @Nullable Runnable callInAwtLater) {
commonCheckout(startPoint, newBranchName, callInAwtLater);
public void checkoutNewBranchStartingFrom(@NotNull String newBranchName, @NotNull String startPoint,
@NotNull List<GitRepository> repositories, @Nullable Runnable callInAwtLater) {
commonCheckout(startPoint, newBranchName, repositories, callInAwtLater);
}
@Override
public void checkout(@NotNull final String reference, @Nullable Runnable callInAwtLater) {
commonCheckout(reference, null, callInAwtLater);
public void checkout(@NotNull final String reference, @NotNull List<GitRepository> repositories, @Nullable Runnable callInAwtLater) {
commonCheckout(reference, null, repositories, callInAwtLater);
}
private void commonCheckout(@NotNull final String reference, @Nullable final String newBranch, @Nullable Runnable callInAwtLater) {
private void commonCheckout(@NotNull final String reference, @Nullable final String newBranch, @NotNull final List<GitRepository> repositories,
@Nullable Runnable callInAwtLater) {
new CommonBackgroundTask(myProject, "Checking out " + reference, callInAwtLater) {
@Override public void execute(@NotNull ProgressIndicator indicator) {
doCheckout(indicator, reference, newBranch);
doCheckout(indicator, reference, repositories, newBranch);
}
}.runInBackground();
}
private void doCheckout(@NotNull ProgressIndicator indicator, @NotNull String reference, @Nullable String newBranch) {
new GitCheckoutOperation(myProject, myGit, myRepositories, reference, newBranch, getCurrentBranchOrRev(), indicator).execute();
private void doCheckout(@NotNull ProgressIndicator indicator, @NotNull String reference, @NotNull List<GitRepository> repositories,
@Nullable String newBranch) {
new GitCheckoutOperation(myProject, myGit, repositories, reference, newBranch, getCurrentBranchOrRev(repositories), indicator)
.execute();
}
@Override
public void deleteBranch(final String branchName) {
public void deleteBranch(@NotNull final String branchName, @NotNull final List<GitRepository> repositories) {
new CommonBackgroundTask(myProject, "Deleting " + branchName, null) {
@Override public void execute(@NotNull ProgressIndicator indicator) {
doDelete(branchName, indicator);
doDelete(branchName, repositories, indicator);
}
}.runInBackground();
}
private void doDelete(@NotNull String branchName, @NotNull ProgressIndicator indicator) {
new GitDeleteBranchOperation(myProject, myGit, myRepositories, branchName, getCurrentBranchOrRev(), indicator).execute();
private void doDelete(@NotNull String branchName, @NotNull List<GitRepository> repositories, @NotNull ProgressIndicator indicator) {
new GitDeleteBranchOperation(myProject, myGit, repositories, branchName, getCurrentBranchOrRev(repositories), indicator).execute();
}
@Override
public void deleteRemoteBranch(@NotNull final String branchName) {
final Collection<String> trackingBranches = findTrackingBranches(branchName);
String currentBranch = getCurrentBranchOrRev();
public void deleteRemoteBranch(@NotNull final String branchName, @NotNull final List<GitRepository> repositories) {
final Collection<String> trackingBranches = findTrackingBranches(branchName, repositories);
String currentBranch = getCurrentBranchOrRev(repositories);
boolean currentBranchTracksBranchToDelete = false;
if (trackingBranches.contains(currentBranch)) {
currentBranchTracksBranchToDelete = true;
trackingBranches.remove(currentBranch);
}
final DeleteRemoteBranchDecision decision = confirmBranchDeletion(branchName, trackingBranches, currentBranchTracksBranchToDelete);
final DeleteRemoteBranchDecision decision = confirmBranchDeletion(branchName, trackingBranches, currentBranchTracksBranchToDelete,
repositories);
if (decision.delete()) {
new CommonBackgroundTask(myProject, "Deleting " + branchName, null) {
@Override public void execute(@NotNull ProgressIndicator indicator) {
boolean deletedSuccessfully = doDeleteRemote(branchName);
boolean deletedSuccessfully = doDeleteRemote(branchName, repositories);
if (deletedSuccessfully) {
final Collection<String> successfullyDeletedLocalBranches = new ArrayList<String>(1);
if (decision.deleteTracking()) {
for (final String branch : trackingBranches) {
indicator.setText("Deleting " + branch);
new GitDeleteBranchOperation(myProject, myGit, myRepositories, branch, getCurrentBranchOrRev(), indicator) {
new GitDeleteBranchOperation(myProject, myGit, repositories, branch, getCurrentBranchOrRev(repositories), indicator) {
@Override
protected void notifySuccess(@NotNull String message) {
// do nothing - will display a combo notification for all deleted branches below
@@ -185,13 +186,13 @@ public final class GitBrancherImpl implements GitBrancher {
}
@NotNull
private Collection<String> findTrackingBranches(@NotNull String remoteBranch) {
return new GitMultiRootBranchConfig(myRepositories).getTrackingBranches(remoteBranch);
private static Collection<String> findTrackingBranches(@NotNull String remoteBranch, @NotNull List<GitRepository> repositories) {
return new GitMultiRootBranchConfig(repositories).getTrackingBranches(remoteBranch);
}
private boolean doDeleteRemote(String branchName) {
private boolean doDeleteRemote(@NotNull String branchName, @NotNull List<GitRepository> repositories) {
GitCompoundResult result = new GitCompoundResult(myProject);
for (GitRepository repository : myRepositories) {
for (GitRepository repository : repositories) {
Pair<String, String> pair = GitBranch.splitNameOfRemoteBranch(branchName);
String remote = pair.getFirst();
String branch = pair.getSecond();
@@ -207,7 +208,7 @@ public final class GitBrancherImpl implements GitBrancher {
}
@NotNull
private GitCommandResult pushDeletion(GitRepository repository, String remoteName, String branchName) {
private GitCommandResult pushDeletion(@NotNull GitRepository repository, @NotNull String remoteName, @NotNull String branchName) {
GitRemote remote = getRemoteByName(repository, remoteName);
if (remote == null) {
return pushDeletionNatively(repository, remoteName, branchName);
@@ -225,12 +226,13 @@ public final class GitBrancherImpl implements GitBrancher {
}
}
private GitCommandResult pushDeletionNatively(GitRepository repository, String remoteName, String branchName) {
@NotNull
private GitCommandResult pushDeletionNatively(@NotNull GitRepository repository, @NotNull String remoteName, @NotNull String branchName) {
return myGit.push(repository, remoteName, ":" + branchName);
}
@NotNull
private static GitCommandResult convertSimplePushResultToCommandResult(GitSimplePushResult result) {
private static GitCommandResult convertSimplePushResultToCommandResult(@NotNull GitSimplePushResult result) {
boolean success = result.getType() == GitSimplePushResult.Type.SUCCESS;
return new GitCommandResult(success, -1, success ? Collections.<String>emptyList() : Collections.singletonList(result.getOutput()),
success ? Collections.singletonList(result.getOutput()) : Collections.<String>emptyList());
@@ -256,7 +258,8 @@ public final class GitBrancherImpl implements GitBrancher {
}
private DeleteRemoteBranchDecision confirmBranchDeletion(@NotNull String branchName, @NotNull Collection<String> trackingBranches,
boolean currentBranchTracksBranchToDelete) {
boolean currentBranchTracksBranchToDelete,
@NotNull List<GitRepository> repositories) {
String title = "Delete Remote Branch";
String message = "Delete remote branch " + branchName;
@@ -268,7 +271,7 @@ public final class GitBrancherImpl implements GitBrancher {
}
else {
if (currentBranchTracksBranchToDelete) {
message += "\n\nCurrent branch " + getCurrentBranchOrRev() + " tracks " + branchName + " but won't be deleted.";
message += "\n\nCurrent branch " + getCurrentBranchOrRev(repositories) + " tracks " + branchName + " but won't be deleted.";
}
final String checkboxMessage;
if (trackingBranches.size() == 1) {
@@ -329,23 +332,24 @@ public final class GitBrancherImpl implements GitBrancher {
}
@Override
public void compare(@NotNull final String branchName, @NotNull final GitRepository selectedRepository) {
public void compare(@NotNull final String branchName, @NotNull final List<GitRepository> repositories,
@NotNull final GitRepository selectedRepository) {
new CommonBackgroundTask(myProject, "Comparing with " + branchName, null) {
private GitCommitCompareInfo myCompareInfo;
@Override
public void execute(@NotNull ProgressIndicator indicator) {
myCompareInfo = loadCommitsToCompare(myRepositories, branchName);
myCompareInfo = loadCommitsToCompare(repositories, branchName);
}
@Override
public void onSuccess() {
if (myCompareInfo == null) {
LOG.error("The task to get compare info didn't finish. Repositories: \n" + myRepositories + "\nbranch name: " + branchName);
LOG.error("The task to get compare info didn't finish. Repositories: \n" + repositories + "\nbranch name: " + branchName);
return;
}
displayCompareDialog(branchName, getCurrentBranchOrRev(), myCompareInfo, selectedRepository);
displayCompareDialog(branchName, getCurrentBranchOrRev(repositories), myCompareInfo, selectedRepository);
}
}.runInBackground();
}
@@ -397,20 +401,21 @@ public final class GitBrancherImpl implements GitBrancher {
}
@Override
public void merge(@NotNull final String branchName, final boolean localBranch) {
public void merge(@NotNull final String branchName, final boolean localBranch, @NotNull final List<GitRepository> repositories) {
new CommonBackgroundTask(myProject, "Merging " + branchName, null) {
@Override public void execute(@NotNull ProgressIndicator indicator) {
doMerge(branchName, localBranch, indicator);
doMerge(branchName, localBranch, repositories, indicator);
}
}.runInBackground();
}
private void doMerge(@NotNull String branchName, boolean localBranch, @NotNull ProgressIndicator indicator) {
private void doMerge(@NotNull String branchName, boolean localBranch, @NotNull List<GitRepository> repositories,
@NotNull ProgressIndicator indicator) {
Map<GitRepository, String> revisions = new HashMap<GitRepository, String>();
for (GitRepository repository : myRepositories) {
for (GitRepository repository : repositories) {
revisions.put(repository, repository.getCurrentRevision());
}
new GitMergeOperation(myProject, myGit, myRepositories, branchName, localBranch, getCurrentBranchOrRev(),
new GitMergeOperation(myProject, myGit, repositories, branchName, localBranch, getCurrentBranchOrRev(repositories),
revisions, indicator).execute();
}
@@ -378,7 +378,7 @@ class GitMergeOperation extends GitBranchOperation {
public void hyperlinkUpdate(@NotNull Notification notification,
@NotNull HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED && event.getDescription().equalsIgnoreCase("delete")) {
new GitBrancherImpl(myProject, new ArrayList<GitRepository>(getRepositories())).deleteBranch(myBranchToMerge);
new GitBrancherImpl(myProject).deleteBranch(myBranchToMerge, new ArrayList<GitRepository>(getRepositories()));
}
}
}
@@ -22,6 +22,8 @@ import com.intellij.openapi.util.text.StringUtil;
import git4idea.branch.GitBrancherImpl;
import git4idea.repo.GitRepository;
import java.util.Collections;
/**
* Created by IntelliJ IDEA.
* User: Irina.Chernushina
@@ -55,7 +57,7 @@ public class GitCreateNewTag {
}
});
if (name != null) {
new GitBrancherImpl(myRepository).createNewTag(name, myReference, myCallInAwtAfterExecution);
new GitBrancherImpl(myProject).createNewTag(name, myReference, Collections.singletonList(myRepository), myCallInAwtAfterExecution);
}
}
}
@@ -2439,7 +2439,8 @@ public class GitLogUI implements Disposable {
final GitRepository repository =
GitUtil.getRepositoryManager(myProject).getRepositoryForRoot(commitAt.selectRepository(myRootsUnderVcs));
if (repository == null) return;
new GitBrancherImpl(repository).checkout(commitAt.getHash().getString(), myRefresh);
new GitBrancherImpl(repository.getProject()).checkout(commitAt.getHash().getString(),
Collections.singletonList(repository), myRefresh);
}
@Override
@@ -2467,7 +2468,8 @@ public class GitLogUI implements Disposable {
String reference = commitAt.getHash().getString();
final String name = GitBranchUiUtil.getNewBranchNameFromUser(myProject, Collections.singleton(repository), "Checkout New Branch From " + reference);
if (name != null) {
new GitBrancherImpl(repository).checkoutNewBranchStartingFrom(name, reference, myRefresh);
new GitBrancherImpl(repository.getProject()).checkoutNewBranchStartingFrom(name, reference,
Collections.singletonList(repository), myRefresh);
}
}
@@ -93,7 +93,7 @@ class GitBranchPopupActions {
public void actionPerformed(AnActionEvent e) {
final String name = GitBranchUiUtil.getNewBranchNameFromUser(myProject, myRepositories, "Create New Branch");
if (name != null) {
new GitBrancherImpl(myProject, myRepositories).checkoutNewBranch(name);
new GitBrancherImpl(myProject).checkoutNewBranch(name, myRepositories);
}
}
@@ -134,7 +134,7 @@ class GitBranchPopupActions {
String reference = Messages
.showInputDialog(myProject, "Enter reference (branch, tag) name or commit hash", "Checkout", Messages.getQuestionIcon());
if (reference != null) {
new GitBrancherImpl(myRepository).checkout(reference, null);
new GitBrancherImpl(myProject).checkout(reference, Collections.singletonList(myRepository), null);
}
}
@@ -214,7 +214,7 @@ class GitBranchPopupActions {
@Override
public void actionPerformed(AnActionEvent e) {
new GitBrancherImpl(myProject, myRepositories).checkout(myBranchName, null);
new GitBrancherImpl(myProject).checkout(myBranchName, myRepositories, null);
}
}
@@ -237,7 +237,7 @@ class GitBranchPopupActions {
.showInputDialog(myProject, "Enter name of new branch", "Checkout New Branch From " + myBranchName,
Messages.getQuestionIcon(), "", GitNewBranchNameValidator.newInstance(myRepositories));
if (name != null) {
new GitBrancherImpl(myProject, myRepositories).checkoutNewBranchStartingFrom(name, myBranchName, null);
new GitBrancherImpl(myProject).checkoutNewBranchStartingFrom(name, myBranchName, myRepositories, null);
}
}
@@ -257,7 +257,7 @@ class GitBranchPopupActions {
@Override
public void actionPerformed(AnActionEvent e) {
new GitBrancherImpl(myProject, myRepositories).deleteBranch(myBranchName);
new GitBrancherImpl(myProject).deleteBranch(myBranchName, myRepositories);
}
}
}
@@ -311,7 +311,7 @@ class GitBranchPopupActions {
final String name = Messages.showInputDialog(myProject, "Enter name of new branch", "Checkout Remote Branch", Messages.getQuestionIcon(),
guessBranchName(), GitNewBranchNameValidator.newInstance(myRepositories));
if (name != null) {
new GitBrancherImpl(myProject, myRepositories).checkoutNewBranchStartingFrom(name, myRemoteBranchName, null);
new GitBrancherImpl(myProject).checkoutNewBranchStartingFrom(name, myRemoteBranchName, myRepositories, null);
}
}
@@ -337,7 +337,7 @@ class GitBranchPopupActions {
@Override
public void actionPerformed(AnActionEvent e) {
new GitBrancherImpl(myProject, myRepositories).deleteRemoteBranch(myBranchName);
new GitBrancherImpl(myProject).deleteRemoteBranch(myBranchName, myRepositories);
}
}
@@ -361,7 +361,7 @@ class GitBranchPopupActions {
@Override
public void actionPerformed(AnActionEvent e) {
new GitBrancherImpl(myProject, myRepositories).compare(myBranchName, mySelectedRepository);
new GitBrancherImpl(myProject).compare(myBranchName, myRepositories, mySelectedRepository);
}
}
@@ -384,7 +384,7 @@ class GitBranchPopupActions {
@Override
public void actionPerformed(AnActionEvent e) {
new GitBrancherImpl(myProject, myRepositories).merge(myBranchName, myLocalBranch);
new GitBrancherImpl(myProject).merge(myBranchName, myLocalBranch, myRepositories);
}
}
@@ -461,10 +461,10 @@ public class GitBranchOperationsTest extends AbstractVcsTestCase {
return DialogWrapper.CANCEL_EXIT_CODE;
}
});
GitBrancher processor = new GitBrancherImpl(myProject, singletonList(myCommunity));
GitBrancher processor = new GitBrancherImpl(myProject);
Method method = GitBrancherImpl.class.getDeclaredMethod("doDelete", String.class, ProgressIndicator.class);
method.setAccessible(true);
method.invoke(processor, "feature", new EmptyProgressIndicator());
method.invoke(processor, "feature", singletonList(myCommunity), new EmptyProgressIndicator());
assertTrue(dialogShown.get());
}
@@ -670,10 +670,10 @@ public class GitBranchOperationsTest extends AbstractVcsTestCase {
}
private void doMerge(String branch) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
GitBrancher processor = new GitBrancherImpl(myProject, myRepositories);
GitBrancher processor = new GitBrancherImpl(myProject);
Method method = GitBrancherImpl.class.getDeclaredMethod("doMerge", String.class, Boolean.TYPE, ProgressIndicator.class);
method.setAccessible(true);
method.invoke(processor, branch, true, new EmptyProgressIndicator());
method.invoke(processor, branch, true, myRepositories, new EmptyProgressIndicator());
// sync refresh is needed, because the refresh inside GitMergeOperation is asynchronous.
for (GitRepository repository : myRepositories) {
@@ -707,10 +707,10 @@ public class GitBranchOperationsTest extends AbstractVcsTestCase {
private void callPrivateBranchOperationsProcessorMethod(String methodName, String branchName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
// call private doCheckoutNewBranch instead of public checkoutNewBranch to avoid dealing with background process creation
// same for other branch operations
GitBrancher processor = new GitBrancherImpl(myProject, myRepositories);
GitBrancher processor = new GitBrancherImpl(myProject);
Method method = GitBrancherImpl.class.getDeclaredMethod(methodName, String.class, ProgressIndicator.class);
method.setAccessible(true);
method.invoke(processor, branchName, new EmptyProgressIndicator());
method.invoke(processor, branchName, myRepositories, new EmptyProgressIndicator());
}
private void doDeleteBranch(@NotNull String branchName) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
@@ -718,10 +718,10 @@ public class GitBranchOperationsTest extends AbstractVcsTestCase {
}
private void doCheckout(@NotNull String branchName, @Nullable String newBranch) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
GitBrancher processor = new GitBrancherImpl(myProject, myRepositories);
GitBrancher processor = new GitBrancherImpl(myProject);
Method doCheckout = GitBrancherImpl.class.getDeclaredMethod("doCheckout", ProgressIndicator.class, String.class, String.class);
doCheckout.setAccessible(true);
doCheckout.invoke(processor, new EmptyProgressIndicator(), branchName, newBranch);
doCheckout.invoke(processor, new EmptyProgressIndicator(), branchName, newBranch, myRepositories);
}
private void assertBranch(String branch) throws IOException {