Commits

Yuya Nishihara committed b916f6e

hglib: fix buildcmdargs to accept short option

Comments (0)

Files changed (1)

tortoisehg/util/hglib.py

 
     >>> buildcmdargs('push', branch='foo')
     ['push', '--branch', 'foo']
-    >>> buildcmdargs('graft', rev=['0', '1'])
-    ['graft', '--rev', '0', '--rev', '1']
+    >>> buildcmdargs('graft', r=['0', '1'])
+    ['graft', '-r', '0', '-r', '1']
     >>> buildcmdargs('log', no_merges=True, quiet=False)
     ['log', '--no-merges']
 
     """
     fullargs = [name]
     for k, v in opts.iteritems():
-        aname = '--%s' % k.replace('_', '-')
+        if len(k) == 1:
+            aname = '-%s' % k
+        else:
+            aname = '--%s' % k.replace('_', '-')
         if isinstance(v, bool):
             if v:
                 fullargs.append(aname)