1. TortoiseHg
  2. TortoiseHg
  3. thg

Commits

Yuya Nishihara  committed e58cf6c

hglib: extract helper to build command-line arguments from option table

  • Participants
  • Parent commits f122312
  • Branches default

Comments (0)

Files changed (2)

File tortoisehg/hgqt/hgemail.py

View file
             getattr(self._qui, e).editTextChanged.connect(self._updateforms)
 
     def accept(self):
-        # TODO: want to pass patchbombopts directly
-        def cmdargs(opts):
-            args = []
-            for k, v in opts.iteritems():
-                if isinstance(v, bool):
-                    if v:
-                        args.append('--%s' % k.replace('_', '-'))
-                else:
-                    for e in isinstance(v, basestring) and [v] or v:
-                        args += ['--%s' % k.replace('_', '-'), e]
-
-            return args
-
         hglib.loadextension(self._ui, 'patchbomb')
 
         opts = self._patchbombopts()
         try:
-            cmd = cmdui.Dialog(['email'] + cmdargs(opts), parent=self)
+            cmd = cmdui.Dialog(['email'] + hglib.buildcmdargs(**opts),
+                               parent=self)
             cmd.setWindowTitle(_('Sending Email'))
             cmd.setShowOutput(False)
             cmd.finished.connect(cmd.deleteLater)

File tortoisehg/util/hglib.py

View file
 def dispatch(ui, args):
     req = hgdispatch.request(args, ui)
     return hgdispatch._dispatch(req)
+
+def buildcmdargs(**opts):
+    args = []
+    for k, v in opts.iteritems():
+        if isinstance(v, bool):
+            if v:
+                args.append('--%s' % k.replace('_', '-'))
+        else:
+            for e in isinstance(v, basestring) and [v] or v:
+                args += ['--%s' % k.replace('_', '-'), e]
+
+    return args