Commits

Yuya Nishihara committed d879202

commit: do not crash by invalid issue.regex expression (fixes #3732)

Invalid regex pattern is silently ignored as in qtlib.descriptionhtmlizer.
Maybe we can add a validator to settings dialog.

Comments (0)

Files changed (1)

tortoisehg/hgqt/commit.py

         linkmandatory = self.repo.ui.configbool('tortoisehg',
                                                 'issue.linkmandatory', False)
         if linkmandatory:
-            issueregex = self.repo.ui.config('tortoisehg', 'issue.regex')
+            issueregex = None
+            s = self.repo.ui.config('tortoisehg', 'issue.regex')
+            if s:
+                try:
+                    issueregex = re.compile(s)
+                except re.error:
+                    pass
             if issueregex:
-                m = re.search(issueregex, msg)
+                m = issueregex.search(msg)
                 if not m:
                     qtlib.WarningMsgBox(_('Nothing Committed'),
                                         _('No issue link was found in the '