Commits

Angel Ezquerra committed 35febb9

merge: let the user change the commit options on the merge wizard commit page (fixes #1727)

An "options" button has been added to the "commit panel". This button opens the
same "Options dialog" that is shown when you click the "Options" button on the
commit widget.

If some commit option is set, it will be shown on the commit panel as well, and
the options will be taken into account when making the commit.

  • Participants
  • Parent commits 56ea862
  • Branches stable

Comments (0)

Files changed (1)

File tortoisehg/hgqt/merge.py

 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2, incorporated herein by reference.
 
-from mercurial import hg, error
+from mercurial import hg, error, util
 
 from tortoisehg.util import hglib
 from tortoisehg.hgqt.i18n import _
 from tortoisehg.hgqt import qtlib, csinfo, i18n, cmdui, status, resolve
-from tortoisehg.hgqt import qscilib, thgrepo, messageentry
+from tortoisehg.hgqt import qscilib, thgrepo, messageentry, commit
 
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
         self.skiplast.setChecked(checked)
         self.layout().addWidget(self.skiplast)
 
+        hblayout = QHBoxLayout()
+        self.opts = commit.readrepoopts(self.repo)
+        self.optionsbtn = QPushButton(_('Commit Options'))
+        self.optionsbtn.clicked.connect(self.details)
+        hblayout.addWidget(self.optionsbtn)
+        self.optionslabelfmt = _('<b>Selected Options:</b> %s')
+        self.optionslabel = QLabel('')
+        hblayout.addWidget(self.optionslabel)
+        hblayout.addStretch()
+        self.layout().addLayout(hblayout)
+
         self.setButtonText(QWizard.CommitButton, _('Commit Now'))
         # The cancel button does not really "cancel" the merge
         self.setButtonText(QWizard.CancelButton, _('Commit Later'))
 
+        # Update the options label
+        self.refresh()
+
     def refresh(self):
-        pass
+        opts = commit.commitopts2str(self.opts)
+        self.optionslabel.setText(self.optionslabelfmt
+            % hglib.tounicode(opts))
+        self.optionslabel.setVisible(bool(opts))
 
     def cleanupPage(self):
         s = QSettings()
                 self.wizard().close()
             return True
 
-        user = qtlib.getCurrentUsername(self, self.repo)
+        user = qtlib.getCurrentUsername(self, self.repo, self.opts)
         if not user:
             return False
 
         message = hglib.fromunicode(self.msgEntry.text())
         cmdline = ['commit', '--verbose', '--message', message,
                    '--repository', self.repo.root, '--user', user]
+        if self.opts.get('recurseinsubrepos'):
+            cmdline.append('--subrepos')
+        try:
+            date = self.opts.get('date')
+            if date:
+                util.parsedate(date)
+                dcmd = ['--date', date]
+            else:
+                dcmd = []
+        except error.Abort, e:
+            if e.hint:
+                err = _('%s (hint: %s)') % (hglib.tounicode(str(e)),
+                                            hglib.tounicode(e.hint))
+            else:
+                err = hglib.tounicode(str(e))
+            qtlib.WarningMsgBox(_('TortoiseHg Merge Commit'),
+                _('Error creating interpreting commit date (%s).\n'
+                  'Using current date instead.'), err)
+            dcmd = []
+
+        cmdline += dcmd
+
         commandlines = [cmdline]
         pushafter = self.repo.ui.config('tortoisehg', 'cipushafter')
         if pushafter:
             self.wizard().next()
         self.completeChanged.emit()
 
+    def readUserHistory(self):
+        'Load user history from the global commit settings'
+        s = QSettings()
+        userhist = s.value('commit/userhist').toStringList()
+        userhist = [u for u in userhist if u]
+        return userhist
+
+    def details(self):
+        self.userhist = self.readUserHistory()
+        dlg = commit.DetailsDialog(self.opts, self.userhist, self, mode='merge')
+        dlg.finished.connect(dlg.deleteLater)
+        dlg.setWindowFlags(Qt.Sheet)
+        dlg.setWindowModality(Qt.WindowModal)
+        if dlg.exec_() == QDialog.Accepted:
+            self.opts.update(dlg.outopts)
+            self.refresh()
 
 class ResultPage(BasePage):
     def __init__(self, repo, parent):