hgext/githelp.py
branchstable
changeset 49366 288de6f5d724
parent 48946 642e31cb55f0
child 51370 0d414fb8336f
equal deleted inserted replaced
49364:e8ea403b1c46 49366:288de6f5d724
    13 
    13 
    14 If an unknown command or parameter combination is detected, an error is
    14 If an unknown command or parameter combination is detected, an error is
    15 produced.
    15 produced.
    16 """
    16 """
    17 
    17 
    18 from __future__ import absolute_import
       
    19 
    18 
    20 import getopt
    19 import getopt
    21 import re
    20 import re
    22 
    21 
    23 from mercurial.i18n import _
    22 from mercurial.i18n import _
   114 
   113 
   115     args = list([convert(x) for x in args])
   114     args = list([convert(x) for x in args])
   116     opts = dict(
   115     opts = dict(
   117         [
   116         [
   118             (k, convert(v)) if isinstance(v, bytes) else (k, v)
   117             (k, convert(v)) if isinstance(v, bytes) else (k, v)
   119             for k, v in pycompat.iteritems(opts)
   118             for k, v in opts.items()
   120         ]
   119         ]
   121     )
   120     )
   122 
   121 
   123     return args, opts
   122     return args, opts
   124 
   123 
   125 
   124 
   126 class Command(object):
   125 class Command:
   127     def __init__(self, name):
   126     def __init__(self, name):
   128         self.name = name
   127         self.name = name
   129         self.args = []
   128         self.args = []
   130         self.opts = {}
   129         self.opts = {}
   131 
   130 
   132     def __bytes__(self):
   131     def __bytes__(self):
   133         cmd = b"hg " + self.name
   132         cmd = b"hg " + self.name
   134         if self.opts:
   133         if self.opts:
   135             for k, values in sorted(pycompat.iteritems(self.opts)):
   134             for k, values in sorted(self.opts.items()):
   136                 for v in values:
   135                 for v in values:
   137                     if v:
   136                     if v:
   138                         if isinstance(v, int):
   137                         if isinstance(v, int):
   139                             fmt = b' %s %d'
   138                             fmt = b' %s %d'
   140                         else:
   139                         else:
   162 
   161 
   163     def __and__(self, other):
   162     def __and__(self, other):
   164         return AndCommand(self, other)
   163         return AndCommand(self, other)
   165 
   164 
   166 
   165 
   167 class AndCommand(object):
   166 class AndCommand:
   168     def __init__(self, left, right):
   167     def __init__(self, left, right):
   169         self.left = left
   168         self.left = left
   170         self.right = right
   169         self.right = right
   171 
   170 
   172     def __str__(self):
   171     def __str__(self):