import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import git4idea.commands.StringScanner;
import git4idea.config.GitConfigUtil;
*/
@Nullable
public static GitBranch current(Project project, VirtualFile root) throws VcsException {
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.BRANCH);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.BRANCH);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--no-color");
// no need to run handler
return;
}
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.BRANCH);
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.BRANCH);
handler.setNoSSH(true);
handler.setSilent(true);
handler.addParameters("--no-color");
@Nullable
public GitRevisionNumber getMergeBase(@NotNull Project project, @NotNull VirtualFile root, @NotNull GitBranch branch)
throws VcsException {
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.MERGE_BASE);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.MERGE_BASE);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters(this.getFullName(), branch.getFullName());
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.vcsUtil.VcsUtil;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
return null;
}
VirtualFile root = GitUtil.getGitRoot(myFile);
- GitSimpleHandler h = new GitSimpleHandler(myProject, root, GitHandler.SHOW);
+ GitSimpleHandler h = new GitSimpleHandler(myProject, root, GitCommand.SHOW);
h.setCharset(myCharset);
h.setNoSSH(true);
h.setSilent(true);
}
}
- public static ContentRevision createRevision(final VirtualFile file, final VcsRevisionNumber revisionNumber, final Project project) throws VcsException {
+ public static ContentRevision createRevision(final VirtualFile file, final VcsRevisionNumber revisionNumber, final Project project)
+ throws VcsException {
final FilePathImpl filePath = new FilePathImpl(file);
if (revisionNumber != null) {
return new GitContentRevision(filePath, (GitRevisionNumber)revisionNumber, project);
import com.intellij.openapi.vcs.history.VcsFileRevision;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vfs.VirtualFile;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public synchronized void loadContent() throws VcsException {
final VirtualFile root = GitUtil.getGitRoot(path);
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.SHOW);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.SHOW);
h.setNoSSH(true);
h.setCharset(BIN_ENCODING);
h.setSilent(true);
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import git4idea.commands.StringScanner;
import git4idea.config.GitConfigUtil;
* @throws VcsException in case of git error
*/
public static List<GitRemote> list(Project project, VirtualFile root) throws VcsException {
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.REMOTE);
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.REMOTE);
handler.setNoSSH(true);
handler.setSilent(true);
handler.addParameters("-v");
*/
@Nullable
public static GitRemote find(Project project, VirtualFile root, String name) throws VcsException {
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.REMOTE);
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.REMOTE);
handler.setNoSSH(true);
handler.setSilent(true);
handler.ignoreErrorCode(1);
* @throws VcsException if there is a problem with running git
*/
public Info localInfo(Project project, VirtualFile root) throws VcsException {
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.REMOTE);
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.REMOTE);
handler.setNoSSH(true);
handler.setSilent(true);
handler.addParameters("show", "-n", myName);
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
import com.intellij.openapi.vfs.VirtualFile;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
* @throws VcsException if there is a problem with running git
*/
public static GitRevisionNumber resolve(Project project, VirtualFile vcsRoot, @NonNls String rev) throws VcsException {
- GitSimpleHandler h = new GitSimpleHandler(project, vcsRoot, GitHandler.REV_LIST);
+ GitSimpleHandler h = new GitSimpleHandler(project, vcsRoot, GitCommand.REV_LIST);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--timestamp", "--max-count=1", rev);
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
* @throws VcsException if there is a problem with running git
*/
public static void listAsStrings(final Project project, final VirtualFile root, final Collection<String> tags) throws VcsException {
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.TAG);
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.TAG);
handler.setNoSSH(true);
handler.setSilent(true);
handler.addParameters("-l");
import com.intellij.util.Consumer;
import com.intellij.vcsUtil.VcsUtil;
import git4idea.changes.GitChangeUtils;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import git4idea.commands.StringScanner;
import git4idea.config.GitConfigUtil;
throws VcsException {
final List<CommittedChangeList> rc = new ArrayList<CommittedChangeList>();
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.LOG);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
h.setNoSSH(true);
h.addParameters("--pretty=format:%x0C%n" + GitChangeUtils.COMMITTED_CHANGELIST_FORMAT, "--name-status");
parametersSpecifier.consume(h);
import git4idea.changes.GitOutgoingChangesProvider;
import git4idea.checkin.GitCheckinEnvironment;
import git4idea.checkin.GitCommitAndPushExecutor;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import git4idea.config.GitVcsConfigurable;
import git4idea.config.GitVcsSettings;
import java.util.Collections;
import java.util.Date;
import java.util.List;
+import java.util.concurrent.locks.ReadWriteLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Git VCS implementation
* The queue that is used to schedule background task from actions
*/
private final BackgroundTaskQueue myTaskQueue;
+ /**
+ * The command read/write lock
+ */
+ private final ReadWriteLock myCommandLock = new ReentrantReadWriteLock(true);
private final TreeDiffProvider myTreeDiffProvider;
myTaskQueue = new BackgroundTaskQueue(myProject, GitBundle.getString("task.queue.title"));
}
+ /**
+ * @return the command lock
+ */
+ public ReadWriteLock getCommandLock() {
+ return myCommandLock;
+ }
+
/**
* Run task in background using the common queue (per project)
*
*/
public static String version(Project project) throws VcsException {
final String s;
- GitSimpleHandler h = new GitSimpleHandler(project, new File("."), GitHandler.VERSION);
+ GitSimpleHandler h = new GitSimpleHandler(project, new File("."), GitCommand.VERSION);
h.setNoSSH(true);
h.setSilent(true);
s = h.run();
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vfs.VirtualFile;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitLineHandler;
import git4idea.i18n.GitBundle;
import git4idea.rebase.GitInteractiveRebaseEditorHandler;
return null;
}
}
- GitLineHandler h = new GitLineHandler(project, root, GitHandler.REBASE);
+ GitLineHandler h = new GitLineHandler(project, root, GitCommand.REBASE);
h.addParameters(getOptionName());
return h;
}
import com.intellij.openapi.vfs.VirtualFile;
import git4idea.GitUtil;
import git4idea.GitVcs;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitHandlerUtil;
import git4idea.commands.GitLineHandler;
import git4idea.i18n.GitBundle;
GitBundle.getString("init.error.title"));
return;
}
- GitLineHandler h = new GitLineHandler(project, root, GitHandler.INIT);
+ GitLineHandler h = new GitLineHandler(project, root, GitCommand.INIT);
h.setNoSSH(true);
GitHandlerUtil.doSynchronously(h, GitBundle.getString("initializing.title"), h.printableCommandLine());
if (!h.errors().isEmpty()) {
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitHandlerUtil;
import git4idea.commands.GitSimpleHandler;
import git4idea.i18n.GitBundle;
}
}
affectedRoots.add(root);
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.REBASE);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.REBASE);
h.addParameters("--abort");
GitHandlerUtil.doSynchronously(h, getActionName(), h.printableCommandLine());
}
}
final VirtualFile root = h.workingDirectoryFile();
GitRebaseEditorService service = GitRebaseEditorService.getInstance();
- GitInteractiveRebaseEditorHandler editor = new GitInteractiveRebaseEditorHandler(service, project, root);
+ GitInteractiveRebaseEditorHandler editor = new GitInteractiveRebaseEditorHandler(service, project, root, h);
GitRebaseLineListener resultListener = new GitRebaseLineListener();
h.addLineListener(resultListener);
configureEditor(editor);
import git4idea.GitFileRevision;
import git4idea.GitRevisionNumber;
import git4idea.GitUtil;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import git4idea.commands.StringScanner;
import git4idea.history.GitHistoryUtils;
final VcsFileRevision revision,
final List<VcsFileRevision> revisions,
final VirtualFile file) throws VcsException {
- GitSimpleHandler h = new GitSimpleHandler(myProject, GitUtil.getGitRoot(repositoryFilePath), GitHandler.ANNOTATE);
+ GitSimpleHandler h = new GitSimpleHandler(myProject, GitUtil.getGitRoot(repositoryFilePath), GitCommand.ANNOTATE);
h.setNoSSH(true);
h.setStdoutSuppressed(true);
h.setCharset(file.getCharset());
import git4idea.GitContentRevision;
import git4idea.GitRevisionNumber;
import git4idea.GitUtil;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import git4idea.commands.StringScanner;
}
private void updateIndex() throws VcsException {
- GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitHandler.UPDATE_INDEX);
+ GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.UPDATE_INDEX);
handler.addParameters("--refresh", "--ignore-missing");
handler.setSilent(true);
handler.setNoSSH(true);
if (dirtyPaths.isEmpty()) {
return;
}
- GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitHandler.DIFF);
+ GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.DIFF);
handler.addParameters("--name-status", "--diff-filter=ADCMRUX", "-M", "HEAD");
handler.setNoSSH(true);
handler.setSilent(true);
if (!GitChangeUtils.isHeadMissing(ex)) {
throw ex;
}
- handler = new GitSimpleHandler(myProject, myVcsRoot, GitHandler.LS_FILES);
+ handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.LS_FILES);
handler.addParameters("--cached");
handler.setNoSSH(true);
handler.setSilent(true);
return;
}
// prepare handler
- GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitHandler.LS_FILES);
+ GitSimpleHandler handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.LS_FILES);
handler.addParameters("-v", "--unmerged");
handler.setSilent(true);
handler.setNoSSH(true);
// run handler and collect changes
parseFiles(handler.run());
// prepare handler
- handler = new GitSimpleHandler(myProject, myVcsRoot, GitHandler.LS_FILES);
+ handler = new GitSimpleHandler(myProject, myVcsRoot, GitCommand.LS_FILES);
handler.addParameters("-v", "--others", "--exclude-standard");
handler.setSilent(true);
handler.setNoSSH(true);
import git4idea.GitContentRevision;
import git4idea.GitRevisionNumber;
import git4idea.GitUtil;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import git4idea.commands.StringScanner;
import org.jetbrains.annotations.NonNls;
/**
* Parse changes from lines
*
- * @param project the context project
- * @param root the git root
+ * @param project the context project
+ * @param root the git root
* @return a set of unmerged files
* @throws VcsException if the input format does not matches expected format
*/
public static List<VirtualFile> unmergedFiles(Project project, VirtualFile root) throws VcsException {
HashSet<VirtualFile> unmerged = new HashSet<VirtualFile>();
String rootPath = root.getPath();
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.LS_FILES);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LS_FILES);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--unmerged");
file.refresh(false, false);
unmerged.add(file);
}
- if(unmerged.size() == 0) {
+ if (unmerged.size() == 0) {
return Collections.emptyList();
- } else {
+ }
+ else {
ArrayList<VirtualFile> rc = new ArrayList<VirtualFile>(unmerged.size());
rc.addAll(unmerged);
Collections.sort(rc, GitUtil.VIRTUAL_FILE_COMPARATOR);
@SuppressWarnings({"SameParameterValue"})
public static GitRevisionNumber loadRevision(final Project project, final VirtualFile vcsRoot, @NonNls final String revisionNumber)
throws VcsException {
- GitSimpleHandler handler = new GitSimpleHandler(project, vcsRoot, GitHandler.REV_LIST);
+ GitSimpleHandler handler = new GitSimpleHandler(project, vcsRoot, GitCommand.REV_LIST);
handler.addParameters("--timestamp", "--max-count=1", revisionNumber);
handler.endOptions();
handler.setNoSSH(true);
* @throws VcsException in case of problem with running git
*/
public static CommittedChangeList getRevisionChanges(Project project, VirtualFile root, String revisionName) throws VcsException {
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.SHOW);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.SHOW);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--name-status", "--no-abbrev", "-M", "--pretty=format:" + COMMITTED_CHANGELIST_FORMAT, "--encoding=UTF-8",
continue;
}
}
- GitSimpleHandler diffHandler = new GitSimpleHandler(project, root, GitHandler.DIFF);
+ GitSimpleHandler diffHandler = new GitSimpleHandler(project, root, GitCommand.DIFF);
diffHandler.setNoSSH(true);
diffHandler.setSilent(true);
diffHandler.addParameters("--name-status", "-M", parentRevision.getRev(), thisRevision.getRev());
HashSet<FilePath> realAdded = new HashSet<FilePath>();
HashSet<FilePath> realRemoved = new HashSet<FilePath>();
// perform diff
- GitSimpleHandler diff = new GitSimpleHandler(project, root, GitHandler.DIFF);
+ GitSimpleHandler diff = new GitSimpleHandler(project, root, GitCommand.DIFF);
diff.setNoSSH(true);
diff.setSilent(true);
diff.setStdoutSuppressed(true);
}
// perform merge commit
try {
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.COMMIT);
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.COMMIT);
handler.setNoSSH(true);
handler.addParameters("-F", messageFile.getAbsolutePath());
if (author != null) {
}
if (!removed.isEmpty()) {
try {
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.RM);
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.RM);
handler.addParameters("--ignore-unmatch");
handler.endOptions();
handler.addRelativePaths(removed);
Collection<FilePath> files,
File message,
final String nextCommitAuthor) {
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.COMMIT);
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.COMMIT);
handler.setNoSSH(true);
handler.addParameters("--only", "-F", message.getAbsolutePath());
if (nextCommitAuthor != null) {
import com.intellij.util.ui.tree.TreeUtil;
import git4idea.GitUtil;
import git4idea.GitVcs;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import git4idea.commands.StringScanner;
import git4idea.config.GitVcsSettings;
boolean stdin = CHECK_ATTR_STDIN_SUPPORTED.isLessOrEqual(GitVcs.getInstance(project).version());
for (final Map.Entry<VirtualFile, Set<VirtualFile>> e : files.entrySet()) {
final VirtualFile r = e.getKey();
- GitSimpleHandler h = new GitSimpleHandler(project, r, GitHandler.CHECK_ATTR);
+ GitSimpleHandler h = new GitSimpleHandler(project, r, GitCommand.CHECK_ATTR);
if (stdin) {
h.addParameters("--stdin", "-z");
}
r.remoteBranch = b.getTrackedBranchName(project, root);
if (r.remote != null) {
if (fetchData && !r.remote.equals(".")) {
- GitLineHandler fetch = new GitLineHandler(project, root, GitHandler.FETCH);
+ GitLineHandler fetch = new GitLineHandler(project, root, GitCommand.FETCH);
fetch.addParameters(r.remote, "-v");
Collection<VcsException> exs = GitHandlerUtil.doSynchronouslyWithExceptions(fetch);
exceptions.addAll(exs);
}
GitBranch tracked = b.tracked(project, root);
assert tracked != null : "Tracked branch cannot be null here";
- GitSimpleHandler unmerged = new GitSimpleHandler(project, root, GitHandler.LOG);
+ GitSimpleHandler unmerged = new GitSimpleHandler(project, root, GitCommand.LOG);
unmerged.addParameters("--pretty=format:%H", r.branch + ".." + tracked.getFullName());
unmerged.setNoSSH(true);
unmerged.setStdoutSuppressed(true);
r.remoteCommits++;
}
}
- GitSimpleHandler toPush = new GitSimpleHandler(project, root, GitHandler.LOG);
+ GitSimpleHandler toPush = new GitSimpleHandler(project, root, GitCommand.LOG);
toPush.addParameters("--pretty=format:%H%x20%ct%x20%at%x20%s%n%P", tracked.getFullName() + ".." + r.branch);
toPush.setNoSSH(true);
toPush.setStdoutSuppressed(true);
manager.runProcessWithProgressSynchronously(new Runnable() {
public void run() {
for (Root r : rootsToPush) {
- GitLineHandler h = new GitLineHandler(project, r.root, GitHandler.PUSH);
+ GitLineHandler h = new GitLineHandler(project, r.root, GitCommand.PUSH);
String src = r.commitToPush != null ? r.commitToPush : r.branch;
h.addParameters("-v", r.remote, src + ":" + r.remoteBranch);
GitPushUtils.trackPushRejectedAsError(h, "Rejected push (" + r.root.getPresentableUrl() + "): ");
import git4idea.GitBranch;
import git4idea.GitRemote;
import git4idea.GitTag;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitLineHandler;
import git4idea.config.GitConfigUtil;
import git4idea.i18n.GitBundle;
* @return a prepared handler for push operation
*/
public GitLineHandler handler() {
- GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitHandler.PUSH);
+ GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitCommand.PUSH);
String policy = (String)myPushPolicy.getSelectedItem();
if (PUSH_POLICY_ALL.equals(policy)) {
h.addParameters("--all");
import git4idea.GitBranch;
import git4idea.GitUtil;
import git4idea.GitVcs;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitHandler;
import git4idea.commands.GitLineHandler;
import git4idea.commands.StringScanner;
protected GitLineHandler makeStartHandler(VirtualFile root) throws VcsException {
List<String> commits = myReorderedCommits.get(root);
boolean hasMerges = myRootsWithMerges.contains(root);
- GitLineHandler h = new GitLineHandler(myProject, root, GitHandler.REBASE);
+ GitLineHandler h = new GitLineHandler(myProject, root, GitCommand.REBASE);
if (commits != null || hasMerges) {
h.addParameters("-i");
- PushRebaseEditor pushRebaseEditor = new PushRebaseEditor(root, commits, hasMerges);
+ PushRebaseEditor pushRebaseEditor = new PushRebaseEditor(root, commits, hasMerges, h);
myRebaseEditorNo = pushRebaseEditor.getHandlerNo();
myRebaseEditorService.configureHandler(h, myRebaseEditorNo);
if (hasMerges) {
*/
@Override
protected void configureRebaseEditor(VirtualFile root, GitLineHandler h) {
- GitInteractiveRebaseEditorHandler editorHandler = new GitInteractiveRebaseEditorHandler(myRebaseEditorService, myProject, root);
+ GitInteractiveRebaseEditorHandler editorHandler = new GitInteractiveRebaseEditorHandler(myRebaseEditorService, myProject, root, h);
editorHandler.setRebaseEditorShown();
myRebaseEditorNo = editorHandler.getHandlerNo();
myRebaseEditorService.configureHandler(h, myRebaseEditorNo);
* @param commits the reordered commits
* @param hasMerges if true, the vcs root has merges
*/
- public PushRebaseEditor(final VirtualFile root, List<String> commits, boolean hasMerges) {
- super(myRebaseEditorService, myProject, root);
+ public PushRebaseEditor(final VirtualFile root, List<String> commits, boolean hasMerges, GitHandler h) {
+ super(myRebaseEditorService, myProject, root, h);
myCommits = commits;
myHasMerges = hasMerges;
}
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
import git4idea.GitBranch;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitLineHandler;
import git4idea.commands.GitLineHandlerAdapter;
import org.jetbrains.annotations.Nullable;
if (tracked == null) {
return null;
}
- final GitLineHandler rc = new GitLineHandler(project, vcsRoot, GitHandler.PUSH);
+ final GitLineHandler rc = new GitLineHandler(project, vcsRoot, GitCommand.PUSH);
rc.addParameters("-v", remote, current.getFullName() + ":" + tracked);
trackPushRejectedAsError(rc, "Rejected push (" + vcsRoot.getPresentableUrl() + "): ");
return rc;
import git4idea.GitBranch;
import git4idea.GitTag;
import git4idea.GitVcs;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitLineHandler;
import git4idea.commands.GitSimpleHandler;
import git4idea.config.GitVcsSettings;
if (branch.length() == 0) {
return null;
}
- GitSimpleHandler h = new GitSimpleHandler(myProject, gitRoot(), GitHandler.BRANCH);
+ GitSimpleHandler h = new GitSimpleHandler(myProject, gitRoot(), GitCommand.BRANCH);
h.setNoSSH(true);
if (myTrackBranchCheckBox.isSelected()) {
h.addParameters("--track");
* @return a handler that checkouts branch
*/
public GitLineHandler checkoutHandler() {
- GitLineHandler h = new GitLineHandler(myProject, gitRoot(), GitHandler.CHECKOUT);
+ GitLineHandler h = new GitLineHandler(myProject, gitRoot(), GitCommand.CHECKOUT);
h.setNoSSH(true);
final String newBranch = myNewBranchName.getText();
if (newBranch.length() == 0) {
import com.intellij.openapi.vfs.VirtualFile;
import git4idea.GitVcs;
import git4idea.actions.BasicAction;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitHandlerUtil;
import git4idea.commands.GitLineHandler;
import git4idea.config.GitVersion;
* @return a handler for clone operation
*/
public static GitLineHandler clone(Project project, final String url, final File directory, final String name, final String originName) {
- GitLineHandler handler = new GitLineHandler(project, directory, GitHandler.CLONE);
+ GitLineHandler handler = new GitLineHandler(project, directory, GitCommand.CLONE);
if (VERBOSE_CLONE_SUPPORTED.isLessOrEqual(GitVcs.getInstance(project).version())) {
handler.addParameters("-v");
}
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.*;
import com.intellij.openapi.vfs.VirtualFile;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitHandlerUtil;
import git4idea.commands.GitSimpleHandler;
import git4idea.i18n.GitBundle;
public void actionPerformed(final ActionEvent e) {
myTestURL = myRepositoryURL.getText();
String output = GitHandlerUtil
- .doSynchronously(GitSimpleHandler.checkRepository(myProject, myTestURL), GitBundle.message("clone.testing", myTestURL),
- "connection test");
+ .doSynchronously(checkRepository(myProject, myTestURL), GitBundle.message("clone.testing", myTestURL), "connection test");
if (output != null) {
Messages.showInfoMessage(myTestButton, GitBundle.message("clone.test.success.message", myTestURL),
GitBundle.getString("clone.test.success"));
protected String getHelpId() {
return "reference.VersionControl.Git.CloneRepository";
}
+
+ /**
+ * Prepare check repository handler. To do this ls-remote command is executed and attempts to match
+ * master tag. This will likely return only single entry or none, if there is no master
+ * branch. Stdout output is ignored. Stderr is used to construct exception message and shown
+ * in error message box if exit is negative.
+ *
+ * @param project the project
+ * @param url the url to check
+ * @return a simple handler that does the task
+ */
+ private static GitSimpleHandler checkRepository(Project project, final String url) {
+ GitSimpleHandler handler = new GitSimpleHandler(project, new File("."), GitCommand.LS_REMOTE);
+ handler.addParameters(url, "master");
+ return handler;
+ }
}
--- /dev/null
+/*
+ * Copyright 2000-2009 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package git4idea.commands;
+
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * The descriptor of git command. It contains policy information about myLocking and GUI thread policy.
+ */
+public class GitCommand {
+
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand STASH = write("stash");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand CLONE = write("clone");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand RM = write("rm");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand ADD = write("add");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand ANNOTATE = read("annotate");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand COMMIT = write("commit");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand CONFIG = meta("config");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand FETCH = write("fetch");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand SHOW = write("show");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand LOG = meta("log");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand INIT = write("init");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand BRANCH = meta("branch");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand MERGE = write("merge");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand MERGE_BASE = meta("merge-base");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand PUSH = write("push");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand LS_REMOTE = meta("ls-remote");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand REMOTE = meta("remote");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand REV_LIST = meta("rev-list");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand CHECKOUT = write("checkout");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand TAG = meta("tag");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand PULL = write("pull");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand LS_FILES = read("ls-files");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand DIFF = read("diff");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand VERSION = meta("version");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand REBASE = writeSuspendable("rebase");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand RESET = write("reset");
+ /**
+ * The constant for git command
+ */
+ public static final GitCommand UPDATE_INDEX = write("update-index");
+ /**
+ * Check attributes command
+ */
+ public static final GitCommand CHECK_ATTR = read("check-attr");
+ /**
+ * Name of environment variable that specifies editor for the git
+ */
+ public static final String GIT_EDITOR_ENV = "GIT_EDITOR";
+
+ /**
+ * The command myName
+ */
+ @NotNull @NonNls private final String myName;
+ /**
+ * Locking policy for the command
+ */
+ @NotNull private final LockingPolicy myLocking;
+ /**
+ * Thread policy for the command
+ */
+ @NotNull private final ThreadPolicy myThreading;
+
+ /**
+ * The constructor
+ *
+ * @param name the command myName
+ * @param locking the myLocking policy
+ * @param threading the thread policy
+ */
+ private GitCommand(@NonNls @NotNull String name, @NotNull LockingPolicy locking, @NotNull ThreadPolicy threading) {
+ this.myLocking = locking;
+ this.myName = name;
+ this.myThreading = threading;
+ }
+
+ /**
+ * Create command descriptor that performs metadata operations only
+ *
+ * @param name the command myName
+ * @return the created command object
+ */
+ private static GitCommand meta(String name) {
+ return new GitCommand(name, LockingPolicy.META, ThreadPolicy.ANY);
+ }
+
+ /**
+ * Create command descriptor that performs reads from index
+ *
+ * @param name the command myName
+ * @return the create command objects
+ */
+ private static GitCommand read(String name) {
+ return new GitCommand(name, LockingPolicy.READ, ThreadPolicy.BACKGROUND_ONLY);
+ }
+
+ /**
+ * Create command descriptor that performs write operations
+ *
+ * @param name the command myName
+ * @return the created command object
+ */
+ private static GitCommand write(String name) {
+ return new GitCommand(name, LockingPolicy.WRITE, ThreadPolicy.BACKGROUND_ONLY);
+ }
+
+ /**
+ * Create command descriptor that performs write operations
+ *
+ * @param name the command myName
+ * @return the created command object
+ */
+ private static GitCommand writeSuspendable(String name) {
+ return new GitCommand(name, LockingPolicy.WRITE_SUSPENDABLE, ThreadPolicy.BACKGROUND_ONLY);
+ }
+
+ /**
+ * @return the command name
+ */
+ @NotNull
+ public String name() {
+ return myName;
+ }
+
+ /**
+ * @return the locking policy for the command
+ */
+ @NotNull
+ public LockingPolicy lockingPolicy() {
+ return myLocking;
+ }
+
+ /**
+ * @return the locking policy for the command
+ */
+ @NotNull
+ public ThreadPolicy threadingPolicy() {
+ return myThreading;
+ }
+
+ /**
+ * The myLocking policy for the command
+ */
+ enum LockingPolicy {
+ /**
+ * Read lock should be acquired for the command
+ */
+ READ,
+ /**
+ * Write lock should be acquired for the command
+ */
+ WRITE,
+ /**
+ * Write lock should be acquired for the command, and it could be acquired in several intervals
+ */
+ WRITE_SUSPENDABLE,
+ /**
+ * Metadata read/write command
+ */
+ META, }
+
+ /**
+ * Thread policy for command
+ */
+ enum ThreadPolicy {
+ /**
+ * Any thread could be used
+ */
+ ANY,
+ /**
+ * Only background thread could be used
+ */
+ BACKGROUND_ONLY
+ }
+}
* @throws VcsException in case of git problem
*/
public static String delete(Project project, VirtualFile root, List<FilePath> files) throws VcsException {
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.RM);
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.RM);
handler.endOptions();
handler.addRelativePaths(files);
handler.setNoSSH(true);
* @throws VcsException in case of git problem
*/
public static String deleteFiles(Project project, VirtualFile root, List<VirtualFile> files) throws VcsException {
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.RM);
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.RM);
handler.endOptions();
handler.addRelativeFiles(files);
handler.setNoSSH(true);
* @throws VcsException in case of git problem
*/
public static String addFiles(Project project, VirtualFile root, Collection<VirtualFile> files) throws VcsException {
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.ADD);
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.ADD);
handler.endOptions();
handler.addRelativeFiles(files);
handler.setNoSSH(true);
* @throws VcsException in case of git problem
*/
public static String addPaths(Project project, VirtualFile root, Collection<FilePath> files) throws VcsException {
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.ADD);
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.ADD);
handler.endOptions();
handler.addRelativePaths(files);
handler.setNoSSH(true);
* the context project (might be a default project)
*/
private final Project myProject;
+ /**
+ * The descriptor for the command to be executed
+ */
+ protected final GitCommand myCommand;
/**
* the working directory
*/
* if true, the command execution is not logged in version control view
*/
@SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized"}) private boolean mySilent;
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String CLONE = "clone";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String RM = "rm";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String ADD = "add";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String ANNOTATE = "annotate";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String COMMIT = "commit";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String CONFIG = "config";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String FETCH = "fetch";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String SHOW = "show";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String LOG = "log";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String INIT = "init";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String BRANCH = "branch";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String MERGE = "merge";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String MERGE_BASE = "merge-base";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String PUSH = "push";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String LS_REMOTE = "ls-remote";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String REMOTE = "remote";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String REV_LIST = "rev-list";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String CHECKOUT = "checkout";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String TAG = "tag";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String PULL = "pull";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String LS_FILES = "ls-files";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String DIFF = "diff";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String VERSION = "version";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String STASH = "stash";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String REBASE = "rebase";
- /**
- * The constant for git command {@value}
- */
- @NonNls public static final String RESET = "reset";
- @NonNls public static final String UPDATE_INDEX = "update-index";
- /**
- * Check attributes command
- */
- @NonNls public static final String CHECK_ATTR = "check-attr";
- /**
- * Name of environment variable that specifies editor for the git
- */
- @NonNls public static final String GIT_EDITOR_ENV = "GIT_EDITOR";
/**
* The vcs object
*/
* The settings object
*/
private GitVcsSettings mySettings;
+ /**
+ * Suspend action used by {@link #suspendWriteLock()}
+ */
+ private Runnable mySuspendAction;
+ /**
+ * Resume action used by {@link #resumeWriteLock()}
+ */
+ private Runnable myResumeAction;
/**
* @param directory a process directory
* @param command a command to execute (if empty string, the parameter is ignored)
*/
- protected GitHandler(@NotNull Project project, @NotNull File directory, @NotNull String command) {
+ protected GitHandler(@NotNull Project project, @NotNull File directory, @NotNull GitCommand command) {
myProject = project;
+ myCommand = command;
mySettings = GitVcsSettings.getInstanceChecked(project);
myEnv = new HashMap<String, String>(System.getenv());
if (!myEnv.containsKey("HOME")) {
myCommandLine = new GeneralCommandLine();
myCommandLine.setExePath(mySettings.GIT_EXECUTABLE);
myCommandLine.setWorkingDirectory(myWorkingDirectory);
- if (command.length() > 0) {
- myCommandLine.addParameter(command);
+ if (command.name().length() > 0) {
+ myCommandLine.addParameter(command.name());
}
}
* @param vcsRoot a process directory
* @param command a command to execute
*/
- protected GitHandler(final Project project, final VirtualFile vcsRoot, final String command) {
+ protected GitHandler(final Project project, final VirtualFile vcsRoot, final GitCommand command) {
this(project, VfsUtil.virtualToIoFile(vcsRoot), command);
}
public void setInputProcessor(Processor<OutputStream> inputProcessor) {
myInputProcessor = inputProcessor;
}
+
+ /**
+ * Set suspend/resume actions
+ *
+ * @param suspend the suspend action
+ * @param resume the resume action
+ */
+ synchronized void setSuspendResume(Runnable suspend, Runnable resume) {
+ mySuspendAction = suspend;
+ myResumeAction = resume;
+ }
+
+ /**
+ * Suspend write lock held by the handler
+ */
+ public synchronized void suspendWriteLock() {
+ assert mySuspendAction != null;
+ mySuspendAction.run();
+ }
+
+ /**
+ * Resume write lock held by the handler
+ */
+ public synchronized void resumeWriteLock() {
+ assert mySuspendAction != null;
+ myResumeAction.run();
+ }
}
*/
package git4idea.commands;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import java.awt.*;
import java.util.Collection;
+import java.util.concurrent.LinkedBlockingQueue;
/**
* Handler utilities that allow running handlers with progress indicators
*/
public class GitHandlerUtil {
+ /**
+ * The logger instance
+ */
+ private final static Logger LOG = Logger.getInstance(GitHandlerUtil.class.getName());
+
/**
* a private constructor for utility class
*/
* @param setIndeterminateFlag if true handler is configured as indeterminate
*/
private static void runInCurrentThread(final GitHandler handler, final ProgressIndicator indicator, final boolean setIndeterminateFlag) {
- handler.start();
- if (indicator != null) {
- indicator.setText(GitBundle.message("git.running", handler.printableCommandLine()));
- if (setIndeterminateFlag) {
- indicator.setIndeterminate(true);
+ runInCurrentThread(handler, new Runnable() {
+ public void run() {
+ if (indicator != null) {
+ indicator.setText(GitBundle.message("git.running", handler.printableCommandLine()));
+ if (setIndeterminateFlag) {
+ indicator.setIndeterminate(true);
+ }
+ }
}
+ });
+ }
+
+ /**
+ * Run handler in the current thread
+ *
+ * @param handler a handler to run
+ * @param postStartAction an action that is executed
+ */
+ static void runInCurrentThread(final GitHandler handler, @Nullable final Runnable postStartAction) {
+ boolean suspendable = false;
+ switch (handler.myCommand.lockingPolicy()) {
+ case META:
+ // do nothing no locks are taken for metadata
+ break;
+ case READ:
+ handler.myVcs.getCommandLock().readLock().lock();
+ break;
+ case WRITE_SUSPENDABLE:
+ suspendable = true;
+ case WRITE:
+ handler.myVcs.getCommandLock().writeLock().lock();
+ break;
}
- if (handler.isStarted()) {
- handler.waitFor();
+ try {
+ if (suspendable) {
+ final Object EXIT = new Object();
+ final Object SUSPEND = new Object();
+ final Object RESUME = new Object();
+ final LinkedBlockingQueue<Object> queue = new LinkedBlockingQueue<Object>();
+ boolean suspended = false;
+ Runnable suspend = new Runnable() {
+ public void run() {
+ queue.add(SUSPEND);
+ }
+ };
+ Runnable resume = new Runnable() {
+ public void run() {
+ queue.add(RESUME);
+ }
+ };
+ handler.setSuspendResume(suspend, resume);
+ handler.start();
+ if (handler.isStarted()) {
+ if (postStartAction != null) {
+ postStartAction.run();
+ }
+ ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
+ public void run() {
+ handler.waitFor();
+ queue.add(EXIT);
+ }
+ });
+ while (true) {
+ Object action;
+ while (true) {
+ try {
+ action = queue.take();
+ break;
+ }
+ catch (InterruptedException e) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("queue.take() is interrupted", e);
+ }
+ }
+ }
+ if (action == EXIT) {
+ if (suspended) {
+ LOG.error("Exiting while RW lock is suspended (reacquiring W-lock command)");
+ handler.myVcs.getCommandLock().writeLock().lock();
+ }
+ break;
+ }
+ else if (action == SUSPEND) {
+ if (suspended) {
+ LOG.error("Suspending suspended W-lock (ignoring command)");
+ }
+ else {
+ handler.myVcs.getCommandLock().writeLock().unlock();
+ }
+ }
+ else if (action == RESUME) {
+ if (!suspended) {
+ LOG.error("Resuming not suspended W-lock (ignoring command)");
+ }
+ else {
+ handler.myVcs.getCommandLock().writeLock().lock();
+ }
+ }
+ }
+ }
+ }
+ else {
+ handler.start();
+ if (handler.isStarted()) {
+ if (postStartAction != null) {
+ postStartAction.run();
+ }
+ handler.waitFor();
+ }
+ }
+ }
+ finally {
+ switch (handler.myCommand.lockingPolicy()) {
+ case META:
+ // do nothing no locks are taken for metadata
+ break;
+ case READ:
+ handler.myVcs.getCommandLock().readLock().unlock();
+ break;
+ case WRITE_SUSPENDABLE:
+ case WRITE:
+ handler.myVcs.getCommandLock().writeLock().unlock();
+ break;
+ }
}
}
* @param command a command to execute
*/
@SuppressWarnings({"WeakerAccess"})
- public GitLineHandler(@NotNull Project project, @NotNull File directory, @NotNull String command) {
+ public GitLineHandler(@NotNull Project project, @NotNull File directory, @NotNull GitCommand command) {
super(project, directory, command);
}
* @param vcsRoot a process directory
* @param command a command to execute
*/
- public GitLineHandler(@NotNull final Project project, @NotNull final VirtualFile vcsRoot, @NotNull final String command) {
+ public GitLineHandler(@NotNull final Project project, @NotNull final VirtualFile vcsRoot, @NotNull final GitCommand command) {
super(project, vcsRoot, command);
}
* @param command a command to execute
*/
@SuppressWarnings({"WeakerAccess"})
- public GitSimpleHandler(@NotNull Project project, @NotNull File directory, @NotNull String command) {
+ public GitSimpleHandler(@NotNull Project project, @NotNull File directory, @NotNull GitCommand command) {
super(project, directory, command);
}
* @param command a command to execute
*/
@SuppressWarnings({"WeakerAccess"})
- public GitSimpleHandler(@NotNull final Project project, @NotNull final VirtualFile directory, @NotNull final String command) {
+ public GitSimpleHandler(@NotNull final Project project, @NotNull final VirtualFile directory, @NotNull final GitCommand command) {
super(project, directory, command);
}
ex[0] = new VcsException("Process failed to start: " + exception.toString(), exception);
}
});
- start();
- if (isStarted()) {
- waitFor();
- }
+ GitHandlerUtil.runInCurrentThread(this, null);
if (ex[0] != null) {
throw ex[0];
}
return result[0];
}
-
- /**
- * Prepare check repository handler. To do this ls-remote command is executed and attempts to match
- * master tag. This will likely return only single entry or none, if there is no master
- * branch. Stdout output is ignored. Stderr is used to construct exception message and shown
- * in error message box if exit is negative.
- *
- * @param project the project
- * @param url the url to check
- * @return a simple handler that does the task
- */
- public static GitSimpleHandler checkRepository(Project project, final String url) {
- GitSimpleHandler handler = new GitSimpleHandler(project, new File("."), LS_REMOTE);
- handler.addParameters(url, "master");
- return handler;
- }
-
}
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
import git4idea.GitUtil;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.Nullable;
* @throws VcsException if there is a problem with running git
*/
public static void getValues(Project project, VirtualFile root, String keyMask, Map<String, String> result) throws VcsException {
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.CONFIG);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.CONFIG);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--null", "--get-regexp", keyMask);
*/
public static List<Pair<String, String>> getAllValues(Project project, VirtualFile root, @NonNls String key) throws VcsException {
List<Pair<String, String>> result = new ArrayList<Pair<String, String>>();
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.CONFIG);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.CONFIG);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--null", "--get-all", key);
*/
@Nullable
public static String getValue(Project project, VirtualFile root, @NonNls String key) throws VcsException {
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.CONFIG);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.CONFIG);
h.setNoSSH(true);
h.setSilent(true);
h.ignoreErrorCode(1);
* @throws VcsException if there is a problem with running git
*/
public static void unsetValue(Project project, VirtualFile root, String key) throws VcsException {
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.CONFIG);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.CONFIG);
h.setNoSSH(true);
h.setSilent(true);
h.ignoreErrorCode(1);
* @throws VcsException if there is a problem with running git
*/
public static void setValue(Project project, VirtualFile root, String key, String value) throws VcsException {
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.CONFIG);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.CONFIG);
h.setNoSSH(true);
h.setSilent(true);
h.ignoreErrorCode(1);
import com.intellij.openapi.vfs.VirtualFile;
import git4idea.GitBranchesSearcher;
import git4idea.changes.GitChangeUtils;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import git4idea.commands.StringScanner;
final GitBranchesSearcher searcher = new GitBranchesSearcher(myProject, vcsRoot, true);
if (searcher.getLocal() == null || searcher.getRemote() == null) return Collections.emptyList();
- GitSimpleHandler handler = new GitSimpleHandler(myProject, vcsRoot, GitHandler.DIFF);
+ GitSimpleHandler handler = new GitSimpleHandler(myProject, vcsRoot, GitCommand.DIFF);
handler.addParameters("--name-status", "--diff-filter=ADCMRUX", "-M", "HEAD..." + searcher.getRemote().getFullName());
handler.setNoSSH(true);
handler.setSilent(true);
import com.intellij.util.text.StringTokenizer;
import com.intellij.vcsUtil.VcsUtil;
import git4idea.*;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import org.jetbrains.annotations.Nullable;
@Nullable
public static VcsRevisionNumber getCurrentRevision(final Project project, FilePath filePath) throws VcsException {
filePath = getLastCommitName(project, filePath);
- GitSimpleHandler h = new GitSimpleHandler(project, GitUtil.getGitRoot(filePath), GitHandler.LOG);
+ GitSimpleHandler h = new GitSimpleHandler(project, GitUtil.getGitRoot(filePath), GitCommand.LOG);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("-n1", "--pretty=format:%H%n%ct%n");
return new ItemLatestState(getCurrentRevision(project, filePath), true, false);
}
filePath = getLastCommitName(project, filePath);
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.LOG);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("-n1", "--pretty=format:%H%n%ct", "--name-status", t.getFullName());
// adjust path using change manager
path = getLastCommitName(project, path);
final VirtualFile root = GitUtil.getGitRoot(path);
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.LOG);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
h.setNoSSH(true);
h.setStdoutSuppressed(true);
h.addParameters("-M", "--follow", "--name-only",
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
import git4idea.GitVcs;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitLineHandler;
import git4idea.commands.GitSimpleHandler;
import git4idea.i18n.GitBundle;
private void updateBranches() {
try {
VirtualFile root = getSelectedRoot();
- GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitHandler.BRANCH);
+ GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitCommand.BRANCH);
handler.setNoSSH(true);
handler.setSilent(true);
handler.addParameters("--no-color", "-a", "--no-merged");
throw new IllegalStateException("The handler could be retrieved only if dialog was completed successfully.");
}
VirtualFile root = (VirtualFile)myGitRoot.getSelectedItem();
- GitLineHandler h = new GitLineHandler(myProject, root, GitHandler.MERGE);
+ GitLineHandler h = new GitLineHandler(myProject, root, GitCommand.MERGE);
// ignore merge failure
h.ignoreErrorCode(1);
h.setNoSSH(true);
import git4idea.GitFileRevision;
import git4idea.GitRevisionNumber;
import git4idea.GitUtil;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitFileUtils;
-import git4idea.commands.GitHandler;
import git4idea.commands.GitSimpleHandler;
import git4idea.commands.StringScanner;
import git4idea.i18n.GitBundle;
Map<String, Conflict> cs = new HashMap<String, Conflict>();
VirtualFile root = e.getKey();
List<VirtualFile> files = e.getValue();
- GitSimpleHandler h = new GitSimpleHandler(myProject, root, GitHandler.LS_FILES);
+ GitSimpleHandler h = new GitSimpleHandler(myProject, root, GitCommand.LS_FILES);
h.setNoSSH(true);
h.setStdoutSuppressed(true);
h.addParameters("--exclude-standard", "--unmerged", "-t", "-z");
* @param files the files to describe
*/
public void collectConflicts(VirtualFile root, List<VirtualFile> files) {
- GitSimpleHandler h = new GitSimpleHandler(myProject, root, GitHandler.LS_FILES);
+ GitSimpleHandler h = new GitSimpleHandler(myProject, root, GitCommand.LS_FILES);
h.setNoSSH(true);
h.addParameters("-t", "--exclude-standard", "--unmerged");
h.endOptions();
import com.intellij.util.ArrayUtil;
import git4idea.GitRemote;
import git4idea.GitVcs;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitHandlerUtil;
import git4idea.commands.GitLineHandler;
import git4idea.commands.GitSimpleHandler;
listener.changedUpdate(null);
myGetBranchesButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
- GitSimpleHandler h = new GitSimpleHandler(myProject, gitRoot(), GitHandler.LS_REMOTE);
+ GitSimpleHandler h = new GitSimpleHandler(myProject, gitRoot(), GitCommand.LS_REMOTE);
h.addParameters("--heads", myRemote.getSelectedItem().toString());
String output = GitHandlerUtil.doSynchronously(h, GitBundle.getString("pull.getting.remote.branches"), h.printableCommandLine());
if (output == null) {
* @return a pull handler configured according to dialog options
*/
public GitLineHandler pullHandler() {
- GitLineHandler h = new GitLineHandler(myProject, gitRoot(), GitHandler.PULL);
+ GitLineHandler h = new GitLineHandler(myProject, gitRoot(), GitCommand.PULL);
// ignore merge failure for the pull
h.ignoreErrorCode(1);
h.addParameters("--no-stat");
import git4idea.GitRevisionNumber;
import git4idea.GitUtil;
import git4idea.GitVcs;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import git4idea.commands.StringScanner;
try {
// collect unmerged
String root = myRoot.getPath();
- GitSimpleHandler h = new GitSimpleHandler(myProject, myRoot, GitHandler.LS_FILES);
+ GitSimpleHandler h = new GitSimpleHandler(myProject, myRoot, GitCommand.LS_FILES);
h.setNoSSH(true);
h.setSilent(true);
h.addParameters("--unmerged");
*/
private void processDiff(String root, TreeSet<String> updated, TreeSet<String> created, TreeSet<String> removed, String revisions)
throws VcsException {
- GitSimpleHandler h = new GitSimpleHandler(myProject, myRoot, GitHandler.DIFF);
+ GitSimpleHandler h = new GitSimpleHandler(myProject, myRoot, GitCommand.DIFF);
h.setSilent(true);
h.setNoSSH(true);
// note that moves are not detected here
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ui.UIUtil;
+import git4idea.commands.GitHandler;
import org.jetbrains.annotations.NotNull;
import java.io.Closeable;
* The git repository root
*/
private final VirtualFile myRoot;
+ /**
+ * The handler that specified this editor
+ */
+ private GitHandler myHandler;
/**
* The handler number
*/
* @param service the service object that has created this handler
* @param project the context project
* @param root the git repository root
+ * @param handler the handler for process that needs this editor
*/
public GitInteractiveRebaseEditorHandler(@NotNull final GitRebaseEditorService service,
@NotNull final Project project,
- @NotNull final VirtualFile root) {
+ @NotNull final VirtualFile root,
+ @NotNull GitHandler handler) {
myService = service;
myProject = project;
myRoot = root;
+ myHandler = handler;
myHandlerNo = service.registerHandler(this);
}
+ /**
+ * @return the handler for the process that started this editor
+ */
+ public GitHandler getHandler() {
+ return myHandler;
+ }
+
/**
* Edit commits request
*
import com.intellij.ui.DocumentAdapter;
import git4idea.GitBranch;
import git4idea.GitTag;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitLineHandler;
import git4idea.config.GitConfigUtil;
import git4idea.i18n.GitBundle;
}
public GitLineHandler handler() {
- GitLineHandler h = new GitLineHandler(myProject, gitRoot(), GitHandler.REBASE);
+ GitLineHandler h = new GitLineHandler(myProject, gitRoot(), GitCommand.REBASE);
h.setNoSSH(true);
if (myInteractiveCheckBox.isSelected() && myInteractiveCheckBox.isEnabled()) {
h.addParameters("-i");
*/
package git4idea.rebase;
+import git4idea.commands.GitHandler;
+
/**
* The interface
*/
* @return the exit code to be returned from editor
*/
int editCommits(String path);
+
+ /**
+ * @return the handler for the git process
+ */
+ GitHandler getHandler();
}
import com.intellij.ide.XmlRpcServer;
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.components.ServiceManager;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitHandler;
import git4idea.commands.GitLineHandler;
import git4idea.commands.ScriptGenerator;
* @param editorNo the editor number
*/
public void configureHandler(GitLineHandler h, int editorNo) {
- h.setEnvironment(GitHandler.GIT_EDITOR_ENV, getEditorCommand());
+ h.setEnvironment(GitCommand.GIT_EDITOR_ENV, getEditorCommand());
h.setEnvironment(GitRebaseEditorMain.IDEA_REBASE_HANDER_NO, Integer.toString(editorNo));
}
*/
@SuppressWarnings({"UnusedDeclaration"})
public int editCommits(int handlerNo, String path) {
- return getHandler(handlerNo).editCommits(path);
+ GitRebaseEditorHandler editor = getHandler(handlerNo);
+ GitHandler handler = editor.getHandler();
+ handler.suspendWriteLock();
+ try {
+ return editor.editCommits(path);
+ }
+ finally {
+ handler.resumeWriteLock();
+ }
}
}
}
import com.intellij.openapi.vcs.rollback.RollbackProgressListener;
import com.intellij.openapi.vfs.VirtualFile;
import git4idea.GitUtil;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import git4idea.i18n.GitBundle;
import org.jetbrains.annotations.NotNull;
* @throws VcsException Id it breaks.
*/
public void revert(final VirtualFile root, final List<FilePath> files) throws VcsException {
- GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitHandler.CHECKOUT);
+ GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitCommand.CHECKOUT);
handler.setNoSSH(true);
handler.addParameters("HEAD");
handler.endOptions();
* @throws VcsException if there is a problem with running git
*/
private void unindex(final VirtualFile root, final List<FilePath> files) throws VcsException {
- GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitHandler.RM);
+ GitSimpleHandler handler = new GitSimpleHandler(myProject, root, GitCommand.RM);
handler.setNoSSH(true);
handler.addParameters("--cached");
handler.addParameters("-f");
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.DocumentAdapter;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitLineHandler;
import git4idea.i18n.GitBundle;
* @return the handler for the fetch operation
*/
public GitLineHandler fetchHandler() {
- GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitHandler.FETCH);
+ GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitCommand.FETCH);
h.addParameters("-v");
if (myForceReferencesUpdateCheckBox.isSelected()) {
h.addParameters("--force");
import com.intellij.util.ui.tree.TreeUtil;
import git4idea.GitBranch;
import git4idea.GitTag;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitHandlerUtil;
import git4idea.commands.GitSimpleHandler;
import git4idea.commands.StringScanner;
// perform update
myGetRefsButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
- GitSimpleHandler handler = new GitSimpleHandler(myProject, myRoot, GitHandler.LS_REMOTE);
+ GitSimpleHandler handler = new GitSimpleHandler(myProject, myRoot, GitCommand.LS_REMOTE);
if (myIncludeBranchesCheckBox.isSelected()) {
handler.addParameters("--heads");
myBranches.clear();
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vfs.VirtualFile;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitLineHandler;
import git4idea.i18n.GitBundle;
* @return the handler for reset operation
*/
public GitLineHandler handler() {
- GitLineHandler handler = new GitLineHandler(myProject, getGitRoot(), GitHandler.RESET);
+ GitLineHandler handler = new GitLineHandler(myProject, getGitRoot(), GitCommand.RESET);
handler.setNoSSH(true);
String type = (String)myResetTypeComboBox.getSelectedItem();
if (SOFT.equals(type)) {
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.vfs.VirtualFile;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitLineHandler;
import git4idea.i18n.GitBundle;
* @return the handler
*/
public GitLineHandler handler() {
- GitLineHandler handler = new GitLineHandler(myProject, getGitRoot(), GitHandler.STASH);
+ GitLineHandler handler = new GitLineHandler(myProject, getGitRoot(), GitCommand.STASH);
handler.addParameters("save");
if (myKeepIndexCheckBox.isSelected()) {
handler.addParameters("--keep-index");
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.DocumentAdapter;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitHandlerUtil;
import git4idea.commands.GitSimpleHandler;
import git4idea.commands.StringScanner;
messageFile = null;
}
try {
- GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitHandler.TAG);
+ GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitCommand.TAG);
h.setNoSSH(true);
if (hasMessage) {
h.addParameters("-a");
*/
private void fetchTags() {
myExistingTags.clear();
- GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitHandler.TAG);
+ GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitCommand.TAG);
h.setNoSSH(true);
h.setSilent(true);
String output = GitHandlerUtil.doSynchronously(h, GitBundle.getString("tag.getting.existing.tags"), h.printableCommandLine());
});
myClearButton.addActionListener(new ActionListener() {
public void actionPerformed(final ActionEvent e) {
- GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitHandler.STASH);
+ GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitCommand.STASH);
h.setNoSSH(true);
h.addParameters("clear");
GitHandlerUtil.doSynchronously(h, GitBundle.getString("unstash.clearing.stashes"), h.printableCommandLine());
}
private GitSimpleHandler dropHandler(String stash) {
- GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitHandler.STASH);
+ GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitCommand.STASH);
h.setNoSSH(true);
h.addParameters("drop", stash);
return h;
private void refreshStashList() {
final DefaultListModel listModel = (DefaultListModel)myStashList.getModel();
listModel.clear();
- GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitHandler.STASH);
+ GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitCommand.STASH);
h.setSilent(true);
h.setNoSSH(true);
h.addParameters("list");
* @return unstash handler
*/
private GitLineHandler handler(boolean escaped) {
- GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitHandler.STASH);
+ GitLineHandler h = new GitLineHandler(myProject, getGitRoot(), GitCommand.STASH);
h.setNoSSH(true);
String branch = myBranchTextField.getText();
if (branch.length() == 0) {
import git4idea.GitUtil;
import git4idea.GitVcs;
import git4idea.changes.GitChangeUtils;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitHandlerUtil;
import git4idea.commands.GitLineHandler;
import git4idea.commands.GitLineHandlerAdapter;
VirtualFile root,
RebaseConflictDetector rebaseConflictDetector,
final String action) {
- GitLineHandler rh = new GitLineHandler(myProject, root, GitHandler.REBASE);
+ GitLineHandler rh = new GitLineHandler(myProject, root, GitCommand.REBASE);
// ignore failure for abort
rh.ignoreErrorCode(1);
rh.addParameters(action);
rebaseConflictDetector.reset();
rh.addLineListener(rebaseConflictDetector);
- if(!"--abort".equals(action)) {
+ if (!"--abort".equals(action)) {
configureRebaseEditor(root, rh);
}
try {
- GitHandlerUtil.doSynchronouslyWithExceptions(rh, progressIndicator);
- } finally {
+ GitHandlerUtil.doSynchronouslyWithExceptions(rh, progressIndicator);
+ }
+ finally {
cleanupHandler(root, rh);
}
}
/**
* Configure rebase editor
+ *
* @param root the vcs root
- * @param h the handler to configure
+ * @param h the handler to configure
*/
@SuppressWarnings({"UnusedDeclaration"})
protected void configureRebaseEditor(VirtualFile root, GitLineHandler h) {
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vfs.VirtualFile;
import git4idea.GitVcs;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import git4idea.config.GitVersion;
import org.jetbrains.annotations.NotNull;
* @return true if the stash was created, false otherwise
*/
public static boolean saveStash(@NotNull Project project, @NotNull VirtualFile root, final String message) throws VcsException {
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.STASH);
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.STASH);
handler.setNoSSH(true);
handler.addParameters("save", message);
String output = handler.run();
* @param root the root
*/
public static void popLastStash(@NotNull Project project, @NotNull VirtualFile root) throws VcsException {
- GitSimpleHandler handler = new GitSimpleHandler(project, root, GitHandler.STASH);
+ GitSimpleHandler handler = new GitSimpleHandler(project, root, GitCommand.STASH);
handler.setNoSSH(true);
handler.addParameters("pop");
- if(QUIET_STASH_SUPPORTED.isLessOrEqual(GitVcs.getInstance(project).version())) {
+ if (QUIET_STASH_SUPPORTED.isLessOrEqual(GitVcs.getInstance(project).version())) {
handler.addParameters("--quiet");
}
handler.run();
import com.intellij.util.ui.UIUtil;
import com.intellij.vcsUtil.VcsUtil;
import git4idea.GitUtil;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitSimpleHandler;
import git4idea.commands.StringScanner;
import git4idea.i18n.GitBundle;
/**
* The constructor
- * @param project the current project
- * @param root the vcs root
+ *
+ * @param project the current project
+ * @param root the vcs root
* @param locallyModifiedFiles the collection of locally modified files to use
*/
protected GitUpdateLocallyModifiedDialog(final Project project, final VirtualFile root, List<String> locallyModifiedFiles) {
}
}
});
- myDescriptionLabel.setText(GitBundle.message("update.locally.modified.message", ApplicationNamesInfo.getInstance().getFullProductName()));
+ myDescriptionLabel
+ .setText(GitBundle.message("update.locally.modified.message", ApplicationNamesInfo.getInstance().getFullProductName()));
init();
}
private void syncListModel() {
DefaultListModel listModel = (DefaultListModel)myFilesList.getModel();
listModel.removeAllElements();
- for(String p : myLocallyModifiedFiles) {
+ for (String p : myLocallyModifiedFiles) {
listModel.addElement(p);
}
}
* Scan working tree and detect locally modified files
*
* @param project the project to scan
- * @param root the root to scan
- * @param files the collection with files
+ * @param root the root to scan
+ * @param files the collection with files
* @throws VcsException if there problem with running git or working tree is dirty in unsupported way
*/
private static void scanFiles(Project project, VirtualFile root, List<String> files) throws VcsException {
String rootPath = root.getPath();
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.DIFF);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.DIFF);
h.addParameters("--name-status");
h.setNoSSH(true);
h.setStdoutSuppressed(true);
StringScanner s = new StringScanner(h.run());
- while(s.hasMoreData()) {
- if(s.isEol()) {
+ while (s.hasMoreData()) {
+ if (s.isEol()) {
s.line();
continue;
}
- if(s.tryConsume("M\t")) {
+ if (s.tryConsume("M\t")) {
String path = rootPath + "/" + GitUtil.unescapePath(s.line());
files.add(path);
- } else {
- throw new VcsException("Working tree is dirty in unsupported way: "+s.line());
+ }
+ else {
+ throw new VcsException("Working tree is dirty in unsupported way: " + s.line());
}
}
}
* Show the dialog if needed
*
* @param project the project
- * @param root the vcs root
+ * @param root the vcs root
* @return true if showing is not needed or operation completed successfully
*/
public static boolean showIfNeeded(final Project project, final VirtualFile root) {
try {
scanFiles(project, root, files);
final AtomicBoolean rc = new AtomicBoolean(true);
- if(!files.isEmpty()) {
+ if (!files.isEmpty()) {
UIUtil.invokeAndWaitIfNeeded(new Runnable() {
public void run() {
GitUpdateLocallyModifiedDialog d = new GitUpdateLocallyModifiedDialog(project, root, files);
rc.set(d.isOK());
}
});
- if(rc.get()) {
- if(!files.isEmpty()) {
+ if (rc.get()) {
+ if (!files.isEmpty()) {
revertFiles(project, root, files);
}
}
* Revert files from the list
*
* @param project the project
- * @param root the vcs root
- * @param files the files to revert
+ * @param root the vcs root
+ * @param files the files to revert
*/
private static void revertFiles(Project project, VirtualFile root, ArrayList<String> files) throws VcsException {
- GitSimpleHandler h = new GitSimpleHandler(project, root, GitHandler.CHECKOUT);
+ GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.CHECKOUT);
h.endOptions();
h.setNoSSH(true);
- for(String p : files) {
+ for (String p : files) {
h.addRelativePaths(VcsUtil.getFilePath(p));
}
h.run();
import com.intellij.openapi.vfs.VirtualFile;
import git4idea.GitRevisionNumber;
import git4idea.GitVcs;
-import git4idea.commands.GitHandler;
+import git4idea.commands.GitCommand;
import git4idea.commands.GitLineHandler;
import git4idea.config.GitVcsSettings;
import git4idea.merge.MergeChangeCollector;
@Override
protected GitLineHandler makeStartHandler(VirtualFile root) {
// do pull
- GitLineHandler h = new GitLineHandler(myProject, root, GitHandler.PULL);
+ GitLineHandler h = new GitLineHandler(myProject, root, GitCommand.PULL);
// ignore merge failure for the pull
h.ignoreErrorCode(1);
switch (mySettings.UPDATE_TYPE) {