Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2014-06-05 15:31:14 +0000
committerMatthias Sohn2014-07-08 23:40:03 +0000
commit32c24955597ab4c41c34672cc3db05fb9bfeefb6 (patch)
tree48006f1a8c7bd5177af4e9ea200cf7872e68dbf8 /org.eclipse.egit.ui/src/org
parent1c852c25df52476b73aa6f6da7330f0cbf8e7753 (diff)
downloadegit-32c24955597ab4c41c34672cc3db05fb9bfeefb6.tar.gz
egit-32c24955597ab4c41c34672cc3db05fb9bfeefb6.tar.xz
egit-32c24955597ab4c41c34672cc3db05fb9bfeefb6.zip
Improve simple push dialog
This dialog now shows which commit, from which branch is about to be pushed. It fits both use cases of pushing HEAD from resource, or pushing a single branch. Bug: 436669 Change-Id: Ibd8d75d6cece181657210fba73c9f2be90ea077b Signed-off-by: Mickael Istria <mistria@redhat.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.egit.ui/src/org')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java36
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushBranchActionHandler.java24
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushMenu.java125
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushUpstreamOrBranchActionHandler.java2
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/SimplePushSpecPage.java198
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/PushCommitHandler.java22
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchPage.java232
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchWizard.java54
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/SimplePushRefWizard.java169
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushCommand.java7
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties22
12 files changed, 413 insertions, 481 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
index b82fcd2d7f..1ec1f988f6 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/UIText.java
@@ -10,6 +10,7 @@
* Copyright (C) 2012, Gunnar Wagenknecht <gunnar@wagenknecht.org>
* Copyright (C) 2013, Ben Hammen <hammenb@gmail.com>
* Copyright (C) 2014, Marc Khouzam <marc.khouzam@ericsson.com>
+ * Copyright (C) 2014, Red Hat Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -1976,7 +1977,22 @@ public class UIText extends NLS {
public static String PushAction_wrongURITitle;
/** */
- public static String PushBranchPage_BranchNameLabel;
+ public static String PushBranchPage_CommitLabel;
+
+ /** */
+ public static String PushBranchPage_RemoteBranchNameLabel;
+
+ /** */
+ public static String PushBranchPage_CannotAccessCommitDescription;
+
+ /** */
+ public static String PushBranchPage_LocalBranchLabel;
+
+ /** */
+ public static String PushBranchPage_Source;
+
+ /** */
+ public static String PushBranchPage_Destination;
/** */
public static String PushBranchPage_ChooseBranchNameError;
@@ -4584,18 +4600,6 @@ public class UIText extends NLS {
public static String SimplePushActionHandler_NothingToPushDialogTitle;
/** */
- public static String SimplePushSpecPage_message;
-
- /** */
- public static String SimplePushSpecPage_pushAheadInfo;
-
- /** */
- public static String SimplePushSpecPage_TargetRefName;
-
- /** */
- public static String SimplePushSpecPage_title;
-
- /** */
public static String SkipRebaseCommand_CancelDialogMessage;
/** */
@@ -5159,6 +5163,12 @@ public class UIText extends NLS {
/** */
public static String BranchEditDialog_Title;
+ /** */
+ public static String PushMenu_PushHEAD;
+
+ /** */
+ public static String PushMenu_PushBranch;
+
static {
initializeMessages(BUNDLE_NAME, UIText.class);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java
index d825f4133d..b96c2ebaa4 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/ActionCommands.java
@@ -92,6 +92,9 @@ public class ActionCommands {
/** "Push" action command id */
public static final String PUSH_ACTION = "org.eclipse.egit.ui.team.Push"; //$NON-NLS-1$
+ /** "Push branch" action command id */
+ public static final String PUSH_BRANCH_ACTION = "org.eclipse.egit.ui.team.PushBranch"; //$NON-NLS-1$
+
/** "Rename Branch" action command id */
public static final String RENAME_BRANCH_ACTION = "org.eclipse.egit.ui.team.RenameBranch"; //$NON-NLS-1$
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushBranchActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushBranchActionHandler.java
index ecfa6bcf99..ac580013b8 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushBranchActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushBranchActionHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Robin Stocker <robin@nibor.org> and others.
+ * Copyright (c) 2013, 2014 Robin Stocker <robin@nibor.org> and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,9 +11,11 @@ import java.io.IOException;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.internal.push.PushBranchWizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
@@ -24,11 +26,19 @@ public class PushBranchActionHandler extends RepositoryActionHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
Repository repository = getRepository(true, event);
- Ref branchRef = getBranchRef(repository);
- if (branchRef != null) {
- PushBranchWizard wizard = new PushBranchWizard(repository, branchRef);
+ try {
+ PushBranchWizard wizard = null;
+ Ref ref = getBranchRef(repository);
+ if (ref != null) {
+ wizard = new PushBranchWizard(repository, ref);
+ } else {
+ ObjectId id = repository.resolve(repository.getFullBranch());
+ wizard = new PushBranchWizard(repository, id);
+ }
WizardDialog dlg = new WizardDialog(getShell(event), wizard);
dlg.open();
+ } catch (IOException ex) {
+ Activator.handleError(ex.getLocalizedMessage(), ex, false);
}
return null;
@@ -37,9 +47,7 @@ public class PushBranchActionHandler extends RepositoryActionHandler {
@Override
public boolean isEnabled() {
Repository repository = getRepository();
- if (repository == null)
- return false;
- return getBranchRef(repository) != null;
+ return repository != null;
}
private Ref getBranchRef(Repository repository) {
@@ -48,7 +56,7 @@ public class PushBranchActionHandler extends RepositoryActionHandler {
if (fullBranch != null && fullBranch.startsWith(Constants.R_HEADS))
return repository.getRef(fullBranch);
} catch (IOException e) {
- // We'll return null then, see below
+ Activator.handleError(e.getLocalizedMessage(), e, false);
}
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushMenu.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushMenu.java
new file mode 100644
index 0000000000..bcf2784969
--- /dev/null
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushMenu.java
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (C) 2014, Red Hat Inc.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * - Mickael Istria (Red Hat Inc.) - 436669 Simply push workflow
+ *******************************************************************************/
+package org.eclipse.egit.ui.internal.actions;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.egit.core.project.RepositoryMapping;
+import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.egit.ui.internal.repository.tree.BranchesNode;
+import org.eclipse.egit.ui.internal.repository.tree.LocalNode;
+import org.eclipse.egit.ui.internal.repository.tree.RepositoryNode;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.actions.CompoundContributionItem;
+import org.eclipse.ui.menus.CommandContributionItem;
+import org.eclipse.ui.menus.CommandContributionItemParameter;
+import org.eclipse.ui.menus.IWorkbenchContribution;
+import org.eclipse.ui.services.IServiceLocator;
+
+/**
+ * This is the definition of the Push menu on a given node. Depending on the
+ * node, it will show either "Push Branch '...'" or "Push HEAD".
+ */
+public class PushMenu extends CompoundContributionItem implements
+ IWorkbenchContribution {
+
+ private IServiceLocator serviceLocator;
+
+ private ISelectionService selectionService;
+
+ /** */
+ public PushMenu() {
+ this(null);
+ }
+
+ /**
+ * @param id
+ */
+ public PushMenu(String id) {
+ super(id);
+ }
+
+ @Override
+ public boolean isDynamic() {
+ return true;
+ }
+
+ public void initialize(IServiceLocator serviceLocator) {
+ this.serviceLocator = serviceLocator;
+ this.selectionService = (ISelectionService) serviceLocator
+ .getService(ISelectionService.class);
+ }
+
+ @Override
+ protected IContributionItem[] getContributionItems() {
+ List<IContributionItem> res = new ArrayList<IContributionItem>();
+
+ if (this.selectionService != null
+ && this.selectionService.getSelection() instanceof IStructuredSelection) {
+ IStructuredSelection sel = (IStructuredSelection) this.selectionService
+ .getSelection();
+ Object selected = sel.getFirstElement();
+ if (selected instanceof IAdaptable) {
+ Object adapter = ((IAdaptable) selected)
+ .getAdapter(IProject.class);
+ if (adapter != null)
+ selected = adapter;
+ }
+
+ Repository repository = null;
+ if (selected instanceof RepositoryNode)
+ repository = ((RepositoryNode) selected).getRepository();
+ else if (selected instanceof BranchesNode)
+ repository = ((BranchesNode) selected).getRepository();
+ else if (selected instanceof LocalNode)
+ repository = ((LocalNode) selected).getRepository();
+ else if ((selected instanceof IProject)) {
+ RepositoryMapping mapping = RepositoryMapping
+ .getMapping((IProject) selected);
+ if (mapping != null)
+ repository = mapping.getRepository();
+ }
+
+ if (repository != null) {
+ try {
+ String ref = repository.getFullBranch();
+ String menuLabel = UIText.PushMenu_PushHEAD;
+ if (ref.startsWith(Constants.R_HEADS)) {
+ menuLabel = NLS.bind(UIText.PushMenu_PushBranch,
+ Repository.shortenRefName(ref));
+ }
+ CommandContributionItemParameter params = new CommandContributionItemParameter(
+ this.serviceLocator, getClass().getName(),
+ ActionCommands.PUSH_BRANCH_ACTION,
+ CommandContributionItem.STYLE_PUSH);
+ params.label = menuLabel;
+ CommandContributionItem item = new CommandContributionItem(
+ params);
+ res.add(item);
+ } catch (IOException ex) {
+ Activator.handleError(ex.getLocalizedMessage(), ex, false);
+ }
+ }
+ }
+ return res.toArray(new IContributionItem[res.size()]);
+ }
+}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushUpstreamOrBranchActionHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushUpstreamOrBranchActionHandler.java
index 6f278f4edf..96979d9b2a 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushUpstreamOrBranchActionHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/PushUpstreamOrBranchActionHandler.java
@@ -53,7 +53,7 @@ public class PushUpstreamOrBranchActionHandler extends RepositoryActionHandler {
Ref head = getHeadIfSymbolic(repository);
if (head != null) {
PushBranchWizard pushBranchWizard = new PushBranchWizard(
- repository, head.getTarget());
+ repository, head);
WizardDialog dlg = new WizardDialog(shell,
pushBranchWizard);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/SimplePushSpecPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/SimplePushSpecPage.java
deleted file mode 100644
index af4f9c7611..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/components/SimplePushSpecPage.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2012 Markus Duft <markus.duft@salomon.at> and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-package org.eclipse.egit.ui.internal.components;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.egit.ui.UIUtils;
-import org.eclipse.egit.ui.UIUtils.IRefListProvider;
-import org.eclipse.egit.ui.internal.UIText;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.jgit.lib.BranchTrackingStatus;
-import org.eclipse.jgit.lib.Constants;
-import org.eclipse.jgit.lib.Ref;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * A page that allows to select a target branch for a push operation.
- */
-public class SimplePushSpecPage extends WizardPage {
-
- private boolean forceUpdate;
-
- private Text remoteRefName;
-
- private String sourceName;
-
- private Repository repository;
-
- /**
- * the content assist provider for the {@link Ref}s
- */
- protected RefContentAssistProvider assist;
-
- /**
- * Creates a new wizard page that allows selection of the target
- *
- * @param niceSourceName
- * the nice displayable name of the source to be pushed.
- * @param repo
- * source repository
- */
- public SimplePushSpecPage(String niceSourceName, Repository repo) {
- super(UIText.SimplePushSpecPage_title);
- setTitle(UIText.SimplePushSpecPage_title);
- setMessage(NLS.bind(UIText.SimplePushSpecPage_message, niceSourceName));
-
- this.sourceName = niceSourceName;
- this.repository = repo;
- }
-
- public void createControl(Composite parent) {
- Composite main = new Composite(parent, SWT.NONE);
- GridDataFactory.fillDefaults().grab(true, true).applyTo(main);
- main.setLayout(new GridLayout(1, false));
-
- Composite inputPanel = new Composite(main, SWT.NONE);
- GridDataFactory.fillDefaults().grab(true, false).applyTo(inputPanel);
- GridLayout layout = new GridLayout(2, false);
- layout.marginWidth= 0;
- layout.marginHeight= 0;
- inputPanel.setLayout(layout);
-
- final Label lblRemote = new Label(inputPanel, SWT.NONE);
- lblRemote.setText(UIText.SimplePushSpecPage_TargetRefName);
- remoteRefName = new Text(inputPanel, SWT.BORDER);
- GridDataFactory.fillDefaults().grab(true, false).applyTo(remoteRefName);
- remoteRefName.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- setPageComplete(isPageComplete());
- }
- });
-
- UIUtils.addRefContentProposalToText(remoteRefName, repository,
- new IRefListProvider() {
- public List<Ref> getRefList() {
- if (assist != null)
- return assist.getRefsForContentAssist(false, true);
-
- return Collections.emptyList();
- }
- });
-
- final Button forceButton = new Button(main, SWT.CHECK);
- forceButton.setText(UIText.RefSpecDialog_ForceUpdateCheckbox);
- GridDataFactory.fillDefaults().grab(true, false).applyTo(forceButton);
-
- forceButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- forceUpdate = forceButton.getSelection();
- }
- });
-
- setControl(main);
- }
-
- /*
- * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
- * @since 2.0
- */
- @Override
- public void setVisible(boolean visible) {
- super.setVisible(visible);
- if (visible)
- remoteRefName.setFocus();
- }
-
- /**
- * pre-fills the destination box with a remote ref name if one exists that
- * matches the local branch name.
- */
- protected void updateDestinationField() {
- setMessage(NLS.bind(UIText.SimplePushSpecPage_message, sourceName));
- String checkRemote = sourceName;
-
- if (sourceName.startsWith(Constants.R_HEADS)) {
- try {
- BranchTrackingStatus status = BranchTrackingStatus.of(
- repository,
- sourceName.substring(Constants.R_HEADS.length()));
-
- if (status != null) {
- // calculate the name of the branch on the other side.
- checkRemote = status.getRemoteTrackingBranch();
- checkRemote = Constants.R_HEADS
- + checkRemote.substring(checkRemote.indexOf('/',
- Constants.R_REMOTES.length() + 1) + 1);
-
- setMessage(NLS.bind(
- UIText.SimplePushSpecPage_pushAheadInfo,
- new Object[] { sourceName,
- Integer.valueOf(status.getAheadCount()),
- status.getRemoteTrackingBranch() }),
- IStatus.INFO);
- }
- } catch (Exception e) {
- // ignore and continue...
- }
-
- if (assist == null) {
- if (checkRemote != null)
- remoteRefName.setText(checkRemote);
- return;
- }
-
- if (checkRemote == null)
- checkRemote = sourceName;
-
- for (Ref ref : assist.getRefsForContentAssist(false, true))
- if (ref.getName().equals(checkRemote))
- remoteRefName.setText(checkRemote);
- }
- }
-
- @Override
- public boolean isPageComplete() {
- return remoteRefName.getText().length() > 0;
- }
-
- /**
- * Whether the user wants to force pushing.
- *
- * @return whether to force the push
- */
- public boolean isForceUpdate() {
- return forceUpdate;
- }
-
- /**
- * Retrieves the target name to push to.
- *
- * @return the target name.
- */
- public String getTargetRef() {
- return remoteRefName.getText();
- }
-
-}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/PushCommitHandler.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/PushCommitHandler.java
index 154b72fca6..d507b63438 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/PushCommitHandler.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/history/command/PushCommitHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (C) 2012, Markus Duft <markus.duft@salomon.at>
+ * Copyright (C) 2012-2014, Markus Duft <markus.duft@salomon.at> and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -11,11 +11,12 @@ package org.eclipse.egit.ui.internal.history.command;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.history.GitHistoryPage;
-import org.eclipse.egit.ui.internal.push.SimplePushRefWizard;
+import org.eclipse.egit.ui.internal.push.PushBranchWizard;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revplot.PlotCommit;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -30,10 +31,21 @@ public class PushCommitHandler extends AbstractHistoryCommandHandler {
final Repository repo = getRepository(event);
try {
+ PushBranchWizard wizard = null;
+ Ref localBranch = null;
+ for (int i = 0; i < commit.getRefCount(); i++) {
+ Ref currentRef = commit.getRef(i);
+ if (localBranch == null
+ && currentRef.getName().startsWith(Constants.R_HEADS))
+ localBranch = currentRef;
+ }
+ if (localBranch == null)
+ wizard = new PushBranchWizard(repo, commit.getId());
+ else
+ wizard = new PushBranchWizard(repo, localBranch);
WizardDialog dlg = new WizardDialog(
HandlerUtil.getActiveShellChecked(event),
- new SimplePushRefWizard(repo, commit.getId(),
- UIText.PushCommitHandler_pushCommitTitle));
+ wizard);
dlg.setHelpAvailable(true);
dlg.open();
} catch (Exception e) {
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchPage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchPage.java
index df5c5fa631..807678307d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchPage.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchPage.java
@@ -7,13 +7,19 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.push;
+import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import org.eclipse.egit.core.internal.Utils;
import org.eclipse.egit.core.op.CreateLocalBranchOperation.UpstreamConfig;
import org.eclipse.egit.ui.Activator;
+import org.eclipse.egit.ui.UIUtils;
+import org.eclipse.egit.ui.internal.UIIcons;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.internal.components.RemoteSelectionCombo;
import org.eclipse.egit.ui.internal.components.RemoteSelectionCombo.IRemoteSelectionListener;
@@ -23,14 +29,18 @@ import org.eclipse.egit.ui.internal.components.UpstreamConfigComponent.UpstreamC
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.layout.RowLayoutFactory;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevWalk;
import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.URIish;
import org.eclipse.swt.SWT;
@@ -38,6 +48,10 @@ import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Resource;
+import org.eclipse.swt.layout.RowData;
+import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
@@ -49,8 +63,12 @@ import org.eclipse.swt.widgets.Text;
*/
public class PushBranchPage extends WizardPage {
+ private static final int MAX_SHORTCOMMIT_MESSAGE_LENGTH = 65;
+
private final Repository repository;
+ private final ObjectId commitToPush;
+
private final Ref ref;
private boolean showNewRemoteButton = true;
@@ -61,7 +79,7 @@ public class PushBranchPage extends WizardPage {
private RemoteSelectionCombo remoteSelectionCombo;
- private Text branchNameText;
+ private Text remoteBranchNameText;
private UpstreamConfig upstreamConfig = UpstreamConfig.NONE;
@@ -72,18 +90,23 @@ public class PushBranchPage extends WizardPage {
/** Only set if user selected "New Remote" */
private AddRemotePage addRemotePage;
+ private Set<Resource> disposables = new HashSet<Resource>();
+
/**
* Create the page.
*
* @param repository
+ * @param commitToPush
* @param ref
+ * An optional ref to give hints
*/
- public PushBranchPage(Repository repository, Ref ref) {
+ public PushBranchPage(Repository repository, ObjectId commitToPush, Ref ref) {
super(UIText.PushBranchPage_PageName);
setTitle(UIText.PushBranchPage_PageTitle);
setMessage(UIText.PushBranchPage_PageMessage);
this.repository = repository;
+ this.commitToPush = commitToPush;
this.ref = ref;
}
@@ -109,8 +132,8 @@ public class PushBranchPage extends WizardPage {
/**
* @return the chosen short name of the branch on the remote
*/
- String getBranchName() {
- return branchNameText.getText();
+ String getRemoteBranchName() {
+ return remoteBranchNameText.getText();
}
boolean isConfigureUpstreamSelected() {
@@ -138,17 +161,82 @@ public class PushBranchPage extends WizardPage {
Composite inputPanel = new Composite(main, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, false).applyTo(inputPanel);
- inputPanel.setLayout(GridLayoutFactory.fillDefaults().numColumns(3)
+ GridLayoutFactory.fillDefaults().numColumns(1).applyTo(inputPanel);
+
+ Label sourceLabel = new Label(inputPanel, SWT.NONE);
+ sourceLabel.setText(UIText.PushBranchPage_Source);
+
+ Composite sourceComposite = new Composite(inputPanel, SWT.NONE);
+ sourceComposite.setLayoutData(GridDataFactory.fillDefaults()
+ .indent(UIUtils.getControlIndent(), 0).create());
+ RowLayout rowLayout = RowLayoutFactory.fillDefaults().create();
+ rowLayout.center = true;
+ sourceComposite.setLayout(rowLayout);
+
+ if (this.ref != null) {
+ Image branchIcon = UIIcons.BRANCH.createImage();
+ this.disposables.add(branchIcon);
+
+ Label branchIconLabel = new Label(sourceComposite, SWT.NONE);
+ branchIconLabel
+ .setLayoutData(new RowData(branchIcon.getBounds().width,
+ branchIcon.getBounds().height));
+ branchIconLabel.setBackgroundImage(branchIcon);
+ Label localBranchLabel = new Label(sourceComposite, SWT.NONE);
+ localBranchLabel.setText(Repository.shortenRefName(this.ref
+ .getName()));
+
+ Label spacer = new Label(sourceComposite, SWT.NONE);
+ spacer.setLayoutData(new RowData(3, SWT.DEFAULT));
+ }
+
+ Image commitIcon = UIIcons.COMMIT.createImage();
+ this.disposables.add(commitIcon);
+ Label commitIconLabel = new Label(sourceComposite, SWT.NONE);
+ commitIconLabel.setBackgroundImage(commitIcon);
+ commitIconLabel.setLayoutData(new RowData(commitIcon.getBounds().width,
+ commitIcon.getBounds().height));
+
+ Label commit = new Label(sourceComposite, SWT.NONE);
+ RevWalk revWalk = new RevWalk(repository);
+ StringBuilder commitBuilder = new StringBuilder(this.commitToPush
+ .abbreviate(7).name());
+ StringBuilder commitTooltipBuilder = new StringBuilder(
+ this.commitToPush.getName());
+ try {
+ RevCommit revCommit = revWalk.parseCommit(this.commitToPush);
+ commitBuilder.append(" "); //$NON-NLS-1$
+ commitBuilder.append(Utils.shortenText(revCommit.getShortMessage(),
+ MAX_SHORTCOMMIT_MESSAGE_LENGTH));
+ commitTooltipBuilder.append("\n\n"); //$NON-NLS-1$
+ commitTooltipBuilder.append(revCommit.getFullMessage());
+ } catch (IOException ex) {
+ commitBuilder
+ .append(UIText.PushBranchPage_CannotAccessCommitDescription);
+ commitTooltipBuilder.append(ex.getMessage());
+ Activator.handleError(ex.getLocalizedMessage(), ex, false);
+ }
+ commit.setText(commitBuilder.toString());
+ commit.setToolTipText(commitTooltipBuilder.toString());
+
+ Label destinationLabel = new Label(inputPanel, SWT.NONE);
+ destinationLabel.setText(UIText.PushBranchPage_Destination);
+ GridDataFactory.fillDefaults().applyTo(destinationLabel);
+
+ Composite remoteGroup = new Composite(inputPanel, SWT.NONE);
+ remoteGroup.setLayoutData(GridDataFactory.fillDefaults()
+ .indent(UIUtils.getControlIndent(), 0).create());
+ remoteGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(3)
.create());
- Label remoteLabel = new Label(inputPanel, SWT.NONE);
+ Label remoteLabel = new Label(remoteGroup, SWT.NONE);
remoteLabel.setText(UIText.PushBranchPage_RemoteLabel);
// Use full width in case "New Remote..." button is not shown
int remoteSelectionSpan = showNewRemoteButton ? 1 : 2;
- remoteSelectionCombo = new RemoteSelectionCombo(
- inputPanel, SWT.NONE, SelectionType.PUSH);
+ remoteSelectionCombo = new RemoteSelectionCombo(remoteGroup, SWT.NONE,
+ SelectionType.PUSH);
GridDataFactory.fillDefaults().grab(true, false).span(remoteSelectionSpan, 1)
.applyTo(remoteSelectionCombo);
setRemoteConfigs();
@@ -161,7 +249,7 @@ public class PushBranchPage extends WizardPage {
});
if (showNewRemoteButton) {
- Button newRemoteButton = new Button(inputPanel, SWT.PUSH);
+ Button newRemoteButton = new Button(remoteGroup, SWT.PUSH);
newRemoteButton.setText(UIText.PushBranchPage_NewRemoteButton);
GridDataFactory.fillDefaults().applyTo(newRemoteButton);
newRemoteButton.addSelectionListener(new SelectionAdapter() {
@@ -172,27 +260,30 @@ public class PushBranchPage extends WizardPage {
});
}
- Label branchNameLabel = new Label(inputPanel, SWT.NONE);
- branchNameLabel.setText(UIText.PushBranchPage_BranchNameLabel);
+ Label branchNameLabel = new Label(remoteGroup, SWT.NONE);
+ branchNameLabel.setText(UIText.PushBranchPage_RemoteBranchNameLabel);
- branchNameText = new Text(inputPanel, SWT.BORDER);
+ remoteBranchNameText = new Text(remoteGroup, SWT.BORDER);
GridDataFactory.fillDefaults().grab(true, false).span(2, 1)
- .applyTo(branchNameText);
- branchNameText.setText(getSuggestedBranchName());
-
- upstreamConfigComponent = new UpstreamConfigComponent(inputPanel,
- SWT.NONE);
- upstreamConfigComponent.getContainer().setLayoutData(
- GridDataFactory.fillDefaults().grab(true, false).span(3, 1)
- .create());
- upstreamConfigComponent
- .addUpstreamConfigSelectionListener(new UpstreamConfigSelectionListener() {
- public void upstreamConfigSelected(
- UpstreamConfig newUpstreamConfig) {
- upstreamConfig = newUpstreamConfig;
- checkPage();
- }
- });
+ .applyTo(remoteBranchNameText);
+ remoteBranchNameText.setText(getSuggestedBranchName());
+
+ if (this.ref != null) {
+ upstreamConfigComponent = new UpstreamConfigComponent(inputPanel,
+ SWT.NONE);
+ upstreamConfigComponent.getContainer().setLayoutData(
+ GridDataFactory.fillDefaults().grab(true, false).span(3, 1)
+ .indent(SWT.DEFAULT, 20).create());
+ upstreamConfigComponent
+ .addUpstreamConfigSelectionListener(new UpstreamConfigSelectionListener() {
+ public void upstreamConfigSelected(
+ UpstreamConfig newUpstreamConfig) {
+ upstreamConfig = newUpstreamConfig;
+ checkPage();
+ }
+ });
+ setDefaultUpstreamConfig();
+ }
final Button forceUpdateButton = new Button(inputPanel, SWT.CHECK);
forceUpdateButton.setText(UIText.PushBranchPage_ForceUpdateButton);
@@ -205,14 +296,14 @@ public class PushBranchPage extends WizardPage {
}
});
- setDefaultUpstreamConfig();
+
setControl(main);
checkPage();
// Add listener now to avoid setText above to already trigger it.
- branchNameText.addModifyListener(new ModifyListener() {
+ remoteBranchNameText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
checkPage();
}
@@ -221,15 +312,16 @@ public class PushBranchPage extends WizardPage {
private void setRemoteConfigs() {
remoteSelectionCombo.setItems(remoteConfigs);
-
- String branchName = Repository.shortenRefName(ref.getName());
- String remoteName = repository.getConfig().getString(
- ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
- ConfigConstants.CONFIG_KEY_REMOTE);
- if (remoteName != null) {
- for (RemoteConfig rc : remoteConfigs) {
- if (remoteName.equals(rc.getName()))
- remoteSelectionCombo.setSelectedRemote(rc);
+ if (this.ref != null) {
+ String branchName = Repository.shortenRefName(this.ref.getName());
+ String remoteName = repository.getConfig().getString(
+ ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
+ ConfigConstants.CONFIG_KEY_REMOTE);
+ if (remoteName != null) {
+ for (RemoteConfig rc : remoteConfigs) {
+ if (remoteName.equals(rc.getName()))
+ remoteSelectionCombo.setSelectedRemote(rc);
+ }
}
}
@@ -237,22 +329,24 @@ public class PushBranchPage extends WizardPage {
}
private void setDefaultUpstreamConfig() {
- String branchName = Repository.shortenRefName(ref.getName());
- boolean alreadyConfigured = repository.getConfig()
- .getSubsections(ConfigConstants.CONFIG_BRANCH_SECTION)
- .contains(branchName);
- UpstreamConfig config;
- if (alreadyConfigured) {
- boolean rebase = repository.getConfig().getBoolean(
- ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
- ConfigConstants.CONFIG_KEY_REBASE, false);
- config = rebase ? UpstreamConfig.REBASE : UpstreamConfig.MERGE;
- } else {
- config = UpstreamConfig.getDefault(repository, Constants.R_REMOTES
- + Constants.DEFAULT_REMOTE_NAME + "/" + branchName); //$NON-NLS-1$
+ if (this.ref != null) {
+ String branchName = Repository.shortenRefName(ref.getName());
+ boolean alreadyConfigured = repository.getConfig()
+ .getSubsections(ConfigConstants.CONFIG_BRANCH_SECTION)
+ .contains(branchName);
+ UpstreamConfig config;
+ if (alreadyConfigured) {
+ boolean rebase = repository.getConfig().getBoolean(
+ ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
+ ConfigConstants.CONFIG_KEY_REBASE, false);
+ config = rebase ? UpstreamConfig.REBASE : UpstreamConfig.MERGE;
+ } else {
+ config = UpstreamConfig.getDefault(repository, Constants.R_REMOTES
+ + Constants.DEFAULT_REMOTE_NAME + "/" + branchName); //$NON-NLS-1$
+ }
+ this.upstreamConfig = config;
+ this.upstreamConfigComponent.setUpstreamConfig(this.upstreamConfig);
}
- upstreamConfigComponent.setUpstreamConfig(config);
- upstreamConfig = config;
}
private void showNewRemoteDialog() {
@@ -273,7 +367,7 @@ public class PushBranchPage extends WizardPage {
setErrorMessage(UIText.PushBranchPage_ChooseRemoteError);
return;
}
- String branchName = branchNameText.getText();
+ String branchName = remoteBranchNameText.getText();
if (branchName.length() == 0) {
setErrorMessage(UIText.PushBranchPage_ChooseBranchNameError);
return;
@@ -311,15 +405,20 @@ public class PushBranchPage extends WizardPage {
}
private String getSuggestedBranchName() {
- StoredConfig config = repository.getConfig();
- String branchName = Repository.shortenRefName(ref.getName());
+ if (ref != null) {
+ StoredConfig config = repository.getConfig();
+ String branchName = Repository.shortenRefName(ref.getName());
- String merge = config.getString(ConfigConstants.CONFIG_BRANCH_SECTION,
- branchName, ConfigConstants.CONFIG_KEY_MERGE);
- if (merge != null && merge.startsWith(Constants.R_HEADS))
- return Repository.shortenRefName(merge);
+ String merge = config.getString(
+ ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
+ ConfigConstants.CONFIG_KEY_MERGE);
+ if (merge != null && merge.startsWith(Constants.R_HEADS))
+ return Repository.shortenRefName(merge);
- return branchName;
+ return branchName;
+ } else {
+ return ""; //$NON-NLS-1$
+ }
}
private boolean hasDifferentUpstreamConfiguration() {
@@ -336,7 +435,7 @@ public class PushBranchPage extends WizardPage {
String merge = config.getString(ConfigConstants.CONFIG_BRANCH_SECTION,
branchName, ConfigConstants.CONFIG_KEY_MERGE);
- if (merge == null || !merge.equals(Constants.R_HEADS + getBranchName()))
+ if (merge == null || !merge.equals(Constants.R_HEADS + getRemoteBranchName()))
return true;
boolean rebase = config.getBoolean(
@@ -352,4 +451,11 @@ public class PushBranchPage extends WizardPage {
Activator.handleError(e.getMessage(), e, false);
setErrorMessage(e.getMessage());
}
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ for (Resource disposable : this.disposables)
+ disposable.dispose();
+ }
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchWizard.java
index dee4ffb852..1278e9c096 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchWizard.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushBranchWizard.java
@@ -23,6 +23,7 @@ import org.eclipse.egit.ui.internal.credentials.EGitCredentialsProvider;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jgit.lib.ConfigConstants;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
@@ -31,12 +32,18 @@ import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.URIish;
/**
- * A wizard dedicated to pushing a branch for the first time.
+ * A wizard dedicated to pushing a commit.
*/
public class PushBranchWizard extends Wizard {
private final Repository repository;
- private final Ref refToPush;
+
+ private final ObjectId commitToPush;
+
+ /**
+ * In case of detached HEAD, reference is null.
+ */
+ private final Ref ref;
private AddRemotePage addRemotePage;
private PushBranchPage pushBranchPage;
@@ -46,17 +53,33 @@ public class PushBranchWizard extends Wizard {
/**
* @param repository
* the repository the ref belongs to
- * @param refToPush
+ * @param ref
*/
- public PushBranchWizard(final Repository repository, Ref refToPush) {
+ public PushBranchWizard(final Repository repository, Ref ref) {
+ this(repository, ref.getObjectId(), ref);
+ }
+
+ /**
+ * @param repository
+ * the repository commit belongs to
+ * @param commitToPush
+ */
+ public PushBranchWizard(final Repository repository, ObjectId commitToPush) {
+ this(repository, commitToPush, null);
+ }
+
+ private PushBranchWizard(final Repository repository, ObjectId commitToPush, Ref ref) {
this.repository = repository;
- this.refToPush = refToPush;
+ this.commitToPush = commitToPush;
+ this.ref = ref;
+ assert (this.repository != null);
+ assert (this.commitToPush != null);
Set<String> remoteNames = repository.getConfig().getSubsections(ConfigConstants.CONFIG_REMOTE_SECTION);
if (remoteNames.isEmpty())
addRemotePage = new AddRemotePage(repository);
- pushBranchPage = new PushBranchPage(repository, refToPush) {
+ pushBranchPage = new PushBranchPage(repository, commitToPush, ref) {
@Override
public void setVisible(boolean visible) {
if (visible && addRemotePage != null) {
@@ -91,8 +114,11 @@ public class PushBranchWizard extends Wizard {
@Override
public String getWindowTitle() {
- return MessageFormat.format(UIText.PushBranchWizard_WindowTitle,
- Repository.shortenRefName(refToPush.getName()));
+ if (ref != null)
+ return MessageFormat.format(UIText.PushBranchWizard_WindowTitle,
+ Repository.shortenRefName(this.ref.getName()));
+ else
+ return UIText.PushCommitHandler_pushCommitTitle;
}
@Override
@@ -140,8 +166,8 @@ public class PushBranchWizard extends Wizard {
}
private List<RefSpec> getRefSpecs() {
- String src = refToPush.getName();
- String dst = Constants.R_HEADS + pushBranchPage.getBranchName();
+ String src = this.ref != null ? this.ref.getName() : this.commitToPush.getName();
+ String dst = Constants.R_HEADS + pushBranchPage.getRemoteBranchName();
RefSpec refSpec = new RefSpec().setSourceDestination(src, dst)
.setForceUpdate(pushBranchPage.isForceUpdateSelected());
return Arrays.asList(refSpec);
@@ -171,9 +197,13 @@ public class PushBranchWizard extends Wizard {
}
private void configureUpstream() throws IOException {
+ if (this.ref == null) {
+ // Don't configure upstream for detached HEAD
+ return;
+ }
String remoteName = getRemoteName();
- String remoteBranchName = pushBranchPage.getBranchName();
- String branchName = Repository.shortenRefName(refToPush.getName());
+ String remoteBranchName = pushBranchPage.getRemoteBranchName();
+ String branchName = Repository.shortenRefName(this.ref.getName());
StoredConfig config = repository.getConfig();
config.setString(ConfigConstants.CONFIG_BRANCH_SECTION, branchName,
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/SimplePushRefWizard.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/SimplePushRefWizard.java
deleted file mode 100644
index 616a6fffa6..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/SimplePushRefWizard.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (C) 2011, 2012 Markus Duft <markus.duft@salomon.at> and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *******************************************************************************/
-
-package org.eclipse.egit.ui.internal.push;
-
-import java.net.URISyntaxException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.egit.core.op.PushOperation;
-import org.eclipse.egit.core.op.PushOperationSpecification;
-import org.eclipse.egit.ui.Activator;
-import org.eclipse.egit.ui.UIPreferences;
-import org.eclipse.egit.ui.internal.components.RefContentAssistProvider;
-import org.eclipse.egit.ui.internal.components.RepositorySelection;
-import org.eclipse.egit.ui.internal.components.RepositorySelectionPage;
-import org.eclipse.egit.ui.internal.components.SimplePushSpecPage;
-import org.eclipse.egit.ui.internal.push.PushWizard.PushJob;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jgit.lib.AbbreviatedObjectId;
-import org.eclipse.jgit.lib.ObjectId;
-import org.eclipse.jgit.lib.Ref;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.transport.RefSpec;
-import org.eclipse.jgit.transport.RemoteConfig;
-import org.eclipse.jgit.transport.RemoteRefUpdate;
-import org.eclipse.jgit.transport.Transport;
-
-/**
- * A simple push wizard, which only pushes out the selected ref/commit to the
- * selected repo.
- */
-public class SimplePushRefWizard extends Wizard {
-
- /**
- * The commit that will be pushed out.
- */
- private ObjectId pushObj;
-
- private RepositorySelectionPage repoPage;
-
- private String nicePushName;
-
- private Repository repo;
-
- private SimplePushSpecPage targetPage;
-
- /**
- * Creates a new simple push wizard for a ref
- *
- * @param repo
- * the repository the ref belongs to
- * @param refToPush
- * the ref to push
- * @param title
- * the wizard title
- * @throws URISyntaxException
- */
- public SimplePushRefWizard(Repository repo, Ref refToPush, String title)
- throws URISyntaxException {
- this(repo, refToPush.getObjectId(), refToPush.getName(), title);
- }
-
- /**
- * Creates a new simple push wizard which can be used to push out a certain
- * object.
- *
- * @param repo
- * the repository the object belongs to
- * @param objectId
- * the object that should be pushed.
- * @param title
- * the wizard title
- * @throws URISyntaxException
- */
- public SimplePushRefWizard(Repository repo, ObjectId objectId, String title)
- throws URISyntaxException {
- this(repo, objectId, AbbreviatedObjectId.fromObjectId(objectId).name(), title);
- }
-
- private SimplePushRefWizard(Repository repo, ObjectId objectId, String name, String title)
- throws URISyntaxException {
- final List<RemoteConfig> remotes = RemoteConfig
- .getAllRemoteConfigs(repo.getConfig());
-
- this.nicePushName = name;
- this.pushObj = objectId;
- this.repo = repo;
-
- repoPage = new RepositorySelectionPage(false, remotes, null);
- targetPage = new SimplePushSpecPage(nicePushName, repo) {
- @Override
- public void setVisible(boolean visible) {
- super.setVisible(visible);
-
- if (visible)
- try {
- if (assist != null
- && assist.getRepository().equals(
- SimplePushRefWizard.this.repo)
- && assist.getRemoteURI().equals(
- repoPage.getSelection().getURI(true)))
- return;
-
- assist = new RefContentAssistProvider(
- SimplePushRefWizard.this.repo, repoPage
- .getSelection().getURI(true), getShell());
-
- } finally {
- updateDestinationField();
- }
- }
- };
- setWindowTitle(title);
- }
-
- @Override
- public void addPages() {
- addPage(repoPage);
- addPage(targetPage);
- }
-
- @Override
- public boolean performFinish() {
- try {
- int timeout = Activator.getDefault().getPreferenceStore()
- .getInt(UIPreferences.REMOTE_CONNECTION_TIMEOUT);
-
- PushOperationSpecification specification = new PushOperationSpecification();
- RepositorySelection remote = repoPage.getSelection();
-
- RefSpec refSpec = new RefSpec().
- setSourceDestination(pushObj.name(), targetPage.getTargetRef()).
- setForceUpdate(targetPage.isForceUpdate());
-
- // Include fetchSpecs in calculation so that tracking refs are also updated
- RemoteConfig remoteConfig = remote.getConfig();
- List<RefSpec> fetchSpecs = remoteConfig != null ? remoteConfig.getFetchRefSpecs() : null;
-
- Collection<RemoteRefUpdate> remoteRefUpdates = Transport
- .findRemoteRefUpdatesFor(repo,
- Collections.singleton(refSpec), fetchSpecs);
-
- specification.addURIRefUpdates(remote.getURI(true), remoteRefUpdates);
-
- PushOperation pop = new PushOperation(repo, specification, false,
- timeout);
-
- PushJob job = new PushWizard.PushJob(repo, pop, null,
- PushWizard.getDestinationString(remote));
- job.setUser(true);
- job.schedule();
-
- repoPage.saveUriInPrefs();
- } catch (Exception e) {
- Activator.handleError(e.getMessage(), e, true);
- }
-
- return true;
- }
-
-}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushCommand.java
index 5a89f20511..a5a2f9898d 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushCommand.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PushCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2013 SAP AG and others.
+ * Copyright (c) 2010, 2014 SAP AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Mathias Kinzler (SAP AG) - initial implementation
+ * Mickael Istria (Red Hat Inc.)
*******************************************************************************/
package org.eclipse.egit.ui.internal.repository.tree.command;
@@ -41,8 +42,8 @@ public class PushCommand extends
try {
switch (node.getType()) {
case REF:
- pushWiz = new PushBranchWizard(node.getRepository(),
- (Ref) node.getObject());
+ Ref ref = (Ref) node.getObject();
+ pushWiz = new PushBranchWizard(node.getRepository(), ref);
break;
case TAG:
pushWiz = createPushTagsWizard(nodes);
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
index 8f99fd0333..c67e9d2b86 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/uitext.properties
@@ -15,6 +15,7 @@
# Gunnar Wagenknecht <gunnar@wagenknecht.org>
# Marc Khouzam <marc.khouzam@ericsson.com> - Added CompareTreeView Compare Mode tooltip
# Marc Khouzam <marc.khouzam@ericsson.com> - Add option not to checkout new branch from Gerrit
+# Mickael Istria (Red Hat Inc.) - 463339 Simple push wizard improvements
###############################################################################
AbortRebaseCommand_CancelDialogMessage=The abort operation was canceled
AbortRebaseCommand_JobName=Aborting Rebase
@@ -682,16 +683,20 @@ PullResultDialog_MergeAlreadyUpToDateMessage=Nothing to update - everything up t
PullResultDialog_MergeResultGroupHeader=Update Result
PushAction_wrongURIDescription=Remote repositories URIs configuration is corrupted.
PushAction_wrongURITitle=Corrupted Configuration
-PushBranchPage_BranchNameLabel=&Branch name:
-PushBranchPage_ChooseBranchNameError=Please choose a name for the new branch.
+PushBranchPage_CannotAccessCommitDescription=<<<Cannot access commit description. See log for details.>>>
+PushBranchPage_LocalBranchLabel=Branch:
+PushBranchPage_Source=Source:
+PushBranchPage_Destination=Destination:
+PushBranchPage_RemoteLabel=Remote:
PushBranchPage_ChooseRemoteError=Please choose or add a remote.
+PushBranchPage_RemoteBranchNameLabel=Branch:
+PushBranchPage_ChooseBranchNameError=Please choose a name for the new branch.
PushBranchPage_ForceUpdateButton=&Force overwrite of branch on remote if it exists and has diverged
PushBranchPage_InvalidBranchNameError=Invalid branch name.
PushBranchPage_NewRemoteButton=&New Remote...
PushBranchPage_PageMessage=Select a remote and the name the branch should have on the remote.
-PushBranchPage_PageName=Push Branch
-PushBranchPage_PageTitle=Push Branch to Remote
-PushBranchPage_RemoteLabel=R&emote:
+PushBranchPage_PageName=Simple Push
+PushBranchPage_PageTitle=Push to branch on remote
PushBranchPage_UpstreamConfigOverwriteWarning=The existing upstream configuration for the branch will be overwritten.
PushBranchWizard_WindowTitle=Push Branch {0}
PushCommand_pushBranchTitle=Push Branch
@@ -1656,10 +1661,6 @@ SimpleFetchActionHandler_NothingToFetchDialogTitle=Nothing to Fetch
SimpleFetchRefSpecWizard_WizardTitle=Adding a Refspec for Fetch
SimplePushActionHandler_NothingToPushDialogMessage=Cannot push anything: the currently checked-out branch is based on a local branch
SimplePushActionHandler_NothingToPushDialogTitle=Nothing to Push
-SimplePushSpecPage_message=Select target to push {0} to
-SimplePushSpecPage_pushAheadInfo={0} is {1} commits ahead of {2}
-SimplePushSpecPage_TargetRefName=Target Ref Name:
-SimplePushSpecPage_title=Select push destination
SquashHandler_CommitsNotOnCurrentBranch=The selected commits cannot be squashed because they are not on the currently checked-out branch.
SquashHandler_Error_Title=Error Squashing Commits
SquashHandler_ErrorCheckingIfCommitsAreOnCurrentBranch=Error checking if commits are on current branch
@@ -1811,3 +1812,6 @@ GitScmUrlImportWizardPage_counter=Total: {0}
BranchEditDialog_Title=Edit branches
CancelAfterSaveDialog_Title=Cancel Confirmation
+
+PushMenu_PushHEAD=Push &HEAD...
+PushMenu_PushBranch=Push &Branch ''{0}''...

Back to the top