rebase, HgRebaseDialog: add support for --confirm and --dry-run as of Mercurial 4.7.0.

Sat, 04 Aug 2018 13:38:50 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 04 Aug 2018 13:38:50 +0200
changeset 6459
68c13732795b
parent 6458
97480c872ea9
child 6460
af9e529d0fb6

rebase, HgRebaseDialog: add support for --confirm and --dry-run as of Mercurial 4.7.0.

Plugins/VcsPlugins/vcsMercurial/RebaseExtension/HgRebaseDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/RebaseExtension/HgRebaseDialog.ui file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/RebaseExtension/rebase.py file | annotate | diff | comparison | revisions
--- a/Plugins/VcsPlugins/vcsMercurial/RebaseExtension/HgRebaseDialog.py	Fri Aug 03 17:56:44 2018 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/RebaseExtension/HgRebaseDialog.py	Sat Aug 04 13:38:50 2018 +0200
@@ -15,12 +15,11 @@
 from .Ui_HgRebaseDialog import Ui_HgRebaseDialog
 
 
-# TODO: Mercurial 4.7: add support for --confirm and --dry-run flags
 class HgRebaseDialog(QDialog, Ui_HgRebaseDialog):
     """
     Class implementing a dialog to enter the data for a rebase session.
     """
-    def __init__(self, tagsList, branchesList, bookmarksList=None,
+    def __init__(self, tagsList, branchesList, bookmarksList, version,
                  parent=None):
         """
         Constructor
@@ -42,14 +41,10 @@
         self.tag2Combo.addItems(sorted(tagsList))
         self.branch1Combo.addItems(["default"] + sorted(branchesList))
         self.branch2Combo.addItems(["default"] + sorted(branchesList))
-        if bookmarksList is not None:
-            self.bookmark1Combo.addItems(sorted(bookmarksList))
-            self.bookmark2Combo.addItems(sorted(bookmarksList))
-        else:
-            self.bookmark1Button.setHidden(True)
-            self.bookmark1Combo.setHidden(True)
-            self.bookmark2Button.setHidden(True)
-            self.bookmark2Combo.setHidden(True)
+        self.bookmark1Combo.addItems(sorted(bookmarksList))
+        self.bookmark2Combo.addItems(sorted(bookmarksList))
+        
+        self.dryRunGroup.setEnabled(version >= (4, 7, 0))
         
         msh = self.minimumSizeHint()
         self.resize(max(self.width(), msh.width()), msh.height())
@@ -276,9 +271,11 @@
         @return tuple with a source indicator of "S" or "B", the source
             revision, the destination revision, a flag indicating to collapse,
             a flag indicating to keep the original changesets, a flag
-            indicating to keep the original branch name and a flag indicating
-            to detach the source (string, string, string, boolean, boolean,
-            boolean, boolean)
+            indicating to keep the original branch name, a flag indicating
+            to detach the source, a flag indicating to perform a dry-run only
+            and a flag indicating to perform a dry-run first, than ask for
+            confirmation
+        @rtype tuple of (str, str, str, bool, bool, bool, bool, bool, bool)
         """
         if self.sourceButton.isChecked():
             indicator = "S"
@@ -298,5 +295,7 @@
             self.collapseCheckBox.isChecked(),
             self.keepChangesetsCheckBox.isChecked(),
             self.keepBranchCheckBox.isChecked(),
-            self.detachCheckBox.isChecked()
+            self.detachCheckBox.isChecked(),
+            self.dryRunOnlyButton.isChecked(),
+            self.dryRunConfirmButton.isChecked(),
         )
--- a/Plugins/VcsPlugins/vcsMercurial/RebaseExtension/HgRebaseDialog.ui	Fri Aug 03 17:56:44 2018 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/RebaseExtension/HgRebaseDialog.ui	Sat Aug 04 13:38:50 2018 +0200
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>650</width>
-    <height>394</height>
+    <height>477</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -423,6 +423,48 @@
     </layout>
    </item>
    <item row="1" column="0" colspan="2">
+    <widget class="QGroupBox" name="dryRunGroup">
+     <property name="title">
+      <string>Dry-Run</string>
+     </property>
+     <layout class="QHBoxLayout" name="horizontalLayout">
+      <item>
+       <widget class="QRadioButton" name="noDryRunButton">
+        <property name="toolTip">
+         <string>Select to not do a dry-run</string>
+        </property>
+        <property name="text">
+         <string>No</string>
+        </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QRadioButton" name="dryRunOnlyButton">
+        <property name="toolTip">
+         <string>Select to just do a dry-run</string>
+        </property>
+        <property name="text">
+         <string>Dry-Run Only</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QRadioButton" name="dryRunConfirmButton">
+        <property name="toolTip">
+         <string>Select to do a dry-run first, than ask the user for confirmation to perform the rebase</string>
+        </property>
+        <property name="text">
+         <string>Dry-Run First, than Confirm</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item row="2" column="0" colspan="2">
     <widget class="QDialogButtonBox" name="buttonBox">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>
--- a/Plugins/VcsPlugins/vcsMercurial/RebaseExtension/rebase.py	Fri Aug 03 17:56:44 2018 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/RebaseExtension/rebase.py	Sat Aug 04 13:38:50 2018 +0200
@@ -17,7 +17,6 @@
 from ..HgDialog import HgDialog
 
 
-# TODO: Mercurial 4.7: add support for --confirm and --dry-run flags
 class Rebase(HgExtension):
     """
     Class implementing the rebase extension interface.
@@ -48,10 +47,11 @@
         from .HgRebaseDialog import HgRebaseDialog
         dlg = HgRebaseDialog(self.vcs.hgGetTagsList(repodir),
                              self.vcs.hgGetBranchesList(repodir),
-                             self.vcs.hgGetBookmarksList(repodir))
+                             self.vcs.hgGetBookmarksList(repodir),
+                             self.vcs.version)
         if dlg.exec_() == QDialog.Accepted:
             (indicator, sourceRev, destRev, collapse, keep, keepBranches,
-             detach) = dlg.getData()
+             detach, dryRunOnly, dryRunConfirm) = dlg.getData()
             
             args = self.vcs.initCommand("rebase")
             if indicator == "S":
@@ -71,6 +71,10 @@
                 args.append("--keepbranches")
             if detach:
                 args.append("--detach")
+            if dryRunOnly:
+                args.append("--dry-run")
+            elif dryRunConfirm:
+                args.append("--confirm")
             args.append("--verbose")
             
             dia = HgDialog(self.tr('Rebase Changesets'), self.vcs)

eric ide

mercurial