From 1a116738994d60ecc6ffb56fdb4f134f2ffad12e Mon Sep 17 00:00:00 2001 From: Nadya Zabrodina Date: Thu, 27 Feb 2014 15:03:39 +0400 Subject: [PATCH] IDEA-109794 ability to push mercurial bookmark --- .../src/org/zmlx/hg4idea/HgPusher.java | 1 + .../zmlx/hg4idea/command/HgPushCommand.java | 13 ++- .../src/org/zmlx/hg4idea/ui/HgPushDialog.form | 109 +++++++++++------- .../src/org/zmlx/hg4idea/ui/HgPushDialog.java | 11 ++ 4 files changed, 89 insertions(+), 45 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java index da11f2330a13..17d4f364a154 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgPusher.java @@ -108,6 +108,7 @@ public class HgPusher { command.setRevision(dialog.getRevision()); command.setForce(dialog.isForce()); command.setBranchName(dialog.getBranch()); + command.setBookmarkName(dialog.getBookmarkName()); command.setIsNewBranch(dialog.isNewBranch()); return command; } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgPushCommand.java b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgPushCommand.java index 4a8791296991..16748462a45f 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgPushCommand.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/command/HgPushCommand.java @@ -34,6 +34,7 @@ public class HgPushCommand { private String myRevision; private boolean myForce; private String myBranchName; + private String myBookmarkName; private boolean myIsNewBranch; public HgPushCommand(Project project, @NotNull VirtualFile repo, String destination) { @@ -50,14 +51,18 @@ public class HgPushCommand { myForce = force; } - public void setBranchName(String branch) { - myBranchName = branch; + public void setBranchName(String branchName) { + myBranchName = branchName; } public void setIsNewBranch(boolean isNewBranch) { myIsNewBranch = isNewBranch; } + public void setBookmarkName(String bookmark) { + myBookmarkName = bookmark; + } + public void execute(final HgCommandResultHandler resultHandler) { final List arguments = new LinkedList(); if (!StringUtil.isEmptyOrSpaces(myRevision)) { @@ -73,6 +78,10 @@ public class HgPushCommand { arguments.add(myBranchName); } } + if (!StringUtil.isEmptyOrSpaces(myBookmarkName)) { + arguments.add("-B"); + arguments.add(myBookmarkName); + } if (myForce) { arguments.add("-f"); } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPushDialog.form b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPushDialog.form index a11d251812ad..ab1fd73801f5 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPushDialog.form +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPushDialog.form @@ -3,7 +3,7 @@ - + @@ -18,13 +18,13 @@ - + - + - + @@ -34,17 +34,9 @@ - - - - - - - - - + @@ -55,45 +47,76 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPushDialog.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPushDialog.java index 7795edccd86d..250485959399 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPushDialog.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgPushDialog.java @@ -51,6 +51,8 @@ public class HgPushDialog extends DialogWrapper { private JComboBox branchComboBox; private EditorComboBox myRepositoryURL; private JCheckBox newBranchCheckBox; + private JComboBox myBookmarkComboBox; + private JCheckBox myBookmarkCheckBox; private String myCurrentRepositoryUrl; public HgPushDialog(Project project, Collection repos, @Nullable HgRepository selectedRepo) { @@ -67,6 +69,7 @@ public class HgPushDialog extends DialogWrapper { final UpdatingListener updatingListener = new UpdatingListener(); revisionCbx.addChangeListener(updatingListener); branchCheckBox.addChangeListener(updatingListener); + myBookmarkCheckBox.addChangeListener(updatingListener); revisionTxt.getDocument().addDocumentListener(updatingListener); setTitle(HgVcsMessages.message("hg4idea.push.dialog.title")); @@ -125,6 +128,11 @@ public class HgPushDialog extends DialogWrapper { return branchCheckBox.isSelected() ? (String)branchComboBox.getSelectedItem() : null; } + @Nullable + public String getBookmarkName() { + return myBookmarkCheckBox.isSelected() ? (String)myBookmarkComboBox.getSelectedItem() : null; + } + public boolean isForce() { return forceCheckBox.isSelected(); } @@ -165,7 +173,9 @@ public class HgPushDialog extends DialogWrapper { private void updateComboBoxes(HgRepository repo) { final Collection branches = repo.getOpenedBranches(); + final Collection bookmarkNames = HgUtil.getNamesWithoutHashes(repo.getBookmarks()); branchComboBox.setModel(new DefaultComboBoxModel(branches.toArray())); + myBookmarkComboBox.setModel(new DefaultComboBoxModel(bookmarkNames.toArray())); } private void updateRepositoryUrlText(String defaultPath) { @@ -180,6 +190,7 @@ public class HgPushDialog extends DialogWrapper { revisionTxt.setEnabled(revisionCbx.isSelected()); branchComboBox.setEnabled(branchCheckBox.isSelected()); newBranchCheckBox.setEnabled(branchCheckBox.isSelected()); + myBookmarkComboBox.setEnabled(myBookmarkCheckBox.isSelected()); } private boolean validateOptions() {