Commits

Yuya Nishihara committed 7166033

mq: move checkForRejects() that is used only by PatchQueueActions

  • Participants
  • Parent commits b46768e

Comments (0)

Files changed (2)

File tortoisehg/hgqt/mq.py

 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import os
+import os, re
 
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 from tortoisehg.util import hglib
 from tortoisehg.hgqt.i18n import _
 from tortoisehg.hgqt import cmdcore, qtlib, cmdui
-from tortoisehg.hgqt import commit, qdelete, qfold, qrename, mqutil
+from tortoisehg.hgqt import commit, qdelete, qfold, qrename, rejects
 from tortoisehg.hgqt.qtlib import geticon
 
+def _checkForRejects(repo, rawoutput, parent=None):
+    """Parse output of qpush/qpop to resolve hunk failure manually"""
+    rejre = re.compile('saving rejects to file (.*).rej')
+    rejfiles = [m.group(1) for m in rejre.finditer(rawoutput)
+                if os.path.exists(repo.wjoin(m.group(1)))]
+    for wfile in rejfiles:
+        ufile = hglib.tounicode(wfile)
+        if qtlib.QuestionMsgBox(_('Manually resolve rejected chunks?'),
+                                _('%s had rejected chunks, edit patched '
+                                  'file together with rejects?') % ufile,
+                                parent=parent):
+            dlg = rejects.RejectsDialog(repo.ui, repo.wjoin(wfile), parent)
+            dlg.exec_()
+
+    return len(rejfiles)
+
 class QueueManagementActions(QObject):
     """Container for patch queue management actions"""
 
         if ret == 2 and self._repoagent:
             repo = self._repoagent.rawRepo()
             output = hglib.fromunicode(self._cmdsession.warningString())
-            if mqutil.checkForRejects(repo, output, self.parent()) > 0:
+            if _checkForRejects(repo, output, self.parent()) > 0:
                 ret = 0  # no further error dialog
         if ret != 0:
             cmdui.errorMessageBox(self._cmdsession, self.parent())

File tortoisehg/hgqt/mqutil.py

 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import os, re
-
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 
 from tortoisehg.util import hglib
 from tortoisehg.hgqt.i18n import _
-from tortoisehg.hgqt import qtlib, rejects
+from tortoisehg.hgqt import qtlib
 
 def getUserOptions(opts, *optionlist):
     out = []
             out.append(val)
     return out
 
-def checkForRejects(repo, rawoutput, parent=None):
-    """Parse output of qpush/qpop to resolve hunk failure manually"""
-    rejre = re.compile('saving rejects to file (.*).rej')
-    rejfiles = [m.group(1) for m in rejre.finditer(rawoutput)
-                if os.path.exists(repo.wjoin(m.group(1)))]
-    for wfile in rejfiles:
-        ufile = hglib.tounicode(wfile)
-        if qtlib.QuestionMsgBox(_('Manually resolve rejected chunks?'),
-                                _('%s had rejected chunks, edit patched '
-                                  'file together with rejects?') % ufile,
-                                parent=parent):
-            dlg = rejects.RejectsDialog(repo.ui, repo.wjoin(wfile), parent)
-            dlg.exec_()
-
-    return len(rejfiles)
-
 def mqNewRefreshCommand(repo, isnew, stwidget, pnwidget, message, opts, olist):
     if isnew:
         name = hglib.fromunicode(pnwidget.text())