# HG changeset patch # User jrice@netbeans.org # Date 1203518750 0 # Node ID 3aef657fdd9c84fa4c7b5b516f27f172179da6be # Parent 0aa6e6031fb2e19f5bfae07afdb1460405b0862f #127399: Update, revert, strip and backout - rework of these and rollback to give user a lot more control working with repos from IDE diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/Bundle.properties --- a/mercurial/src/org/netbeans/modules/mercurial/Bundle.properties Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/Bundle.properties Wed Feb 20 14:45:50 2008 +0000 @@ -99,7 +99,7 @@ CTL_PopupMenuItem_CloneLocal = Cl&one - CTL_PopupMenuItem_Status = &Status CTL_PopupMenuItem_Diff = &Diff -CTL_PopupMenuItem_Update = &Update +CTL_PopupMenuItem_Update = &Update... CTL_PopupMenuItem_Commit = &Commit... CTL_PopupMenuItem_ExportDiff = E&xport Diff... CTL_PopupMenuItem_ImportDiff = Im&port Patches... @@ -111,8 +111,10 @@ CTL_PopupMenuItem_PushLocal = Push &to - CTL_PopupMenuItem_PushLocal = Push &to - default CTL_PopupMenuItem_PullOther = Pu&ll Other... CTL_PopupMenuItem_PullLocal = Pull f&rom - default +CTL_PopupMenuItem_Backout = Backou&t... +CTL_PopupMenuItem_Strip = Stri&p... +CTL_PopupMenuItem_Revert = Re&vert... CTL_PopupMenuItem_Rollback = Rollbac&k -CTL_PopupMenuItem_Revert = Re&vert Modifications CTL_PopupMenuItem_Merge = M&erge CTL_PopupMenuItem_Resolve = Resolve Confl&icts CTL_PopupMenuItem_MarkResolved = M&ark as Resolved diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/MercurialAnnotator.java --- a/mercurial/src/org/netbeans/modules/mercurial/MercurialAnnotator.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/MercurialAnnotator.java Wed Feb 20 14:45:50 2008 +0000 @@ -79,7 +79,9 @@ import org.netbeans.modules.mercurial.ui import org.netbeans.modules.mercurial.ui.pull.PullOtherAction; import org.netbeans.modules.mercurial.ui.push.PushAction; import org.netbeans.modules.mercurial.ui.push.PushOtherAction; +import org.netbeans.modules.mercurial.ui.rollback.BackoutAction; import org.netbeans.modules.mercurial.ui.rollback.RollbackAction; +import org.netbeans.modules.mercurial.ui.rollback.StripAction; import org.netbeans.modules.mercurial.ui.update.RevertModificationsAction; import org.netbeans.modules.mercurial.ui.status.StatusAction; import org.netbeans.modules.mercurial.ui.update.ConflictResolvedAction; @@ -361,10 +363,7 @@ public class MercurialAnnotator extends } actions.add(new CloneExternalAction(loc.getString("CTL_PopupMenuItem_CloneOther"), ctx)); // NOI18N actions.add(null); - actions.add(new IncomingAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_ShowIncoming"), ctx)); // NOI18N - actions.add(new OutAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_ShowOut"), ctx)); // NOI18N actions.add(new FetchAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_FetchLocal"), ctx)); // NOI18N - actions.add(null); actions.add(new PushAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_PushLocal"), ctx)); // NOI18N actions.add(new PushOtherAction(loc.getString("CTL_PopupMenuItem_PushOther"), ctx)); // NOI18N actions.add(new PullAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_PullLocal"), ctx)); // NOI18N @@ -377,10 +376,14 @@ public class MercurialAnnotator extends } actions.add(tempA); actions.add(new LogAction(loc.getString("CTL_PopupMenuItem_Log"), ctx)); // NOI18N + actions.add(new IncomingAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_ShowIncoming"), ctx)); // NOI18N + actions.add(new OutAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_ShowOut"), ctx)); // NOI18N actions.add(new ViewAction(loc.getString("CTL_PopupMenuItem_View"), ctx)); // NOI18N actions.add(null); + actions.add(new RevertModificationsAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_Revert"), ctx)); // NOI18N + actions.add(new StripAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_Strip"), ctx)); // NOI18N + actions.add(new BackoutAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_Backout"), ctx)); // NOI18N actions.add(new RollbackAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_Rollback"), ctx)); // NOI18N - actions.add(new RevertModificationsAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_Revert"), ctx)); // NOI18N actions.add(new ResolveConflictsAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_Resolve"), ctx)); // NOI18N if (!onlyProjects && !onlyFolders) { IgnoreAction tempIA = new IgnoreAction(loc.getString("CTL_PopupMenuItem_Ignore"), ctx); // NOI18N @@ -403,11 +406,8 @@ public class MercurialAnnotator extends } actions.add(null); - actions.add(new IncomingAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_ShowIncoming"), ctx)); // NOI18N - actions.add(new OutAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_ShowOut"), ctx)); // NOI18N actions.add(new FetchAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_FetchLocal"), ctx)); // NOI18N - actions.add(null); actions.add(new PushAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_PushLocal"), ctx)); // NOI18N actions.add(new PullAction(NbBundle.getMessage(MercurialAnnotator.class, @@ -424,12 +424,15 @@ public class MercurialAnnotator extends actions.add(tempA); } actions.add(new LogAction(loc.getString("CTL_PopupMenuItem_Log"), ctx)); // NOI18N + actions.add(new IncomingAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_ShowIncoming"), ctx)); // NOI18N + actions.add(new OutAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_ShowOut"), ctx)); // NOI18N actions.add(new ViewAction(loc.getString("CTL_PopupMenuItem_View"), ctx)); // NOI18N actions.add(null); - actions.add(new RollbackAction(NbBundle.getMessage(MercurialAnnotator.class, - "CTL_PopupMenuItem_Rollback"), ctx)); // NOI18N actions.add(new RevertModificationsAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_Revert"), ctx)); // NOI18N + actions.add(new StripAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_Strip"), ctx)); // NOI18N + actions.add(new BackoutAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_Backout"), ctx)); // NOI18N + actions.add(new RollbackAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_Rollback"), ctx)); // NOI18N actions.add(new ResolveConflictsAction(NbBundle.getMessage(MercurialAnnotator.class, "CTL_PopupMenuItem_Resolve"), ctx)); // NOI18N if (!onlyProjects && !onlyFolders) { diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/annotate/AnnotationBar.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/annotate/AnnotationBar.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/annotate/AnnotationBar.java Wed Feb 20 14:45:50 2008 +0000 @@ -428,10 +428,12 @@ final class AnnotationBar extends JCompo return; } final String revStr = revertModifications.getSelectionRevision(); + final boolean doBackup = revertModifications.isBackupRequested(); + RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root); HgProgressSupport support = new HgProgressSupport() { public void perform() { - RevertModificationsAction.performRevert(root, revStr, file); + RevertModificationsAction.performRevert(root, revStr, file, doBackup); } }; support.start(rp, root.getAbsolutePath(), NbBundle.getMessage(AnnotationBar.class, "MSG_Revert_Progress")); // NOI18N diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitAction.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/commit/CommitAction.java Wed Feb 20 14:45:50 2008 +0000 @@ -313,7 +313,8 @@ public class CommitAction extends Contex commit.setEnabled(enabled && containsCommitable(table)); } - private static void performCommit(String message, Map commitFiles, VCSContext ctx, HgProgressSupport support, String prjName) { + private static void performCommit(String message, Map commitFiles, + VCSContext ctx, HgProgressSupport support, String prjName) { FileStatusCache cache = Mercurial.getInstance().getFileStatusCache(); final File repository = HgUtils.getRootFile(ctx); List addCandidates = new ArrayList(); @@ -356,6 +357,7 @@ public class CommitAction extends Contex HgUtils.outputMercurialTabInRed( NbBundle.getMessage(CommitAction.class, "MSG_COMMIT_TITLE_SEP")); // NOI18N + HgUtils.outputMercurialTab(message); // NOI18N if (addCandidates.size() > 0 ) { HgCommand.doAdd(repository, addCandidates); for (File f : addCandidates) { diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/diff/MultiDiffPanel.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/diff/MultiDiffPanel.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/diff/MultiDiffPanel.java Wed Feb 20 14:45:50 2008 +0000 @@ -400,7 +400,7 @@ class MultiDiffPanel extends javax.swing } private void onUpdateButton() { - UpdateAction.update(context, null); + UpdateAction.update(context); } private void onCommitButton() { diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/log/Bundle.properties --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/Bundle.properties Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/Bundle.properties Wed Feb 20 14:45:50 2008 +0000 @@ -44,8 +44,13 @@ MSG_Log_Progress=Showing History... MSG_Log_Progress=Showing History... MSG_Log_TabTitle = Mercurial History - {0} MSG_Log_TabTitleNotCommitted = Mercurial History - {0} (not committed) -MSG_Log_Title = Mercurial History -MSG_Log_Title_Sep = ----------------- +MSG_Log_Title = Mercurial History +MSG_LogIncoming_Title = Mercurial Incoming +MSG_LogOut_Title = Mercurial Outgoing +MSG_Log_Title_Sep = ------------------ +MSG_LOG_CONTEXT_SEP = Search within:\n +MSG_LOG_EXEC_CONTEXT_SEP = Search executed on:\n + MSG_Log_DONE = INFO: End of Mercurial History MSG_Log_Files = INFO History for file(s): {0} MSG_Log_PrjName = INFO Project Name: {0} diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchExecutor.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchExecutor.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchExecutor.java Wed Feb 20 14:45:50 2008 +0000 @@ -50,6 +50,7 @@ import org.netbeans.modules.mercurial.Hg import org.netbeans.modules.mercurial.HgProgressSupport; import org.netbeans.modules.mercurial.Mercurial; import org.netbeans.modules.mercurial.util.HgCommand; +import org.netbeans.modules.mercurial.util.HgUtils; /** * Executes searches in Search History panel. @@ -85,12 +86,27 @@ class SearchExecutor implements Runnable filterUsername = criteria.getUsername() != null; filterMessage = criteria.getCommitMessage() != null; + if (master.isIncomingSearch()) { + HgUtils.outputMercurialTabInRed( NbBundle.getMessage(SearchHistoryAction.class, + "MSG_LogIncoming_Title")); // NOI18N + }else if (master.isOutSearch()) { + HgUtils.outputMercurialTabInRed( NbBundle.getMessage(SearchHistoryAction.class, + "MSG_LogOut_Title")); // NOI18N + } else { + HgUtils.outputMercurialTabInRed( NbBundle.getMessage(SearchHistoryAction.class, + "MSG_Log_Title")); // NOI18N + } + HgUtils.outputMercurialTabInRed( NbBundle.getMessage(SearchHistoryAction.class, + "MSG_Log_Title_Sep")); // NOI18N + HgUtils.outputMercurialTab( NbBundle.getMessage(SearchHistoryAction.class, + "MSG_LOG_EXEC_CONTEXT_SEP")); // NOI18N pathToRoot = new HashMap(); if (searchingUrl()) { String rootPath = Mercurial.getInstance().getTopmostManagedParent(master.getRoots()[0]).toString(); pathToRoot.put(rootPath, master.getRoots()[0]); + HgUtils.outputMercurialTab(rootPath); } else { - workFiles = new HashMap>(); + workFiles = new HashMap>(); for (File file : master.getRoots()) { String rootPath = Mercurial.getInstance().getTopmostManagedParent(file).toString(); @@ -100,8 +116,11 @@ class SearchExecutor implements Runnable workFiles.put(rootPath, set); } set.add(file); + HgUtils.outputMercurialTab(file.getAbsolutePath()); } - } + } + HgUtils.outputMercurialTab(""); // NOI18N + } public void run() { diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryAction.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/SearchHistoryAction.java Wed Feb 20 14:45:50 2008 +0000 @@ -50,6 +50,7 @@ import java.util.*; import java.util.*; import org.netbeans.modules.mercurial.FileInformation; import org.netbeans.modules.mercurial.ui.actions.ContextAction; +import org.netbeans.modules.mercurial.util.HgUtils; import org.netbeans.modules.versioning.spi.VCSContext; import org.openide.windows.TopComponent; @@ -92,7 +93,22 @@ public class SearchHistoryAction extends public static void openHistory(final VCSContext context, final String title) { SwingUtilities.invokeLater(new Runnable() { public void run() { - SearchHistoryTopComponent tc = new SearchHistoryTopComponent(context); + if (context == null) return; + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(SearchHistoryAction.class, + "MSG_Log_Title")); // NOI18N + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(SearchHistoryAction.class, + "MSG_Log_Title_Sep")); // NOI18N + File[] files = context.getFiles().toArray(new File[0]); + HgUtils.outputMercurialTab( + NbBundle.getMessage(SearchHistoryAction.class, + "MSG_LOG_CONTEXT_SEP")); // NOI18N + for(File f: files){ + HgUtils.outputMercurialTab(f.getAbsolutePath()); + } + HgUtils.outputMercurialTabInRed(""); // NOI18N + SearchHistoryTopComponent tc = new SearchHistoryTopComponent(context); tc.setDisplayName(title); tc.open(); tc.requestActive(); diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/log/SummaryView.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/SummaryView.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/SummaryView.java Wed Feb 20 14:45:50 2008 +0000 @@ -65,6 +65,7 @@ import org.netbeans.api.editor.mimelooku import org.netbeans.api.editor.mimelookup.MimePath; import org.netbeans.modules.mercurial.ExceptionHandler; import org.netbeans.modules.mercurial.HgException; +import org.netbeans.modules.mercurial.HgModuleConfig; import org.netbeans.modules.mercurial.HgProgressSupport; import org.netbeans.modules.mercurial.Mercurial; import org.netbeans.modules.mercurial.VersionsCache; @@ -428,6 +429,7 @@ class SummaryView implements MouseListen private static void revertImpl(SearchHistoryPanel master, RepositoryRevision[] revisions, RepositoryRevision.Event[] events, HgProgressSupport progress) { List revertFiles = new ArrayList(); + boolean doBackup = HgModuleConfig.getDefault().getBackupOnRevertModifications(); for (RepositoryRevision revision : revisions) { File root = new File(revision.getRepositoryRootUrl()); for(RepositoryRevision.Event event: revision.getEvents()){ @@ -435,7 +437,7 @@ class SummaryView implements MouseListen revertFiles.add(event.getFile()); } RevertModificationsAction.performRevert( - root, revision.getLog().getRevision(), revertFiles); + root, revision.getLog().getRevision(), revertFiles, doBackup); revertFiles.clear(); } @@ -465,7 +467,7 @@ class SummaryView implements MouseListen if(revEvents != null && !revEvents.isEmpty()){ // Assuming all files in a given repository reverting to same revision RevertModificationsAction.performRevert( - root, revEvents.get(0).getLogInfoHeader().getLog().getRevision(), revertFiles); + root, revEvents.get(0).getLogInfoHeader().getLog().getRevision(), revertFiles, doBackup); } } } diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/rollback/Backout.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/Backout.java Wed Feb 20 14:45:50 2008 +0000 @@ -0,0 +1,117 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package org.netbeans.modules.mercurial.ui.rollback; + +import java.awt.Dialog; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import javax.swing.JButton; +import org.openide.DialogDescriptor; +import org.openide.DialogDisplayer; +import org.openide.util.HelpCtx; +import java.io.File; + +/** + * + * @author Padraig O'Briain + */ +public class Backout implements PropertyChangeListener { + + private BackoutPanel panel; + private JButton okButton; + private JButton cancelButton; + private File repository; + + /** Creates a new instance of Backout */ + public Backout(File repository) { + this (repository, null); + } + + public Backout(File repository, String defaultRevision) { + this.repository = repository; + panel = new BackoutPanel(repository); + okButton = new JButton(); + org.openide.awt.Mnemonics.setLocalizedText(okButton, org.openide.util.NbBundle.getMessage(Backout.class, "CTL_BackoutForm_Action_Backout")); // NOI18N + okButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(Backout.class, "ACSD_BackoutForm_Action_Backout")); // NOI18N + okButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(Backout.class, "ACSN_BackoutForm_Action_Backout")); // NOI18N + cancelButton = new JButton(); + org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(Backout.class, "CTL_BackoutForm_Action_Cancel")); // NOI18N + cancelButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(Backout.class, "ACSD_BackoutForm_Action_Cancel")); // NOI18N + cancelButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(Backout.class, "ACSN_BackoutForm_Action_Cancel")); // NOI18N + } + + public boolean showDialog() { + DialogDescriptor dialogDescriptor; + dialogDescriptor = new DialogDescriptor(panel, org.openide.util.NbBundle.getMessage(Backout.class, "CTL_BackoutDialog", repository.getName())); // NOI18N + dialogDescriptor.setOptions(new Object[] {okButton, cancelButton}); + + dialogDescriptor.setModal(true); + dialogDescriptor.setHelpCtx(new HelpCtx(this.getClass())); + dialogDescriptor.setValid(false); + + Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor); + dialog.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(Backout.class, "ACSD_BackoutDialog", repository.getName())); // NOI18N + dialog.setVisible(true); + dialog.setResizable(false); + boolean ret = dialogDescriptor.getValue() == okButton; + return ret; + } + + public void propertyChange(PropertyChangeEvent evt) { + if(okButton != null) { + boolean valid = ((Boolean)evt.getNewValue()).booleanValue(); + okButton.setEnabled(valid); + } + } + + public String getSelectionRevision() { + if (panel == null) return null; + return panel.getSelectedRevision(); + } + public String getCommitMessage() { + if (panel == null) return null; + return panel.getCommitMessage(); + } + public boolean isMergeRequested() { + if (panel == null) return false; + return panel.isMergeRequested(); + } +} diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/rollback/BackoutAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/BackoutAction.java Wed Feb 20 14:45:50 2008 +0000 @@ -0,0 +1,188 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package org.netbeans.modules.mercurial.ui.rollback; + +import org.netbeans.modules.versioning.spi.VCSContext; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.io.File; +import java.util.List; +import org.netbeans.modules.mercurial.FileInformation; +import org.netbeans.modules.mercurial.HgException; +import org.netbeans.modules.mercurial.HgProgressSupport; +import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.util.HgCommand; +import org.netbeans.modules.mercurial.util.HgUtils; +import org.netbeans.modules.mercurial.FileStatusCache; +import org.netbeans.modules.mercurial.ui.update.ConflictResolvedAction; +import org.netbeans.modules.mercurial.ui.actions.ContextAction; +import org.netbeans.modules.mercurial.ui.merge.MergeAction; +import org.openide.util.NbBundle; +import org.openide.util.RequestProcessor; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; + +/** + * Pull action for mercurial: + * hg pull - pull changes from the specified source + * + * @author John Rice + */ +public class BackoutAction extends ContextAction { + + private final VCSContext context; + private static final String HG_BACKOUT_REVISION_REPLACE = "\\{revision}"; + public static final String HG_BACKOUT_REVISION = " {revision}"; + + public BackoutAction(String name, VCSContext context) { + this.context = context; + putValue(Action.NAME, name); + } + + public void performAction(ActionEvent e) { + backout(context); + } + + public static void backout(final VCSContext ctx){ + final File root = HgUtils.getRootFile(ctx); + if (root == null) return; + String repository = root.getAbsolutePath(); + + String rev = null; + String commitMsg = null; + + final Backout backout = new Backout(root); + if (!backout.showDialog()) { + return; + } + rev = backout.getSelectionRevision(); + commitMsg = backout.getCommitMessage(); + final boolean doMerge = false; // Now handling this using our own merge mechanism, not backout's + final String revStr = rev; + commitMsg = commitMsg.replaceAll(HG_BACKOUT_REVISION_REPLACE, revStr); //NOI18N + final String commitMsgStr = commitMsg; + + RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(repository); + HgProgressSupport support = new HgProgressSupport() { + public void perform() { + + try { + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(BackoutAction.class, + "MSG_BACKOUT_TITLE")); // NOI18N + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(BackoutAction.class, + "MSG_BACKOUT_TITLE_SEP")); // NOI18N + HgUtils.outputMercurialTab( + NbBundle.getMessage(BackoutAction.class, + "MSG_BACKOUT_INFO_SEP", revStr, root.getAbsolutePath())); // NOI18N + List list = HgCommand.doBackout(root, revStr, doMerge, commitMsgStr); + + if(list != null && !list.isEmpty()){ + boolean bMergeNeededDueToBackout = HgCommand.isBackoutMergeNeededMsg(list.get(list.size() - 1)); + if(bMergeNeededDueToBackout){ + list.remove(list.size() - 1); + list.remove(list.size() - 1); + } + HgUtils.outputMercurialTab(list); + + if(HgCommand.isUncommittedChangesBackout(list.get(0))){ + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(BackoutAction.class, + "MSG_UNCOMMITTED_CHANGES_BACKOUT")); // NOI18N + return; + } else if(HgCommand.isMergeChangesetBackout(list.get(0))){ + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(BackoutAction.class, + "MSG_MERGE_CSET_BACKOUT",revStr)); // NOI18N + return; + } else if(HgCommand.isNoRevStrip(list.get(0))){ + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(BackoutAction.class, + "MSG_NO_REV_BACKOUT",revStr)); // NOI18N + return; + } + + // Handle Merge - both automatic and merge with conflicts + boolean bConfirmMerge = false; + if (bMergeNeededDueToBackout) { + bConfirmMerge = HgUtils.confirmDialog( + BackoutAction.class, "MSG_BACKOUT_MERGE_CONFIRM_TITLE", "MSG_BACKOUT_MERGE_CONFIRM_QUERY"); // NOI18N + } + if (bConfirmMerge) { + HgUtils.outputMercurialTab(""); // NOI18N + HgUtils.outputMercurialTabInRed(NbBundle.getMessage(BackoutAction.class, "MSG_BACKOUT_MERGE_DO")); // NOI18N + MergeAction.doMergeAction(root, null); + } else { + List headRevList = HgCommand.getHeadRevisions(root); + if (headRevList != null && headRevList.size() > 1) { + MergeAction.printMergeWarning(headRevList); + } + } + HgUtils.forceStatusRefreshProject(ctx); + // refresh filesystem to take account of deleted files. + FileObject rootObj = FileUtil.toFileObject(root); + try { + rootObj.getFileSystem().refresh(true); + } catch (java.lang.Exception ex) { + } + } + } catch (HgException ex) { + NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); + DialogDisplayer.getDefault().notifyLater(e); + } finally { + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(BackoutAction.class, + "MSG_BACKOUT_DONE")); // NOI18N + HgUtils.outputMercurialTab(""); // NOI18N + } + } + }; + support.start(rp, repository,org.openide.util.NbBundle.getMessage(BackoutAction.class, "MSG_BACKOUT_PROGRESS")); // NOI18N + } + + public boolean isEnabled() { + return HgUtils.getRootFile(context) != null; + } +} diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/rollback/BackoutPanel.form --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/BackoutPanel.form Wed Feb 20 14:45:50 2008 +0000 @@ -0,0 +1,161 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/rollback/BackoutPanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/BackoutPanel.java Wed Feb 20 14:45:50 2008 +0000 @@ -0,0 +1,277 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package org.netbeans.modules.mercurial.ui.rollback; + +import java.io.File; +import java.util.Set; +import java.util.Vector; +import java.util.LinkedHashSet; +import javax.swing.SwingUtilities; +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import org.netbeans.api.progress.ProgressHandleFactory; +import org.netbeans.api.progress.ProgressHandle; +import org.openide.util.RequestProcessor; +import org.openide.util.NbBundle; +import org.netbeans.modules.mercurial.util.HgCommand; + +/** + * + * @author Padraig O'Briain + */ +public class BackoutPanel extends javax.swing.JPanel { + + private File repository; + private RequestProcessor.Task refreshViewTask; + private static final RequestProcessor rp = new RequestProcessor("MercurialBackout", 1); // NOI18N + private Thread refreshViewThread; + + private static final int HG_REVERT_TARGET_LIMIT = 100; + + /** Creates new form ReverModificationsPanel */ + public BackoutPanel(File repo) { + repository = repo; + refreshViewTask = rp.create(new RefreshViewTask()); + initComponents(); + commitMsgField.setText( + NbBundle.getMessage(BackoutPanel.class, "BackoutPanel.commitMsgField.text") + + BackoutAction.HG_BACKOUT_REVISION); // NOI18N + refreshViewTask.schedule(0); + } + + public String getSelectedRevision() { + String revStr = (String) revisionsComboBox.getSelectedItem(); + if(revStr != null){ + if (revStr.equals(NbBundle.getMessage(Backout.class, "MSG_Revision_Default")) || // NOI18N + revStr.equals(NbBundle.getMessage(Backout.class, "MSG_Fetching_Revisions"))) { // NOI18N + revStr = null; + } else { + revStr = revStr.substring(0, revStr.indexOf(" ")); // NOI18N + } + } + return revStr; + } + + public String getCommitMessage() { + return commitMsgField.getText(); + } + + public boolean isMergeRequested() { + return doMergeChxBox.isSelected(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + doMergeChxBox = new javax.swing.JCheckBox(); + revisionsLabel = new javax.swing.JLabel(); + revisionsComboBox = new javax.swing.JComboBox(); + infoLabel = new javax.swing.JLabel(); + infoLabel2 = new javax.swing.JLabel(); + jPanel1 = new javax.swing.JPanel(); + commitMsgField = new javax.swing.JTextField(); + commitLabel = new javax.swing.JLabel(); + + doMergeChxBox.setSelected(true); + org.openide.awt.Mnemonics.setLocalizedText(doMergeChxBox, org.openide.util.NbBundle.getMessage(BackoutPanel.class, "BackoutPanel.doMergeChxBox.text")); // NOI18N + doMergeChxBox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + doMergeChxBoxActionPerformed(evt); + } + }); + + revisionsLabel.setLabelFor(revisionsComboBox); + org.openide.awt.Mnemonics.setLocalizedText(revisionsLabel, org.openide.util.NbBundle.getMessage(BackoutPanel.class, "BackoutPanel.revisionsLabel.text")); // NOI18N + + infoLabel.setFont(new java.awt.Font("Dialog", 1, 11)); + org.openide.awt.Mnemonics.setLocalizedText(infoLabel, org.openide.util.NbBundle.getMessage(BackoutPanel.class, "BackoutPanel.infoLabel.text")); // NOI18N + + infoLabel2.setForeground(new java.awt.Color(153, 153, 153)); + org.openide.awt.Mnemonics.setLocalizedText(infoLabel2, org.openide.util.NbBundle.getMessage(BackoutPanel.class, "BackoutPanel.infoLabel2.text")); // NOI18N + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(BackoutPanel.class, "StripPanel.jPanel1.border.title"))); // NOI18N + + commitMsgField.setText(org.openide.util.NbBundle.getMessage(BackoutPanel.class, "BackoutPanel.commitMsgField.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(commitLabel, org.openide.util.NbBundle.getMessage(BackoutPanel.class, "BackoutPanel.commitLabel.text")); // NOI18N + + org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .add(commitLabel) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(commitMsgField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE) + .addContainerGap()) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(commitLabel) + .add(commitMsgField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(layout.createSequentialGroup() + .addContainerGap() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, infoLabel2) + .add(org.jdesktop.layout.GroupLayout.LEADING, infoLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 390, Short.MAX_VALUE))) + .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() + .add(48, 48, 48) + .add(revisionsLabel) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(revisionsComboBox, 0, 209, Short.MAX_VALUE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(infoLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(4, 4, 4) + .add(infoLabel2) + .add(29, 29, 29) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(revisionsLabel) + .add(revisionsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap(14, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void doMergeChxBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_doMergeChxBoxActionPerformed + if( doMergeChxBox.isSelected()){ + commitMsgField.setEnabled(true); + commitMsgField.setEditable(true); + commitLabel.setEnabled(true); + }else{ + commitMsgField.setEnabled(false); + commitMsgField.setEditable(false); + commitLabel.setEnabled(false); + } + }//GEN-LAST:event_doMergeChxBoxActionPerformed + + + /** + * Must NOT be run from AWT. + */ + private void setupModels() { + // XXX attach Cancelable hook + final ProgressHandle ph = ProgressHandleFactory.createHandle(NbBundle.getMessage(Backout.class, "MSG_Refreshing_Backout_Versions")); // NOI18N + try { + Set initialRevsSet = new LinkedHashSet(); + initialRevsSet.add(NbBundle.getMessage(Backout.class, "MSG_Fetching_Revisions")); // NOI18N + ComboBoxModel targetsModel = new DefaultComboBoxModel(new Vector(initialRevsSet)); + revisionsComboBox.setModel(targetsModel); + refreshViewThread = Thread.currentThread(); + Thread.interrupted(); // clear interupted status + ph.start(); + + refreshRevisions(); + } finally { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + ph.finish(); + refreshViewThread = null; + } + }); + } + } + + private void refreshRevisions() { + java.util.List targetRevsList = HgCommand.getRevisions(repository, HG_REVERT_TARGET_LIMIT); + + Set targetRevsSet = new LinkedHashSet(); + + int size; + if( targetRevsList == null){ + size = 0; + targetRevsSet.add(NbBundle.getMessage(Backout.class, "MSG_Revision_Default")); // NOI18N + }else{ + size = targetRevsList.size(); + int i = 0 ; + while(i < size){ + targetRevsSet.add(targetRevsList.get(i)); + i++; + } + } + ComboBoxModel targetsModel = new DefaultComboBoxModel(new Vector(targetRevsSet)); + revisionsComboBox.setModel(targetsModel); + + if (targetRevsSet.size() > 0 ) { + revisionsComboBox.setSelectedIndex(0); + } + } + + private class RefreshViewTask implements Runnable { + public void run() { + setupModels(); + } + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel commitLabel; + private javax.swing.JTextField commitMsgField; + private javax.swing.JCheckBox doMergeChxBox; + private javax.swing.JLabel infoLabel; + private javax.swing.JLabel infoLabel2; + private javax.swing.JPanel jPanel1; + private javax.swing.JComboBox revisionsComboBox; + private javax.swing.JLabel revisionsLabel; + // End of variables declaration//GEN-END:variables + +} diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/rollback/Bundle.properties --- a/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/Bundle.properties Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/Bundle.properties Wed Feb 20 14:45:50 2008 +0000 @@ -42,9 +42,79 @@ MSG_ROLLBACK_INFO = INFO Rollback rolls MSG_ROLLBACK_INFO = INFO Rollback rolls back the last transaction in this repository and can only rollback one level. MSG_ROLLBACK_TITLE = Mercurial Rollback MSG_ROLLBACK_TITLE_SEP = -------------------- +MSG_ROLLBACK_INFO_SEP = Rollback in:\n{0} +MSG_ROLLBACK_CANCELED = INFO: Rollback canceled by user MSG_ROLLBACK_DONE = INFO: End of Mercurial Rollback -MSG_ROLLBACK_CONFIRM = Confirm Rollback Update -MSG_ROLLBACK_CONFIRM_QUERY = Repository Rollback has completed.\nDo a forced update of the working directory? +MSG_ROLLBACK_CONFIRM = Confirm Rollback +MSG_ROLLBACK_CONFIRM_QUERY = Roll back the last commit, push/pull, import or unbundle in this repository.\nUse with care as there is no way to undo a rollback!\n\nDo you still want to perform a Rollback? +MSG_ROLLBACK_CONFIRM_UPDATE = Confirm Rollback Update +MSG_ROLLBACK_CONFIRM_UPDATE_QUERY = Repository Rollback has completed.\nDo a forced update of the working directory? MSG_ROLLBACK_FORCE_UPDATE = Carrying out a forced update of the working directory {0} MSG_ROLLBACK_MESSAGE = No Rollback Update MSG_ROLLBACK_MESSAGE_NOHISTORY = Repository Rollback has completed.\nThe working directory will not be updated as the repository now has no history. + +MSG_Revision_Default = +MSG_Fetching_Revisions = Fetching Revisions... +MSG_Refreshing_Strip_Versions = Refreshing Strip Versions + +MSG_STRIP_TITLE = Mercurial Strip +MSG_STRIP_TITLE_SEP = --------------- +MSG_STRIP_INFO_SEP = Stripping revision {0} and descendents in:\n{1} +MSG_NO_REV_STRIP = \nINFO: Unable to Strip this Revision {0} +MSG_LOCAL_CHANGES_STRIP = \nStrip will not work if there are local changes. You can view them using Mercurial -> Status.\nINFO: If you wish to discard local changes, use Mercurial -> Update selecting the Forced Update option and rerun Strip. +MSG_MULTI_HEADS_STRIP = \nINFO: Strip will not work across multiple heads unless the Force multihead option is selected. +MSG_STRIP_RESTORE_INFO = \nINFO: Strip can be undone using the saved backup bundle. On the command line run: +MSG_STRIP_RESTORE_INFO2 = hg unbundle {0} +MSG_STRIP_PROGRESS = Strip... +MSG_STRIP_DONE = INFO: End of Mercurial Strip + +MSG_BACKOUT_TITLE = Mercurial Backout +MSG_BACKOUT_TITLE_SEP = ----------------- +MSG_BACKOUT_INFO_SEP = Backout revision {0} in:\n{1} +MSG_NO_REV_BACKOUT = \nINFO: Unable to Backout this Revision {0} +MSG_BACKOUT_PROGRESS = Backout... +MSG_BACKOUT_DONE = INFO: End of Mercurial Backout +MSG_UNCOMMITTED_CHANGES_BACKOUT = \nBackout will not work if there are uncommitted local changes. You can view them using Mercurial -> Status.\nINFO: If you wish to discard these changes, use Mercurial -> Update selecting the Forced Update option and rerun Backout. +MSG_MERGE_CSET_BACKOUT = \nCannot backout a backout merge changeset.\nINFO: Either run hg backout --parent from the command line or use Mercurial -> Rollback. +MSG_BACKOUT_MERGE_CONFIRM_TITLE = Confirm Merge after Backout +MSG_BACKOUT_MERGE_CONFIRM_QUERY = Backout has completed and Merge is Required.\nMerge the backout changeset now? +MSG_BACKOUT_MERGE_DO = INFO MERGE: Performing Merge with backout changeset + + +CTL_StripForm_Action_Strip=&Strip +ACSD_StripForm_Action_Strip=Strip +ACSN_StripForm_Action_Strip=Strip +CTL_StripForm_Action_Cancel=&Cancel +ACSD_StripForm_Action_Cancel=Cancel +ACSN_StripForm_Action_Cancel=Cancel +CTL_StripDialog=Strip - {0} +ACSD_StripDialog=Strip - {0} + +StripPanel.revisionsLabel.text=Choose from &Revisions: +StripPanel.infoLabel.text=Strip selected revision and it's descendants from the repository +StripPanel.infoLabel2.text=(updates the working dir to the first parent of the stripped revision) +StripPanel.doBackupChxBox.text= Save a backup so stripped revisions can be reapplied +StripPanel.jPanel1.border.title= Options +StripPanel.doForcedMultiHeadStripChxBox.text=Force multi-head removal if required + +BackoutPanel.revisionsLabel.text=Choose from &Revisions: +BackoutPanel.infoLabel.text=Backout selected revision from the repository +BackoutPanel.infoLabel2.text=(creates a backout changeset to back out only this revision) +BackoutPanel.jPanel1.border.title= Options +BackoutPanel.doMergeChxBox.text=Automerge the backout changeset with tip and commit + +MSG_Refreshing_Backout_Versions = Refreshing Backout Versions +MSG_Revision_Default = +MSG_Fetching_Revisions = Fetching Revisions... +MSG_Refreshing_Backout_Versions = Refreshing Backout Versions + +CTL_BackoutForm_Action_Backout=&Backout +ACSD_BackoutForm_Action_Backout=Backout +ACSN_BackoutForm_Action_Backout=Backout +CTL_BackoutForm_Action_Cancel=&Cancel +ACSD_BackoutForm_Action_Cancel=Cancel +ACSN_BackoutForm_Action_Cancel=Cancel +CTL_BackoutDialog=Strip - {0} +ACSD_BackoutDialog=Strip - {0} +BackoutPanel.commitMsgField.text=Autocommit of backout changeset for +BackoutPanel.commitLabel.text=Commit Msg: diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/rollback/RollbackAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/RollbackAction.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/RollbackAction.java Wed Feb 20 14:45:50 2008 +0000 @@ -52,7 +52,6 @@ import org.netbeans.modules.mercurial.Me import org.netbeans.modules.mercurial.Mercurial; import org.netbeans.modules.mercurial.util.HgCommand; import org.netbeans.modules.mercurial.util.HgUtils; -import org.netbeans.modules.mercurial.util.HgRepositoryContextCache; import org.netbeans.modules.mercurial.FileStatusCache; import org.netbeans.modules.mercurial.ui.update.ConflictResolvedAction; import org.netbeans.modules.mercurial.ui.actions.ContextAction; @@ -70,7 +69,6 @@ public class RollbackAction extends Cont public class RollbackAction extends ContextAction { private final VCSContext context; - private static File pullPath = null; public RollbackAction(String name, VCSContext context) { this.context = context; @@ -78,18 +76,6 @@ public class RollbackAction extends Cont } public void performAction(ActionEvent e) { - if(!HgRepositoryContextCache.hasHistory(context)){ - HgUtils.outputMercurialTabInRed( - NbBundle.getMessage(RollbackAction.class, - "MSG_ROLLBACK_TITLE")); // NOI18N - HgUtils.outputMercurialTabInRed( - NbBundle.getMessage(RollbackAction.class, - "MSG_ROLLBACK_TITLE_SEP")); // NOI18N - HgUtils.outputMercurialTab(NbBundle.getMessage(RollbackAction.class, "MSG_NO_ROLLBACK")); // NOI18N - HgUtils.outputMercurialTabInRed(NbBundle.getMessage(RollbackAction.class, "MSG_ROLLBACK_DONE")); // NOI18N - HgUtils.outputMercurialTab(""); // NOI18N - return; - } rollback(context); } @@ -109,7 +95,22 @@ public class RollbackAction extends Cont HgUtils.outputMercurialTabInRed( NbBundle.getMessage(RollbackAction.class, "MSG_ROLLBACK_TITLE_SEP")); // NOI18N + HgUtils.outputMercurialTab( + NbBundle.getMessage(StripAction.class, + "MSG_ROLLBACK_INFO_SEP", root.getAbsolutePath())); // NOI18N + int response = JOptionPane.showOptionDialog(null, + NbBundle.getMessage(RollbackAction.class, "MSG_ROLLBACK_CONFIRM_QUERY"), // NOI18N + NbBundle.getMessage(RollbackAction.class, "MSG_ROLLBACK_CONFIRM"), // NOI18N + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); + + if (response == JOptionPane.NO_OPTION) { + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(RollbackAction.class, + "MSG_ROLLBACK_CANCELED", root.getAbsolutePath())); // NOI18N + return; + } List list = HgCommand.doRollback(root); + if(list != null && !list.isEmpty()){ //HgUtils.clearOutputMercurialTab(); @@ -121,9 +122,9 @@ public class RollbackAction extends Cont }else{ HgUtils.outputMercurialTab(list.get(0)); if (HgCommand.hasHistory(root)) { - int response = JOptionPane.showOptionDialog(null, - NbBundle.getMessage(RollbackAction.class,"MSG_ROLLBACK_CONFIRM_QUERY") , // NOI18N - NbBundle.getMessage(RollbackAction.class,"MSG_ROLLBACK_CONFIRM"), // NOI18N + response = JOptionPane.showOptionDialog(null, + NbBundle.getMessage(RollbackAction.class,"MSG_ROLLBACK_CONFIRM_UPDATE_QUERY") , // NOI18N + NbBundle.getMessage(RollbackAction.class,"MSG_ROLLBACK_CONFIRM_UPDATE"), // NOI18N JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,null, null, null); if( response == JOptionPane.YES_OPTION){ diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/rollback/Strip.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/Strip.java Wed Feb 20 14:45:50 2008 +0000 @@ -0,0 +1,109 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package org.netbeans.modules.mercurial.ui.rollback; + +import java.awt.Dialog; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import javax.swing.JButton; +import org.openide.DialogDescriptor; +import org.openide.DialogDisplayer; +import org.openide.util.HelpCtx; +import java.io.File; + +/** + * + * @author Padraig O'Briain + */ +public class Strip implements PropertyChangeListener { + + private StripPanel panel; + private JButton okButton; + private JButton cancelButton; + private File repository; + + /** Creates a new instance of Strip */ + public Strip(File repository) { + this.repository = repository; + panel = new StripPanel(repository); + okButton = new JButton(); + org.openide.awt.Mnemonics.setLocalizedText(okButton, org.openide.util.NbBundle.getMessage(Strip.class, "CTL_StripForm_Action_Strip")); // NOI18N + okButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(Strip.class, "ACSD_StripForm_Action_Strip")); // NOI18N + okButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(Strip.class, "ACSN_StripForm_Action_Strip")); // NOI18N + cancelButton = new JButton(); + org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(Strip.class, "CTL_StripForm_Action_Cancel")); // NOI18N + cancelButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(Strip.class, "ACSD_StripForm_Action_Cancel")); // NOI18N + cancelButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(Strip.class, "ACSN_StripForm_Action_Cancel")); // NOI18N + } + + public boolean showDialog() { + DialogDescriptor dialogDescriptor; + dialogDescriptor = new DialogDescriptor(panel, org.openide.util.NbBundle.getMessage(Strip.class, "CTL_StripDialog", repository.getName())); // NOI18N + dialogDescriptor.setOptions(new Object[] {okButton, cancelButton}); + + dialogDescriptor.setModal(true); + dialogDescriptor.setHelpCtx(new HelpCtx(this.getClass())); + dialogDescriptor.setValid(false); + + Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor); + dialog.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(Strip.class, "ACSD_StripDialog", repository.getName())); // NOI18N + dialog.setVisible(true); + dialog.setResizable(false); + boolean ret = dialogDescriptor.getValue() == okButton; + return ret; + } + + public void propertyChange(PropertyChangeEvent evt) { + if(okButton != null) { + boolean valid = ((Boolean)evt.getNewValue()).booleanValue(); + okButton.setEnabled(valid); + } + } + + public String getSelectionRevision() { + if (panel == null) return null; + return panel.getSelectedRevision(); + } + public boolean isBackupRequested() { + if (panel == null) return false; + return panel.isBackupRequested(); + } +} diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/rollback/StripAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/StripAction.java Wed Feb 20 14:45:50 2008 +0000 @@ -0,0 +1,168 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package org.netbeans.modules.mercurial.ui.rollback; + +import org.netbeans.modules.versioning.spi.VCSContext; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.io.File; +import java.util.List; +import org.netbeans.modules.mercurial.FileInformation; +import org.netbeans.modules.mercurial.HgException; +import org.netbeans.modules.mercurial.HgProgressSupport; +import org.netbeans.modules.mercurial.Mercurial; +import org.netbeans.modules.mercurial.util.HgCommand; +import org.netbeans.modules.mercurial.util.HgUtils; +import org.netbeans.modules.mercurial.FileStatusCache; +import org.netbeans.modules.mercurial.ui.update.ConflictResolvedAction; +import org.netbeans.modules.mercurial.ui.actions.ContextAction; +import org.openide.util.NbBundle; +import org.openide.util.RequestProcessor; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; + +/** + * Pull action for mercurial: + * hg pull - pull changes from the specified source + * + * @author John Rice + */ +public class StripAction extends ContextAction { + + private final VCSContext context; + private static String HG_STIP_SAVE_BUNDLE = "saving bundle to "; + + public StripAction(String name, VCSContext context) { + this.context = context; + putValue(Action.NAME, name); + } + + public void performAction(ActionEvent e) { + strip(context); + } + + public static void strip(final VCSContext ctx){ + final File root = HgUtils.getRootFile(ctx); + if (root == null) return; + String repository = root.getAbsolutePath(); + + String rev = null; + + final Strip strip = new Strip(root); + if (!strip.showDialog()) { + return; + } + rev = strip.getSelectionRevision(); + final boolean doBackup = strip.isBackupRequested(); + final String revStr = rev; + + RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(repository); + HgProgressSupport support = new HgProgressSupport() { + public void perform() { + + try { + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(StripAction.class, + "MSG_STRIP_TITLE")); // NOI18N + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(StripAction.class, + "MSG_STRIP_TITLE_SEP")); // NOI18N + HgUtils.outputMercurialTab( + NbBundle.getMessage(StripAction.class, + "MSG_STRIP_INFO_SEP", revStr, root.getAbsolutePath())); // NOI18N + List list = HgCommand.doStrip(root, revStr, false, doBackup); + + if(list != null && !list.isEmpty()){ + HgUtils.outputMercurialTab(list); + + if(HgCommand.isNoRevStrip(list.get(0))){ + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(StripAction.class, + "MSG_NO_REV_STRIP",revStr)); // NOI18N + }else if(HgCommand.isLocalChangesStrip(list.get(0))){ + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(StripAction.class, + "MSG_LOCAL_CHANGES_STRIP")); // NOI18N + }else if(HgCommand.isMultipleHeadsStrip(list.get(0))){ + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(StripAction.class, + "MSG_MULTI_HEADS_STRIP")); // NOI18N + }else{ + if (HgCommand.hasHistory(root)) { + FileStatusCache cache = Mercurial.getInstance().getFileStatusCache(); + if (cache.listFiles(ctx, FileInformation.STATUS_VERSIONED_CONFLICT).length != 0) { + ConflictResolvedAction.resolved(ctx); + } + HgUtils.forceStatusRefreshProject(ctx); + Mercurial.getInstance().changesetChanged(root); + } + String savingTo = list.get(list.size()-1); + savingTo = savingTo != null? savingTo.substring(HG_STIP_SAVE_BUNDLE.length()): null; + File savingFile = new File(savingTo); + if(savingFile != null && savingFile.exists() && savingFile.canRead()){ + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(StripAction.class, + "MSG_STRIP_RESTORE_INFO")); // NOI18N + HgUtils.outputMercurialTab( + NbBundle.getMessage(StripAction.class, + "MSG_STRIP_RESTORE_INFO2", savingFile.getAbsoluteFile())); // NOI18N + } + } + } + } catch (HgException ex) { + NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); + DialogDisplayer.getDefault().notifyLater(e); + } finally { + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(StripAction.class, + "MSG_STRIP_DONE")); // NOI18N + HgUtils.outputMercurialTab(""); // NOI18N + } + } + }; + support.start(rp, repository,org.openide.util.NbBundle.getMessage(StripAction.class, "MSG_STRIP_PROGRESS")); // NOI18N + } + + public boolean isEnabled() { + return HgUtils.getRootFile(context) != null; + } +} diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/rollback/StripPanel.form --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/StripPanel.form Wed Feb 20 14:45:50 2008 +0000 @@ -0,0 +1,183 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/rollback/StripPanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/rollback/StripPanel.java Wed Feb 20 14:45:50 2008 +0000 @@ -0,0 +1,276 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package org.netbeans.modules.mercurial.ui.rollback; + +import java.io.File; +import java.util.Set; +import java.util.Vector; +import java.util.LinkedHashSet; +import javax.swing.SwingUtilities; +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import org.netbeans.api.progress.ProgressHandleFactory; +import org.netbeans.api.progress.ProgressHandle; +import org.openide.util.RequestProcessor; +import org.openide.util.NbBundle; +import org.netbeans.modules.mercurial.util.HgCommand; + +/** + * + * @author Padraig O'Briain + */ +public class StripPanel extends javax.swing.JPanel { + + private File repository; + private RequestProcessor.Task refreshViewTask; + private static final RequestProcessor rp = new RequestProcessor("MercurialStrip", 1); // NOI18N + private Thread refreshViewThread; + + private static final int HG_STRIP_TARGET_LIMIT = 100; + + /** Creates new form ReverModificationsPanel */ + public StripPanel(File repo) { + repository = repo; + refreshViewTask = rp.create(new RefreshViewTask()); + initComponents(); + refreshViewTask.schedule(0); + } + + public String getSelectedRevision() { + String revStr = (String) revisionsComboBox.getSelectedItem(); + if(revStr != null){ + if (revStr.equals(NbBundle.getMessage(StripPanel.class, "MSG_Revision_Default")) || // NOI18N + revStr.equals(NbBundle.getMessage(StripPanel.class, "MSG_Fetching_Revisions"))) { // NOI18N + revStr = null; + } else { + revStr = revStr.substring(0, revStr.indexOf(" ")); // NOI18N + } + } + return revStr; + } + + public boolean isBackupRequested() { + return doBackupChxBox.isSelected(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + jPanel2 = new javax.swing.JPanel(); + doForcedMultiHeadStripChxBox = new javax.swing.JCheckBox(); + revisionsLabel = new javax.swing.JLabel(); + revisionsComboBox = new javax.swing.JComboBox(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jPanel1 = new javax.swing.JPanel(); + doBackupChxBox = new javax.swing.JCheckBox(); + jPanel3 = new javax.swing.JPanel(); + + org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(0, 100, Short.MAX_VALUE) + ); + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(0, 100, Short.MAX_VALUE) + ); + + org.openide.awt.Mnemonics.setLocalizedText(doForcedMultiHeadStripChxBox, org.openide.util.NbBundle.getMessage(StripPanel.class, "StripPanel.doForcedMultiHeadStripChxBox.text")); // NOI18N + + revisionsLabel.setLabelFor(revisionsComboBox); + org.openide.awt.Mnemonics.setLocalizedText(revisionsLabel, org.openide.util.NbBundle.getMessage(StripPanel.class, "StripPanel.revisionsLabel.text")); // NOI18N + + jLabel1.setFont(new java.awt.Font("Dialog", 1, 11)); + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(StripPanel.class, "StripPanel.infoLabel.text")); // NOI18N + + jLabel2.setForeground(new java.awt.Color(153, 153, 153)); + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(StripPanel.class, "StripPanel.infoLabel2.text")); // NOI18N + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(StripPanel.class, "StripPanel.jPanel1.border.title"))); // NOI18N + + doBackupChxBox.setSelected(true); + org.openide.awt.Mnemonics.setLocalizedText(doBackupChxBox, org.openide.util.NbBundle.getMessage(StripPanel.class, "StripPanel.doBackupChxBox.text")); // NOI18N + + org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .add(doBackupChxBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 327, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap(6, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .add(doBackupChxBox) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(0, 0, Short.MAX_VALUE) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(0, 165, Short.MAX_VALUE) + ); + + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .addContainerGap() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 357, Short.MAX_VALUE) + .add(layout.createSequentialGroup() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1, 0, 357, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() + .add(35, 35, 35) + .add(revisionsLabel) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(revisionsComboBox, 0, 177, Short.MAX_VALUE)) + .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))) + .add(15, 15, 15) + .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(4, 4, 4) + .add(jLabel2) + .add(30, 30, 30) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(revisionsLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(revisionsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + + /** + * Must NOT be run from AWT. + */ + private void setupModels() { + // XXX attach Cancelable hook + final ProgressHandle ph = ProgressHandleFactory.createHandle(NbBundle.getMessage(StripPanel.class, "MSG_Refreshing_Strip_Versions")); // NOI18N + try { + Set initialRevsSet = new LinkedHashSet(); + initialRevsSet.add(NbBundle.getMessage(StripPanel.class, "MSG_Fetching_Revisions")); // NOI18N + ComboBoxModel targetsModel = new DefaultComboBoxModel(new Vector(initialRevsSet)); + revisionsComboBox.setModel(targetsModel); + refreshViewThread = Thread.currentThread(); + Thread.interrupted(); // clear interupted status + ph.start(); + + refreshRevisions(); + } finally { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + ph.finish(); + refreshViewThread = null; + } + }); + } + } + + private void refreshRevisions() { + java.util.List targetRevsList = HgCommand.getRevisions(repository, HG_STRIP_TARGET_LIMIT); + + Set targetRevsSet = new LinkedHashSet(); + + int size; + if( targetRevsList == null){ + size = 0; + targetRevsSet.add(NbBundle.getMessage(StripPanel.class, "MSG_Revision_Default")); // NOI18N + }else{ + size = targetRevsList.size(); + int i = 0 ; + while(i < size){ + targetRevsSet.add(targetRevsList.get(i)); + i++; + } + } + ComboBoxModel targetsModel = new DefaultComboBoxModel(new Vector(targetRevsSet)); + revisionsComboBox.setModel(targetsModel); + + if (targetRevsSet.size() > 0 ) { + revisionsComboBox.setSelectedIndex(0); + } + } + + private class RefreshViewTask implements Runnable { + public void run() { + setupModels(); + } + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBox doBackupChxBox; + private javax.swing.JCheckBox doForcedMultiHeadStripChxBox; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JComboBox revisionsComboBox; + private javax.swing.JLabel revisionsLabel; + // End of variables declaration//GEN-END:variables + +} diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/status/VersioningPanel.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/status/VersioningPanel.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/status/VersioningPanel.java Wed Feb 20 14:45:50 2008 +0000 @@ -367,7 +367,7 @@ class VersioningPanel extends JPanel imp * Performs the "cvs update" command on all diplayed roots. // NOI18N */ private void onUpdateAction() { - UpdateAction.update(context, null); + UpdateAction.update(context); parentTopComponent.contentRefreshed(); } diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/update/Bundle.properties --- a/mercurial/src/org/netbeans/modules/mercurial/ui/update/Bundle.properties Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/update/Bundle.properties Wed Feb 20 14:45:50 2008 +0000 @@ -55,10 +55,18 @@ MSG_Update_Progress=Updating... MSG_Update_Progress=Updating... MSG_Revert_Progress=Reverting... -#~ +CTL_UpdateForm_Action_Update=&Update +ACSD_UpdateForm_Action_Update=Update +ACSN_UpdateForm_Action_Update=Update +CTL_UpdateForm_Action_Cancel=&Cancel +ACSD_UpdateForm_Action_Cancel=Cancel +ACSN_UpdateForm_Action_Cancel=Cancel +CTL_UpdateDialog=Update - {0} +ACSD_UpdateDialog=Update - {0} MSG_UPDATE_TITLE = Mercurial Update MSG_UPDATE_TITLE_SEP = ---------------- +MSG_UPDATE_INFO_SEP = Update to revision {0} in:\n{1} MSG_UPDATE_DONE = INFO: End of Update MSG_REVERT_TITLE = Mercurial Revert @@ -69,8 +77,17 @@ MSG_REVERT_NOTHING = Nothing yet comitte MSG_Refreshing_Revert_Versions = Refreshing Revert Versions MSG_Revision_Default = - +MSG_Fetching_Revisions = Fetching Revisions... +MSG_Refreshing_Update_Versions = Refreshing Update Versions MSG_ConflictResolved_Progress = Marking resolved... -RevertModificationsPanel.revisionsLabel.text=Choose from &Modified Revisions: -MSG_Fetching_Revisions = Fetching Revisions... +RevertModificationsPanel.revisionsLabel.text=Choose from &Revisions: +RevertModificationsPanel.infoLabel.text=Revert selected files to their state in the chosen revision +RevertModificationsPanel.infoLabel2.text=(only modifies the working directory, not the repository) + +UpdatePanel.revisionsLabel.text=Choose from &Revisions: +UpdatePanel.infoLabel.text=Update files in the working directory to the selected revision +UpdatePanel.infoLabel2.text=(set parent of the working dir to this revision in the repository) +UpdatePanel.forcedUpdateChxBox.text=Do a Forced Update - any local changes will be lost! +UpdatePanel.jPanel1.border.title=Options +RevertModificationsPanel.doBackupChxBox.text=Back up any Locally Modified files to .orig diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModifications.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModifications.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModifications.java Wed Feb 20 14:45:50 2008 +0000 @@ -41,18 +41,11 @@ package org.netbeans.modules.mercurial.u package org.netbeans.modules.mercurial.ui.update; import java.awt.Dialog; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.net.MalformedURLException; import javax.swing.JButton; -import javax.swing.JRadioButton; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; import org.openide.DialogDescriptor; import org.openide.DialogDisplayer; -import org.openide.ErrorManager; import org.openide.util.HelpCtx; import java.io.File; @@ -120,4 +113,10 @@ public class RevertModifications impleme if (panel == null) return null; return panel.getSelectedRevision(); } + + public boolean isBackupRequested() { + if (panel == null) return false; + return panel.isBackupRequested(); + } + } diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModificationsAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModificationsAction.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModificationsAction.java Wed Feb 20 14:45:50 2008 +0000 @@ -60,7 +60,6 @@ import org.netbeans.modules.mercurial.ut import org.netbeans.modules.mercurial.util.HgCommand; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; -import org.netbeans.modules.mercurial.util.HgRepositoryContextCache; /** * Reverts local changes. @@ -92,11 +91,12 @@ public class RevertModificationsAction e } rev = revertModifications.getSelectionRevision(); final String revStr = rev; + final boolean doBackup = revertModifications.isBackupRequested(); RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(repository); HgProgressSupport support = new HgProgressSupport() { public void perform() { - performRevert(repository, revStr, files); + performRevert(repository, revStr, files, doBackup); } }; support.start(rp, repository.getAbsolutePath(), org.openide.util.NbBundle.getMessage(UpdateAction.class, "MSG_Revert_Progress")); // NOI18N @@ -104,22 +104,22 @@ public class RevertModificationsAction e return; } - public static void performRevert(File repository, String revStr, File file) { + public static void performRevert(File repository, String revStr, File file, boolean doBackup) { List revertFiles = new ArrayList(); revertFiles.add(file); - performRevert(repository, revStr, revertFiles); + performRevert(repository, revStr, revertFiles, doBackup); } - public static void performRevert(File repository, String revStr, File[] files) { + public static void performRevert(File repository, String revStr, File[] files, boolean doBackup) { List revertFiles = new ArrayList(); for (File file : files) { revertFiles.add(file); } - performRevert(repository, revStr, revertFiles); + performRevert(repository, revStr, revertFiles, doBackup); } - public static void performRevert(File repository, String revStr, List revertFiles) { + public static void performRevert(File repository, String revStr, List revertFiles, boolean doBackup) { try{ HgUtils.outputMercurialTabInRed( NbBundle.getMessage(RevertModificationsAction.class, @@ -149,7 +149,7 @@ public class RevertModificationsAction e } HgUtils.outputMercurialTab(""); // NOI18N - HgCommand.doRevert(repository, revertFiles, revStr); + HgCommand.doRevert(repository, revertFiles, revStr, doBackup); FileStatusCache cache = Mercurial.getInstance().getFileStatusCache(); File[] conflictFiles = cache.listFiles(revertFiles.toArray(new File[0]), FileInformation.STATUS_VERSIONED_CONFLICT); if (conflictFiles.length != 0) { diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModificationsPanel.form --- a/mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModificationsPanel.form Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModificationsPanel.form Wed Feb 20 14:45:50 2008 +0000 @@ -15,11 +15,23 @@ - - - - - + + + + + + + + + + + + + + + + + @@ -27,12 +39,17 @@ - + + + + + - - + + + @@ -55,5 +72,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModificationsPanel.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModificationsPanel.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/update/RevertModificationsPanel.java Wed Feb 20 14:45:50 2008 +0000 @@ -49,6 +49,7 @@ import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultComboBoxModel; import org.netbeans.api.progress.ProgressHandleFactory; import org.netbeans.api.progress.ProgressHandle; +import org.netbeans.modules.mercurial.HgModuleConfig; import org.openide.util.RequestProcessor; import org.openide.util.NbBundle; import org.netbeans.modules.mercurial.util.HgCommand; @@ -79,11 +80,16 @@ public class RevertModificationsPanel ex public File[] getRevertFiles() { return revertFiles; } + + public boolean isBackupRequested() { + return doBackupChxBox.isSelected(); + } public String getSelectedRevision() { String revStr = (String) revisionsComboBox.getSelectedItem(); if(revStr != null){ - if (revStr.equals(NbBundle.getMessage(RevertModificationsPanel.class, "MSG_Revision_Default"))) { // NOI18N + if (revStr.equals(NbBundle.getMessage(RevertModificationsPanel.class, "MSG_Revision_Default")) || // NOI18N + revStr.equals(NbBundle.getMessage(RevertModificationsPanel.class, "MSG_Fetching_Revisions"))) { // NOI18N revStr = null; } else { revStr = revStr.substring(0, revStr.indexOf(" ")); // NOI18N @@ -102,29 +108,72 @@ public class RevertModificationsPanel ex revisionsLabel = new javax.swing.JLabel(); revisionsComboBox = new javax.swing.JComboBox(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jPanel1 = new javax.swing.JPanel(); + doBackupChxBox = new javax.swing.JCheckBox(); revisionsLabel.setLabelFor(revisionsComboBox); org.openide.awt.Mnemonics.setLocalizedText(revisionsLabel, org.openide.util.NbBundle.getMessage(RevertModificationsPanel.class, "RevertModificationsPanel.revisionsLabel.text")); // NOI18N + + jLabel1.setFont(new java.awt.Font("Dialog", 1, 11)); // NOI18N + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(RevertModificationsPanel.class, "RevertModificationsPanel.infoLabel.text")); // NOI18N + + jLabel2.setForeground(new java.awt.Color(153, 153, 153)); + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(RevertModificationsPanel.class, "RevertModificationsPanel.infoLabel2.text")); // NOI18N + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Options")); + + org.openide.awt.Mnemonics.setLocalizedText(doBackupChxBox, org.openide.util.NbBundle.getMessage(RevertModificationsPanel.class, "RevertModificationsPanel.doBackupChxBox.text")); // NOI18N + + org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .add(doBackupChxBox) + .addContainerGap(57, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .add(doBackupChxBox) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() - .add(22, 22, 22) - .add(revisionsLabel) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 51, Short.MAX_VALUE) - .add(revisionsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 147, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(layout.createSequentialGroup() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() + .add(47, 47, 47) + .add(revisionsLabel) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(revisionsComboBox, 0, 176, Short.MAX_VALUE)) + .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() + .addContainerGap() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jLabel2) + .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE) + .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() - .add(27, 27, 27) + .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(4, 4, 4) + .add(jLabel2) + .add(29, 29, 29) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) - .add(revisionsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .add(revisionsLabel)) - .addContainerGap(42, Short.MAX_VALUE)) + .add(revisionsLabel) + .add(revisionsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); }// //GEN-END:initComponents @@ -136,6 +185,9 @@ public class RevertModificationsPanel ex // XXX attach Cancelable hook final ProgressHandle ph = ProgressHandleFactory.createHandle(NbBundle.getMessage(RevertModificationsPanel.class, "MSG_Refreshing_Revert_Versions")); // NOI18N try { + boolean doBackup = HgModuleConfig.getDefault().getBackupOnRevertModifications(); + doBackupChxBox.setSelected(doBackup); + Set initialRevsSet = new LinkedHashSet(); initialRevsSet.add(NbBundle.getMessage(RevertModificationsPanel.class, "MSG_Fetching_Revisions")); // NOI18N ComboBoxModel targetsModel = new DefaultComboBoxModel(new Vector(initialRevsSet)); @@ -187,6 +239,10 @@ public class RevertModificationsPanel ex } // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBox doBackupChxBox; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JPanel jPanel1; private javax.swing.JComboBox revisionsComboBox; private javax.swing.JLabel revisionsLabel; // End of variables declaration//GEN-END:variables diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/update/Update.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/update/Update.java Wed Feb 20 14:45:50 2008 +0000 @@ -0,0 +1,113 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package org.netbeans.modules.mercurial.ui.update; + +import java.awt.Dialog; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import javax.swing.JButton; +import org.openide.DialogDescriptor; +import org.openide.DialogDisplayer; +import org.openide.util.HelpCtx; +import java.io.File; + +/** + * + * @author Padraig O'Briain + */ +public class Update implements PropertyChangeListener { + + private UpdatePanel panel; + private JButton okButton; + private JButton cancelButton; + private File repository; + + /** Creates a new instance of Update */ + public Update(File repository) { + this (repository, null); + } + + public Update(File repository, String defaultRevision) { + this.repository = repository; + panel = new UpdatePanel(repository); + okButton = new JButton(); + org.openide.awt.Mnemonics.setLocalizedText(okButton, org.openide.util.NbBundle.getMessage(RevertModifications.class, "CTL_UpdateForm_Action_Update")); // NOI18N + okButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(RevertModifications.class, "ACSD_UpdateForm_Action_Update")); // NOI18N + okButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(RevertModifications.class, "ACSN_UpdateForm_Action_Update")); // NOI18N + cancelButton = new JButton(); + org.openide.awt.Mnemonics.setLocalizedText(cancelButton, org.openide.util.NbBundle.getMessage(RevertModifications.class, "CTL_UpdateForm_Action_Cancel")); // NOI18N + cancelButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(RevertModifications.class, "ACSD_UpdateForm_Action_Cancel")); // NOI18N + cancelButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(RevertModifications.class, "ACSN_UpdateForm_Action_Cancel")); // NOI18N + } + + public boolean showDialog() { + DialogDescriptor dialogDescriptor; + dialogDescriptor = new DialogDescriptor(panel, org.openide.util.NbBundle.getMessage(RevertModifications.class, "CTL_UpdateDialog", repository.getName())); // NOI18N + dialogDescriptor.setOptions(new Object[] {okButton, cancelButton}); + + dialogDescriptor.setModal(true); + dialogDescriptor.setHelpCtx(new HelpCtx(this.getClass())); + dialogDescriptor.setValid(false); + + Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor); + dialog.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(RevertModifications.class, "ACSD_UpdateDialog", repository.getName())); // NOI18N + dialog.setVisible(true); + dialog.setResizable(false); + boolean ret = dialogDescriptor.getValue() == okButton; + return ret; + } + + public void propertyChange(PropertyChangeEvent evt) { + if(okButton != null) { + boolean valid = ((Boolean)evt.getNewValue()).booleanValue(); + okButton.setEnabled(valid); + } + } + + public String getSelectionRevision() { + if (panel == null) return null; + return panel.getSelectedRevision(); + } + public boolean isForcedUpdateRequested() { + if (panel == null) return false; + return panel.isForcedUpdateRequested(); + } +} diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/update/UpdateAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/update/UpdateAction.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/update/UpdateAction.java Wed Feb 20 14:45:50 2008 +0000 @@ -74,13 +74,22 @@ public class UpdateAction extends Contex } public void performAction(ActionEvent e) { - update(context, null); + update(context); } - public static void update(final VCSContext ctx, final String revision){ + public static void update(final VCSContext ctx){ final File root = HgUtils.getRootFile(ctx); if (root == null) return; String repository = root.getAbsolutePath(); + String rev = null; + + final Update update = new Update(root); + if (!update.showDialog()) { + return; + } + rev = update.getSelectionRevision(); + final boolean doForcedUpdate = update.isForcedUpdateRequested(); + final String revStr = rev; RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(repository); HgProgressSupport support = new HgProgressSupport() { @@ -93,7 +102,10 @@ public class UpdateAction extends Contex HgUtils.outputMercurialTabInRed( NbBundle.getMessage(UpdateAction.class, "MSG_UPDATE_TITLE_SEP")); // NOI18N - List list = HgCommand.doUpdateAll(root, false, revision); + HgUtils.outputMercurialTab( + NbBundle.getMessage(UpdateAction.class, + "MSG_UPDATE_INFO_SEP", revStr, root.getAbsolutePath())); // NOI18N + List list = HgCommand.doUpdateAll(root, doForcedUpdate, revStr); if (list != null && !list.isEmpty()){ bNoUpdates = HgCommand.isNoUpdates(list.get(0)); @@ -120,6 +132,7 @@ public class UpdateAction extends Contex HgUtils.outputMercurialTabInRed( NbBundle.getMessage(UpdateAction.class, "MSG_UPDATE_DONE")); // NOI18N + HgUtils.outputMercurialTab(""); // NOI18N } }; support.start(rp, repository, org.openide.util.NbBundle.getMessage(UpdateAction.class, "MSG_Update_Progress")); // NOI18N diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/update/UpdatePanel.form --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/update/UpdatePanel.form Wed Feb 20 14:45:50 2008 +0000 @@ -0,0 +1,132 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/ui/update/UpdatePanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/update/UpdatePanel.java Wed Feb 20 14:45:50 2008 +0000 @@ -0,0 +1,238 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common + * Development and Distribution License("CDDL") (collectively, the + * "License"). You may not use this file except in compliance with the + * License. You can obtain a copy of the License at + * http://www.netbeans.org/cddl-gplv2.html + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the + * specific language governing permissions and limitations under the + * License. When distributing the software, include this License Header + * Notice in each file and include the License file at + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the GPL Version 2 section of the License file that + * accompanied this code. If applicable, add the following below the + * License Header, with the fields enclosed by brackets [] replaced by + * your own identifying information: + * "Portions Copyrighted [year] [name of copyright owner]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun + * Microsystems, Inc. All Rights Reserved. + * + * If you wish your version of this file to be governed by only the CDDL + * or only the GPL Version 2, indicate your decision by adding + * "[Contributor] elects to include this software in this distribution + * under the [CDDL or GPL Version 2] license." If you do not indicate a + * single choice of license, a recipient has the option to distribute + * your version of this file under either the CDDL, the GPL Version 2 or + * to extend the choice of license to its licensees as provided above. + * However, if you add GPL Version 2 code and therefore, elected the GPL + * Version 2 license, then the option applies only if the new code is + * made subject to such option by the copyright holder. + */ +package org.netbeans.modules.mercurial.ui.update; + +import java.io.File; +import java.util.Set; +import java.util.Vector; +import java.util.LinkedHashSet; +import javax.swing.SwingUtilities; +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import org.netbeans.api.progress.ProgressHandleFactory; +import org.netbeans.api.progress.ProgressHandle; +import org.openide.util.RequestProcessor; +import org.openide.util.NbBundle; +import org.netbeans.modules.mercurial.util.HgCommand; + +/** + * + * @author Padraig O'Briain + */ +public class UpdatePanel extends javax.swing.JPanel { + + private File repository; + private RequestProcessor.Task refreshViewTask; + private static final RequestProcessor rp = new RequestProcessor("MercurialUpdate", 1); // NOI18N + private Thread refreshViewThread; + + private static final int HG_REVERT_TARGET_LIMIT = 100; + + /** Creates new form ReverModificationsPanel */ + public UpdatePanel(File repo) { + repository = repo; + refreshViewTask = rp.create(new RefreshViewTask()); + initComponents(); + refreshViewTask.schedule(0); + } + + public String getSelectedRevision() { + String revStr = (String) revisionsComboBox.getSelectedItem(); + if(revStr != null){ + if (revStr.equals(NbBundle.getMessage(RevertModificationsPanel.class, "MSG_Revision_Default")) || // NOI18N + revStr.equals(NbBundle.getMessage(RevertModificationsPanel.class, "MSG_Fetching_Revisions"))) { // NOI18N + revStr = null; + } else { + revStr = revStr.substring(0, revStr.indexOf(" ")); // NOI18N + } + } + return revStr; + } + + public boolean isForcedUpdateRequested() { + return forcedUpdateChxBox.isSelected(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + revisionsLabel = new javax.swing.JLabel(); + revisionsComboBox = new javax.swing.JComboBox(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jPanel1 = new javax.swing.JPanel(); + forcedUpdateChxBox = new javax.swing.JCheckBox(); + + revisionsLabel.setLabelFor(revisionsComboBox); + org.openide.awt.Mnemonics.setLocalizedText(revisionsLabel, org.openide.util.NbBundle.getMessage(UpdatePanel.class, "UpdatePanel.revisionsLabel.text")); // NOI18N + + jLabel1.setFont(new java.awt.Font("Dialog", 1, 11)); + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(UpdatePanel.class, "UpdatePanel.infoLabel.text")); // NOI18N + + jLabel2.setForeground(new java.awt.Color(153, 153, 153)); + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(UpdatePanel.class, "UpdatePanel.infoLabel2.text")); // NOI18N + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(UpdatePanel.class, "UpdatePanel.jPanel1.border.title"))); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(forcedUpdateChxBox, org.openide.util.NbBundle.getMessage(UpdatePanel.class, "UpdatePanel.forcedUpdateChxBox.text")); // NOI18N + + org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .add(forcedUpdateChxBox) + .addContainerGap(25, Short.MAX_VALUE)) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .add(forcedUpdateChxBox) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .addContainerGap() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(jLabel2) + .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 355, Short.MAX_VALUE) + .add(layout.createSequentialGroup() + .add(36, 36, 36) + .add(revisionsLabel) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(revisionsComboBox, 0, 174, Short.MAX_VALUE))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(layout.createSequentialGroup() + .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(4, 4, 4) + .add(jLabel2) + .add(29, 29, 29) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(revisionsLabel) + .add(revisionsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 16, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap(15, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + + /** + * Must NOT be run from AWT. + */ + private void setupModels() { + // XXX attach Cancelable hook + final ProgressHandle ph = ProgressHandleFactory.createHandle(NbBundle.getMessage(RevertModificationsPanel.class, "MSG_Refreshing_Update_Versions")); // NOI18N + try { + Set initialRevsSet = new LinkedHashSet(); + initialRevsSet.add(NbBundle.getMessage(RevertModificationsPanel.class, "MSG_Fetching_Revisions")); // NOI18N + ComboBoxModel targetsModel = new DefaultComboBoxModel(new Vector(initialRevsSet)); + revisionsComboBox.setModel(targetsModel); + refreshViewThread = Thread.currentThread(); + Thread.interrupted(); // clear interupted status + ph.start(); + + refreshRevisions(); + } finally { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + ph.finish(); + refreshViewThread = null; + } + }); + } + } + + private void refreshRevisions() { + java.util.List targetRevsList = HgCommand.getRevisions(repository, HG_REVERT_TARGET_LIMIT); + + Set targetRevsSet = new LinkedHashSet(); + + int size; + if( targetRevsList == null){ + size = 0; + targetRevsSet.add(NbBundle.getMessage(RevertModificationsPanel.class, "MSG_Revision_Default")); // NOI18N + }else{ + size = targetRevsList.size(); + int i = 0 ; + while(i < size){ + targetRevsSet.add(targetRevsList.get(i)); + i++; + } + } + ComboBoxModel targetsModel = new DefaultComboBoxModel(new Vector(targetRevsSet)); + revisionsComboBox.setModel(targetsModel); + + if (targetRevsSet.size() > 0 ) { + revisionsComboBox.setSelectedIndex(0); + } + } + + private class RefreshViewTask implements Runnable { + public void run() { + setupModels(); + } + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JCheckBox forcedUpdateChxBox; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JPanel jPanel1; + private javax.swing.JComboBox revisionsComboBox; + private javax.swing.JLabel revisionsLabel; + // End of variables declaration//GEN-END:variables + +} diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/util/Bundle.properties --- a/mercurial/src/org/netbeans/modules/mercurial/util/Bundle.properties Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/util/Bundle.properties Wed Feb 20 14:45:50 2008 +0000 @@ -46,6 +46,8 @@ MSG_COMMAND_ABORTED = Command failed\n\n MSG_COMMAND_ABORTED = Command failed\n\nSee Output Window for further details MSG_COMMAND_CANCELLED = Command has been cancelled MSG_ROLLBACK_FAILED = Rollback command has failed\n\nSee Output Window for further details +MSG_STRIP_FAILED = Strip command has failed\n\nSee Output Window for further details +MSG_BACKOUT_FAILED = Backout command has failed\n\nSee Output Window for further details MSG_CREATE_FAILED = Create command has failed\n\nSee Output Window for further details MSG_NO_REPOSITORY_ERR = Mercurial repository could not be found MSG_NO_RESPONSE_ERR = no suitable response from remote hg! @@ -57,6 +59,8 @@ MSG_EXPORT_FAILED = Export command has f MSG_EXPORT_FAILED = Export command has failed\n\nSee Output Window for further details MSG_IMPORT_FAILED = Import command has failed\n\nSee Output Window for further details MSG_UNABLE_TO_CREATE_PARENT_DIR = Unable to create parent directory\n\nSee Output Window for further details + +MSG_BACKOUT_MERGE_COMMIT_MSG = Automated backout of revision {0} MSG_COMMAND_ERR = ERROR Command failed: MSG_COMMAND_INFO_ERR = Command: {0}\nOutput: {1} diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java --- a/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java Wed Feb 20 14:45:50 2008 +0000 @@ -42,8 +42,6 @@ package org.netbeans.modules.mercurial.u package org.netbeans.modules.mercurial.util; import java.awt.EventQueue; -import java.awt.EventQueue; -import java.awt.EventQueue; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileWriter; @@ -63,7 +61,6 @@ import java.util.Set; import java.util.Set; import java.util.logging.Level; import org.netbeans.api.options.OptionsDisplayer; -import org.netbeans.modules.mercurial.ui.log.HgLogMessage; import org.openide.util.NbBundle; import org.netbeans.modules.mercurial.FileInformation; import org.netbeans.modules.mercurial.FileStatus; @@ -72,7 +69,6 @@ import org.netbeans.api.queries.Sharabil import org.netbeans.api.queries.SharabilityQuery; import org.netbeans.modules.mercurial.HgModuleConfig; import org.netbeans.modules.mercurial.config.HgConfigFiles; -import org.netbeans.modules.mercurial.ui.log.HgLogMessage; import org.netbeans.modules.mercurial.ui.log.HgLogMessage; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; @@ -198,6 +194,16 @@ public class HgCommand { private static final String HG_PUSH_CMD = "push"; // NOI18N private static final String HG_UNBUNDLE_CMD = "unbundle"; // NOI18N private static final String HG_ROLLBACK_CMD = "rollback"; // NOI18N + private static final String HG_BACKOUT_CMD = "backout"; // NOI18N + private static final String HG_BACKOUT_MERGE_CMD = "--merge"; // NOI18N + private static final String HG_BACKOUT_COMMIT_MSG_CMD = "-m"; // NOI18N + private static final String HG_BACKOUT_REV_CMD = "-r"; // NOI18N + + private static final String HG_STRIP_CMD = "strip"; // NOI18N + private static final String HG_STRIP_EXT_CMD = "extensions.mq="; // NOI18N + private static final String HG_STRIP_NOBACKUP_CMD = "-n"; // NOI18N + private static final String HG_STRIP_FORCE_MULTIHEAD_CMD = "-f"; // NOI18N + private static final String HG_VERSION_CMD = "version"; // NOI18N private static final String HG_INCOMING_CMD = "incoming"; // NOI18N private static final String HG_OUTGOING_CMD = "outgoing"; // NOI18N @@ -241,6 +247,9 @@ public class HgCommand { private static final String HG_ABORT_NO_DEFAULT_PUSH_ERR = "abort: repository default-push not found!"; // NOI18N private static final String HG_ABORT_NO_DEFAULT_ERR = "abort: repository default not found!"; // NOI18N private static final String HG_ABORT_POSSIBLE_PROXY_ERR = "abort: error: node name or service name not known"; // NOI18N + private static final String HG_ABORT_UNCOMMITTED_CHANGES_ERR = "abort: outstanding uncommitted changes"; // NOI18N + private static final String HG_BACKOUT_MERGE_NEEDED_ERR = "(use \"backout --merge\" if you want to auto-merge)"; + private static final String HG_ABORT_BACKOUT_MERGE_CSET_ERR = "abort: cannot back out a merge changeset without --parent"; // NOI18N" private static final String HG_NO_CHANGE_NEEDED_ERR = "no change needed"; // NOI18N private static final String HG_NO_ROLLBACK_ERR = "no rollback information available"; // NOI18N @@ -248,7 +257,11 @@ public class HgCommand { private static final String HG_NO_VIEW_ERR = "hg: unknown command 'view'"; // NOI18N private static final String HG_HGK_NOT_FOUND_ERR = "sh: hgk: not found"; // NOI18N private static final String HG_NO_SUCH_FILE_ERR = "No such file"; // NOI18N - + + private static final String HG_NO_REV_STRIP_ERR = "abort: unknown revision"; // NOI18N + private static final String HG_LOCAL_CHANGES_STRIP_ERR = "abort: local changes found"; // NOI18N + private static final String HG_MULTIPLE_HEADS_STRIP_ERR = "no rollback information available"; // NOI18N + private static final char HG_STATUS_CODE_MODIFIED = 'M' + ' '; // NOI18N // STATUS_VERSIONED_MODIFIEDLOCALLY private static final char HG_STATUS_CODE_ADDED = 'A' + ' '; // NOI18N // STATUS_VERSIONED_ADDEDLOCALLY private static final char HG_STATUS_CODE_REMOVED = 'R' + ' '; // NOI18N // STATUS_VERSIONED_REMOVEDLOCALLY - still tracked, hg update will recover, hg commit @@ -363,7 +376,74 @@ public class HgCommand { return list; } + public static List doBackout(File repository, String revision, + boolean doMerge, String commitMsg) throws HgException { + if (repository == null ) return null; + List env = new ArrayList(); + List command = new ArrayList(); + + command.add(getHgCommand()); + command.add(HG_BACKOUT_CMD); + if(doMerge){ + command.add(HG_BACKOUT_MERGE_CMD); + env.add(HG_MERGE_ENV); + } + + if (commitMsg != null && !commitMsg.equals("")) { // NOI18N + command.add(HG_BACKOUT_COMMIT_MSG_CMD); + command.add(commitMsg); + } else { + command.add(HG_BACKOUT_COMMIT_MSG_CMD); + command.add(NbBundle.getMessage(HgCommand.class, "MSG_BACKOUT_MERGE_COMMIT_MSG", revision)); // NOI18N + } + + command.add(HG_OPT_REPOSITORY); + command.add(repository.getAbsolutePath()); + if (revision != null){ + command.add(HG_BACKOUT_REV_CMD); + command.add(revision); + } + + List list; + if(doMerge){ + list = execEnv(command, env); + }else{ + list = exec(command); + } + if (list.isEmpty()) + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_BACKOUT_FAILED")); + + return list; + } + public static List doStrip(File repository, String revision, + boolean doForceMultiHead, boolean doBackup) throws HgException { + if (repository == null ) return null; + List command = new ArrayList(); + + command.add(getHgCommand()); + command.add(HG_CONFIG_OPTION_CMD); + command.add(HG_STRIP_EXT_CMD); + command.add(HG_STRIP_CMD); + if(doForceMultiHead){ + command.add(HG_STRIP_FORCE_MULTIHEAD_CMD); + } + if(!doBackup){ + command.add(HG_STRIP_NOBACKUP_CMD); + } + command.add(HG_OPT_REPOSITORY); + command.add(repository.getAbsolutePath()); + if (revision != null){ + command.add(revision); + } + + List list = exec(command); + if (list.isEmpty()) + handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_STRIP_FAILED")); + + return list; + } + /** * Return the version of hg, e.g. "0.9.3". // NOI18N * @@ -1608,10 +1688,10 @@ public class HgCommand { * @return void * @throws org.netbeans.modules.mercurial.HgException */ - public static void doRevert(File repository, List revertFiles, String revision) throws HgException { + public static void doRevert(File repository, List revertFiles, + String revision, boolean doBackup) throws HgException { if (repository == null) return; if (revertFiles.size() == 0) return; - boolean doBackup = HgModuleConfig.getDefault().getBackupOnRevertModifications(); List command = new ArrayList(); @@ -2587,6 +2667,10 @@ public class HgCommand { public static boolean isMergeNeededMsg(String msg) { return msg.indexOf(HG_MERGE_NEEDED_ERR) > -1; // NOI18N } + + public static boolean isBackoutMergeNeededMsg(String msg) { + return msg.indexOf(HG_BACKOUT_MERGE_NEEDED_ERR) > -1; // NOI18N + } public static boolean isMergeConflictMsg(String msg) { if(Utilities.isWindows() ) { @@ -2688,6 +2772,21 @@ public class HgCommand { public static boolean isNoRollbackPossible(String msg) { return msg.indexOf(HG_NO_ROLLBACK_ERR) > -1; // NOI18N } + public static boolean isNoRevStrip(String msg) { + return msg.indexOf(HG_NO_REV_STRIP_ERR) > -1; // NOI18N + } + public static boolean isLocalChangesStrip(String msg) { + return msg.indexOf(HG_LOCAL_CHANGES_STRIP_ERR) > -1; // NOI18N + } + public static boolean isMultipleHeadsStrip(String msg) { + return msg.indexOf(HG_MULTIPLE_HEADS_STRIP_ERR) > -1; // NOI18N + } + public static boolean isUncommittedChangesBackout(String msg) { + return msg.indexOf(HG_ABORT_UNCOMMITTED_CHANGES_ERR) > -1; // NOI18N + } + public static boolean isMergeChangesetBackout(String msg) { + return msg.indexOf(HG_ABORT_BACKOUT_MERGE_CSET_ERR) > -1; // NOI18N + } public static boolean isNoUpdates(String msg) { return msg.indexOf(HG_NO_UPDATES_ERR) > -1; // NOI18N diff -r 0aa6e6031fb2 -r 3aef657fdd9c mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java --- a/mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java Mon Feb 18 01:45:51 2008 +0300 +++ b/mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java Wed Feb 20 14:45:50 2008 +0000 @@ -116,11 +116,12 @@ public class HgUtils { // IGNORE SUPPORT HG: following file patterns are added to {Hg repos}/.hgignore and Hg will ignore any files // that match these patterns, reporting "I"status for them // NOI18N - private static final String [] HG_IGNORE_FILES = { "\\.orig$", "\\.orig\\..*$", "\\.chg\\..*$", "\\.rej$"}; // NOI18N + private static final String [] HG_IGNORE_FILES = { "\\.orig$", "\\.orig\\..*$", "\\.chg\\..*$", "\\.rej$", "\\.conflict\\~$"}; // NOI18N private static final String HG_IGNORE_ORIG_FILES = "\\.orig$"; // NOI18N private static final String HG_IGNORE_ORIG_ANY_FILES = "\\.orig\\..*$"; // NOI18N private static final String HG_IGNORE_CHG_ANY_FILES = "\\.chg\\..*$"; // NOI18N private static final String HG_IGNORE_REJ_ANY_FILES = "\\.rej$"; // NOI18N + private static final String HG_IGNORE_CONFLICT_ANY_FILES = "\\.conflict\\~$"; // NOI18N private static final String FILENAME_HGIGNORE = ".hgignore"; // NOI18N @@ -388,7 +389,7 @@ public class HgUtils { } } - private static int HG_NUM_PATTERNS_TO_CHECK = 4; + private static int HG_NUM_PATTERNS_TO_CHECK = 5; private static void addToExistingIgnoredFile(File hgignoreFile) { if(hgignoreFile == null || !hgignoreFile.exists() || !hgignoreFile.canWrite()) return; File tempFile = null; @@ -398,6 +399,7 @@ public class HgUtils { boolean bOrigPresent = false; boolean bChgAnyPresent = false; boolean bRejAnyPresent = false; + boolean bConflictAnyPresent = false; // If new patterns are added to HG_IGNORE_FILES, following code needs to // check for these new patterns @@ -420,6 +422,8 @@ public class HgUtils { bChgAnyPresent = true; }else if (!bRejAnyPresent && line.equals(HG_IGNORE_REJ_ANY_FILES)){ bRejAnyPresent = true; + }else if (!bConflictAnyPresent && line.equals(HG_IGNORE_CONFLICT_ANY_FILES)){ + bConflictAnyPresent = true; } pw.println(line); pw.flush(); @@ -441,6 +445,10 @@ public class HgUtils { pw.println(HG_IGNORE_REJ_ANY_FILES ); pw.flush(); } + if (!bConflictAnyPresent) { + pw.println(HG_IGNORE_CONFLICT_ANY_FILES ); + pw.flush(); + } } catch (IOException ex) { // Ignore @@ -449,7 +457,8 @@ public class HgUtils { if(pw != null) pw.close(); if(br != null) br.close(); - boolean bAnyAdditions = !bOrigAnyPresent || !bOrigPresent || !bChgAnyPresent || !bRejAnyPresent; + boolean bAnyAdditions = !bOrigAnyPresent || !bOrigPresent || + !bChgAnyPresent || !bRejAnyPresent || !bConflictAnyPresent; if(bAnyAdditions){ if (!confirmDialog(HgUtils.class, "MSG_IGNORE_FILES_TITLE", "MSG_IGNORE_FILES")) { // NOI18N tempFile.delete();