Commits

Yuya Nishihara committed aff0e3e

sign: use helper to build cmdline parameters

  • Participants
  • Parent commits cbcaaef

Comments (0)

Files changed (1)

tortoisehg/hgqt/sign.py

             self.set_status(_('Repository command still running'), False)
             return
 
-        keyu = self.keyLineEdit.text()
-        key = hglib.fromunicode(keyu)
-        local = self.localCheckBox.isChecked()
-        force = self.replaceCheckBox.isChecked()
-        nocommit = self.nocommitCheckBox.isChecked()
-        if self.customCheckBox.isChecked():
-            msgu = self.customTextLineEdit.text()
-            msg = hglib.fromunicode(msgu)
-        else:
-            msg = None
+        opts = {
+            'key': self.keyLineEdit.text() or None,
+            'local': self.localCheckBox.isChecked(),
+            'force': self.replaceCheckBox.isChecked(),
+            'no_commit': self.nocommitCheckBox.isChecked(),
+            }
+        if self.customCheckBox.isChecked() and not opts['no_commit']:
+            opts['message'] = self.customTextLineEdit.text() or None
 
         user = qtlib.getCurrentUsername(self, self.repo)
         if not user:
             return
+        opts['user'] = hglib.tounicode(user)
 
-        cmd = ['sign', '--user', user]
-
-        if key:
-            cmd.append('--key=%s' % key)
-
-        if force:
-            cmd.append('--force')
-
-        if local:
-            cmd.append('--local')
-
-        if nocommit:
-            cmd.append('--no-commit')
-        else:
-            if msg:
-                cmd.append('--message=%s' % msg)
-
-        cmd.append(str(self.rev))
-        sess = self._repoagent.runCommand(map(hglib.tounicode, cmd), self)
+        cmdline = hglib.buildcmdargs('sign', self.rev, **opts)
+        sess = self._repoagent.runCommand(cmdline, self)
         self._cmdsession = sess
         sess.commandFinished.connect(self.commandFinished)