hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.

Sat, 04 Aug 2018 15:24:58 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 04 Aug 2018 15:24:58 +0200
changeset 6462
58259e234dc9
parent 6461
48bf6c3f084f
child 6463
628d8ee45325

hg, HgExportDialog: added support for the hg export '--bookmark' option as of Mercurial 4.7.0.

Plugins/VcsPlugins/vcsMercurial/HgExportDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/HgExportDialog.ui file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsMercurial/hg.py file | annotate | diff | comparison | revisions
--- a/Plugins/VcsPlugins/vcsMercurial/HgExportDialog.py	Sat Aug 04 14:48:27 2018 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/HgExportDialog.py	Sat Aug 04 15:24:58 2018 +0200
@@ -19,16 +19,21 @@
 from .Ui_HgExportDialog import Ui_HgExportDialog
 
 
-# TODO: Mercurial 4.7: add support for --bookmark flag
 class HgExportDialog(QDialog, Ui_HgExportDialog):
     """
     Class implementing a dialog to enter data for the Mercurial export command.
     """
-    def __init__(self, parent=None):
+    def __init__(self, bookmarksList, bookmarkAvailable, parent=None):
         """
         Constructor
         
-        @param parent reference to the parent widget (QWidget)
+        @param bookmarksList list of defined bookmarks
+        @type list of str
+        @param bookmarkAvailable flag indicating the availability of the
+            "--bookmark" option
+        @type bool
+        @param parent reference to the parent widget
+        @type QWidget
         """
         super(HgExportDialog, self).__init__(parent)
         self.setupUi(self)
@@ -40,6 +45,10 @@
         # set default values for directory and pattern
         self.patternEdit.setText("%b_%r_%h_%n_of_%N.diff")
         self.directoryPicker.setText(QDir.tempPath())
+        
+        self.bookmarkCombo.addItem("")
+        self.bookmarkCombo.addItems(sorted(bookmarksList))
+        self.bookmarkCombo.setenabled(bookmarkAvailable)
     
     def __updateOK(self):
         """
@@ -51,7 +60,8 @@
             enabled = False
         elif self.patternEdit.text() == "":
             enabled = False
-        elif self.changesetsEdit.toPlainText() == "":
+        elif self.changesetsEdit.toPlainText() == "" and \
+                self.bookmarkCombo.currentText() == "":
             enabled = False
         
         self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled)
@@ -86,16 +96,18 @@
         Public method to retrieve the export data.
         
         @return tuple naming the output file name, the list of revisions to
-            export, and flags indicating to compare against the second parent,
-            to treat all files as text, to omit dates in the diff headers and
-            to use the git extended diff format (string, list of strings,
-            boolean, boolean, boolean, boolean)
+            export, the name of a bookmarked branch and flags indicating to
+            compare against the second parent, to treat all files as text,
+            to omit dates in the diff headers and to use the git extended
+            diff format
+        @rtype tuple of (str, list of str, str, bool, bool, bool, bool)
         """
         return (
             os.path.join(
                 self.directoryPicker.text(),
                 self.patternEdit.text()),
             self.changesetsEdit.toPlainText().splitlines(),
+            self.bookmarkCombo.currentText(),
             self.switchParentCheckBox.isChecked(),
             self.textCheckBox.isChecked(),
             self.datesCheckBox.isChecked(),
--- a/Plugins/VcsPlugins/vcsMercurial/HgExportDialog.ui	Sat Aug 04 14:48:27 2018 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/HgExportDialog.ui	Sat Aug 04 15:24:58 2018 +0200
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>450</width>
-    <height>350</height>
+    <height>400</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -99,6 +99,26 @@
        </property>
       </widget>
      </item>
+     <item row="3" column="0">
+      <widget class="QLabel" name="label_4">
+       <property name="text">
+        <string>Bookmark:</string>
+       </property>
+      </widget>
+     </item>
+     <item row="3" column="1">
+      <widget class="QComboBox" name="bookmarkCombo">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="toolTip">
+        <string>Enter a bookmark name</string>
+       </property>
+      </widget>
+     </item>
     </layout>
    </item>
    <item>
@@ -159,6 +179,7 @@
   <tabstop>directoryPicker</tabstop>
   <tabstop>patternEdit</tabstop>
   <tabstop>changesetsEdit</tabstop>
+  <tabstop>bookmarkCombo</tabstop>
   <tabstop>switchParentCheckBox</tabstop>
   <tabstop>textCheckBox</tabstop>
   <tabstop>datesCheckBox</tabstop>
--- a/Plugins/VcsPlugins/vcsMercurial/hg.py	Sat Aug 04 14:48:27 2018 +0200
+++ b/Plugins/VcsPlugins/vcsMercurial/hg.py	Sat Aug 04 15:24:58 2018 +0200
@@ -2905,12 +2905,12 @@
             if os.path.splitdrive(repodir)[1] == os.sep:
                 return
         
-        # TODO: Mercurial 4.7: add support for --bookmark flag
         from .HgExportDialog import HgExportDialog
-        dlg = HgExportDialog()
+        dlg = HgExportDialog(self.hgGetBookmarksList(repodir),
+                             self.version >= (4, 7, 0))
         if dlg.exec_() == QDialog.Accepted:
-            filePattern, revisions, switchParent, allText, noDates, git = \
-                dlg.getParameters()
+            filePattern, revisions, bookmark, switchParent, allText, noDates, \
+            git = dlg.getParameters()
             
             args = self.initCommand("export")
             args.append("--output")
@@ -2924,8 +2924,12 @@
                 args.append("--nodates")
             if git:
                 args.append("--git")
-            for rev in revisions:
-                args.append(rev)
+            if bookmark:
+                args.append ("--bookmark")
+                args.append(bookmark)
+            else:
+                for rev in revisions:
+                    args.append(rev)
             
             dia = HgDialog(self.tr("Export Patches"), self)
             res = dia.startProcess(args, repodir)

eric ide

mercurial