Commits

Yuya Nishihara committed a16be2d

qreorder: extract common checkGuardsOrComments function

Comments (0)

Files changed (3)

tortoisehg/hgqt/mq.py

     def onQreorder(self):
         if self.cmd.running():
             return
-        def checkGuardsOrComments():
-            cont = True
-            for p in self.repo.mq.fullseries:
-                if '#' in p:
-                    cont = qtlib.QuestionMsgBox('Confirm qreorder',
-                            _('<p>ATTENTION!<br>'
-                              'Guard or comment found.<br>'
-                              'Reordering patches will destroy them.<br>'
-                              '<br>Continue?</p>'), parent=self,
-                              defaultbutton=QMessageBox.No)
-                    break
-            return cont
-        if checkGuardsOrComments():
+        if qreorder.checkGuardsOrComments(self.repo, self):
             dlg = qreorder.QReorderDialog(self._repoagent, self)
             dlg.exec_()
 

tortoisehg/hgqt/qreorder.py

         s = QSettings()
         s.setValue('qreorder/geom', self.saveGeometry())
 
+def checkGuardsOrComments(repo, parent=None):
+    cont = True
+    for p in repo.mq.fullseries:
+        if '#' in p:
+            cont = qtlib.QuestionMsgBox('Confirm qreorder',
+                    _('<p>ATTENTION!<br>'
+                      'Guard or comment found.<br>'
+                      'Reordering patches will destroy them.<br>'
+                      '<br>Continue?</p>'), parent=parent,
+                      defaultbutton=QMessageBox.No)
+            break
+    return cont
+
 def writeSeries(repo, applied, unapplied):
     try:
         repo.incrementBusyCount()

tortoisehg/hgqt/repowidget.py

             dlg.makeLogVisible.connect(self.makeLogVisible)
             dlg.exec_()
         def qreorderact():
-            def checkGuardsOrComments():
-                cont = True
-                for p in self.repo.mq.fullseries:
-                    if '#' in p:
-                        cont = QuestionMsgBox('Confirm qreorder',
-                                _('<p>ATTENTION!<br>'
-                                  'Guard or comment found.<br>'
-                                  'Reordering patches will destroy them.<br>'
-                                  '<br>Continue?</p>'), parent=self,
-                                  defaultbutton=QMessageBox.No)
-                        break
-                return cont
-            if checkGuardsOrComments():
+            if qreorder.checkGuardsOrComments(self.repo, self):
                 dlg = qreorder.QReorderDialog(self._repoagent, self)
                 dlg.exec_()
         def qfoldact():