# This patch file was generated by NetBeans IDE # This patch can be applied using context Tools: Apply Diff Patch action on respective folder. # It uses platform neutral UTF-8 encoding. # Above lines and this line are ignored by the patching process. Index: versioncontrol/mercurial/src/org/netbeans/modules/mercurial/ui/push/Bundle.properties --- versioncontrol/mercurial/src/org/netbeans/modules/mercurial/ui/push/Bundle.properties Base (1.11) +++ versioncontrol/mercurial/src/org/netbeans/modules/mercurial/ui/push/Bundle.properties Locally Modified (Based On 1.11) @@ -53,6 +53,11 @@ MSG_PUSH_NOT_SUPPORTED_INVIEW_TITLE = Mercurial Push MSG_PUSH_NOT_SUPPORTED_INVIEW = Push is not supported in this View +MSG_PUSH_FORCE_CONFIRM_TITLE = Confirm Forced Push +MSG_PUSH_FORCE_CONFIRM_QUERY = Did you forget to sync and merge? Push will create new remote branches.\n\nDo you still want to do a forced Push? +MSG_PUSH_FORCE_DO = INFO: Performing a forced Push +MSG_PUSH_FORCE_CANCELED = INFO: User canceled forced Push + MSG_NO_DEFAULT_PUSH_SET = No default Push path set for this project.\n\nPlease set a default Push path using Mercurial > Properties. MSG_PUSH_MERGE_CONFIRM_TITLE = Confirm Merge after Push MSG_PUSH_MERGE_CONFIRM_QUERY = Push has completed and Merge is Required.\nMerge the pushed changes now? Index: versioncontrol/mercurial/src/org/netbeans/modules/mercurial/ui/push/PushAction.java --- versioncontrol/mercurial/src/org/netbeans/modules/mercurial/ui/push/PushAction.java Base (1.18) +++ versioncontrol/mercurial/src/org/netbeans/modules/mercurial/ui/push/PushAction.java Locally Modified (Based On 1.18) @@ -143,11 +143,13 @@ HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_TITLE_SEP")); // NOI18N List listOutgoing = HgCommand.doOutgoing(root, pushPath); - if ((listOutgoing == null) || listOutgoing.isEmpty()) return; + if ((listOutgoing == null) || listOutgoing.isEmpty()) { + return; + } - File pushFile = new File (pushPath); + File pushFile = new File(pushPath); boolean bLocalPush = (FileUtil.toFileObject(FileUtil.normalizeFile(pushFile)) != null); - boolean bNoChanges = HgCommand.isNoChanges(listOutgoing.get(listOutgoing.size()-1)); + boolean bNoChanges = HgCommand.isNoChanges(listOutgoing.get(listOutgoing.size() - 1)); if (bLocalPush) { // Warn user if there are local changes which Push will overwrite @@ -161,23 +163,38 @@ List list; if (bNoChanges) { - list= listOutgoing; + list = listOutgoing; } else { - list = HgCommand.doPush(root, pushPath); + list = HgCommand.doPush(root, pushPath, false); } + if (!list.isEmpty() && + HgCommand.isErrorAbortPush(list.get(list.size() - 1))) { + boolean bConfirmForcedPush = HgUtils.confirmDialog(PushAction.class, + "MSG_PUSH_FORCE_CONFIRM_TITLE", "MSG_PUSH_FORCE_CONFIRM_QUERY"); // NOI18N + if (bConfirmForcedPush) { + HgUtils.outputMercurialTabInRed( + NbBundle.getMessage(PushAction.class, + "MSG_PUSH_FORCE_DO")); // NOI18N + list = HgCommand.doPush(root, pushPath, true); + } else { + HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_FORCE_CANCELED")); // NOI18N + return; + } + } + if (list != null && !list.isEmpty()) { - if(!HgCommand.isNoChanges(listOutgoing.get(listOutgoing.size()-1))){ + if (!HgCommand.isNoChanges(listOutgoing.get(listOutgoing.size() - 1))) { InputOutput io = IOProvider.getDefault().getIO(Mercurial.MERCURIAL_OUTPUT_TAB_TITLE, false); io.select(); OutputWriter out = io.getOut(); OutputWriter outRed = io.getErr(); - outRed.println(NbBundle.getMessage(PushAction.class,"MSG_CHANGESETS_TO_PUSH")); // NOI18N - for( String s : listOutgoing){ - if (s.indexOf(Mercurial.CHANGESET_STR) == 0){ + outRed.println(NbBundle.getMessage(PushAction.class, "MSG_CHANGESETS_TO_PUSH")); // NOI18N + for (String s : listOutgoing) { + if (s.indexOf(Mercurial.CHANGESET_STR) == 0) { outRed.println(s); - }else if( !s.equals("")){ // NOI18N + } else if (!s.equals("")) { // NOI18N out.println(s); } } @@ -191,20 +208,20 @@ if (toPrjName == null) { HgUtils.outputMercurialTabInRed( NbBundle.getMessage(PushAction.class, - "MSG_PUSH_TO_NONAME", bLocalPush? HgUtils.stripDoubleSlash(pushPath): pushPath)); // NOI18N + "MSG_PUSH_TO_NONAME", bLocalPush ? HgUtils.stripDoubleSlash(pushPath) : pushPath)); // NOI18N } else { HgUtils.outputMercurialTabInRed( NbBundle.getMessage(PushAction.class, - "MSG_PUSH_TO", toPrjName, bLocalPush? HgUtils.stripDoubleSlash(pushPath): pushPath)); // NOI18N + "MSG_PUSH_TO", toPrjName, bLocalPush ? HgUtils.stripDoubleSlash(pushPath) : pushPath)); // NOI18N } HgUtils.outputMercurialTabInRed( NbBundle.getMessage(PushAction.class, "MSG_PUSH_FROM", fromPrjName, root)); // NOI18N - boolean bMergeNeeded = HgCommand.isHeadsCreated(list.get(list.size()-1)); + boolean bMergeNeeded = HgCommand.isHeadsCreated(list.get(list.size() - 1)); boolean bConfirmMerge = false; // Push does not do an Update of the target Working Dir - if(!bMergeNeeded){ + if (!bMergeNeeded) { if (bNoChanges) { return; } @@ -224,13 +241,13 @@ NbBundle.getMessage(PushAction.class, "MSG_PUSH_UPDATE_DONE_NONAME", HgUtils.stripDoubleSlash(pushPath))); // NOI18N } - boolean bOutStandingUncommittedMerges = HgCommand.isMergeAbortUncommittedMsg(list.get(list.size() -1)); + boolean bOutStandingUncommittedMerges = HgCommand.isMergeAbortUncommittedMsg(list.get(list.size() - 1)); if (bOutStandingUncommittedMerges) { - bConfirmMerge = HgUtils.confirmDialog(PushAction.class, "MSG_PUSH_MERGE_CONFIRM_TITLE", "MSG_PUSH_MERGE_UNCOMMITTED_CONFIRM_QUERY"); + bConfirmMerge = HgUtils.confirmDialog(PushAction.class, "MSG_PUSH_MERGE_CONFIRM_TITLE", "MSG_PUSH_MERGE_UNCOMMITTED_CONFIRM_QUERY"); // NOI18N } } } else { - bConfirmMerge = HgUtils.confirmDialog(PushAction.class, "MSG_PUSH_MERGE_CONFIRM_TITLE", "MSG_PUSH_MERGE_CONFIRM_QUERY"); + bConfirmMerge = HgUtils.confirmDialog(PushAction.class, "MSG_PUSH_MERGE_CONFIRM_TITLE", "MSG_PUSH_MERGE_CONFIRM_QUERY"); // NOI18N } if (bConfirmMerge) { @@ -258,7 +275,7 @@ } catch (HgException ex) { NotifyDescriptor.Exception e = new NotifyDescriptor.Exception(ex); DialogDisplayer.getDefault().notifyLater(e); - } finally{ + } finally { HgUtils.outputMercurialTabInRed(NbBundle.getMessage(PushAction.class, "MSG_PUSH_DONE")); // NOI18N HgUtils.outputMercurialTab(""); // NOI18N } Index: versioncontrol/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java --- versioncontrol/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java Base (1.64) +++ versioncontrol/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java Locally Modified (Based On 1.64) @@ -203,6 +203,8 @@ private static final String HG_CANNOT_READ_COMMIT_MESSAGE_ERR = "abort: can't read commit message"; // NOI18N private static final String HG_CANNOT_RUN_ERR = "Cannot run program"; // NOI18N private static final String HG_ABORT_ERR = "abort: "; // NOI18N + private static final String HG_ABORT_PUSH_ERR = "abort: push creates new remote branches!"; // 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 private static final String HG_NO_UPDATES_ERR = "0 files updated, 0 files merged, 0 files removed, 0 files unresolved"; // NOI18N @@ -505,28 +507,31 @@ } /** - * Push changes to the local repository to the specified repository - * By default, update will refuse to run if doing so would require - * merging or discarding local changes. + * Push changes to the specified repository + * By default, push will refuse to run if doing so would create multiple heads * * @param File repository of the mercurial repository's root directory - * @param File source repository to push to + * @param String source repository to push to + * @param boolean force push even if multiple heads will be created * @return hg push output * @throws org.netbeans.modules.mercurial.HgException */ - public static List doPush(File repository, String to) throws HgException { + public static List doPush(File repository, String to, boolean bForce) throws HgException { if (repository == null || to == null ) return null; List command = new ArrayList(); command.add(getHgCommand()); command.add(HG_PUSH_CMD); + if(bForce) command.add(HG_PUSH_FORCE_CMD); command.add(HG_OPT_REPOSITORY); command.add(repository.getAbsolutePath()); command.add(to); List list = exec(command); + if (!list.isEmpty() && + !isErrorAbortPush(list.get(list.size() -1)) && isErrorAbort(list.get(list.size() -1))) { handleError(command, list, NbBundle.getMessage(HgCommand.class, "MSG_COMMAND_ABORTED")); } @@ -2110,6 +2115,10 @@ return msg.indexOf(HG_ABORT_ERR) > -1; // NOI18N } + public static boolean isErrorAbortPush(String msg) { + return msg.indexOf(HG_ABORT_PUSH_ERR) > -1; // NOI18N + } + private static boolean isErrorNoChangeNeeded(String msg) { return msg.indexOf(HG_NO_CHANGE_NEEDED_ERR) > -1; // NOI18N }