mercurial/revset.py
branchstable
changeset 15325 cdf1daa3b83f
parent 15268 bd5103819c2e
child 15326 8ae2900d6d9b
equal deleted inserted replaced
15324:0890842c41d1 15325:cdf1daa3b83f
  1066 
  1066 
  1067     >>> formatspec('%r:: and %lr', '10 or 11', ("this()", "that()"))
  1067     >>> formatspec('%r:: and %lr', '10 or 11', ("this()", "that()"))
  1068     '(10 or 11):: and ((this()) or (that()))'
  1068     '(10 or 11):: and ((this()) or (that()))'
  1069     >>> formatspec('%d:: and not %d::', 10, 20)
  1069     >>> formatspec('%d:: and not %d::', 10, 20)
  1070     '10:: and not 20::'
  1070     '10:: and not 20::'
       
  1071     >>> formatspec('%ld or %ld', [], [1])
       
  1072     '(0-0) or (1)'
  1071     >>> formatspec('keyword(%s)', 'foo\\xe9')
  1073     >>> formatspec('keyword(%s)', 'foo\\xe9')
  1072     "keyword('foo\\\\xe9')"
  1074     "keyword('foo\\\\xe9')"
  1073     >>> b = lambda: 'default'
  1075     >>> b = lambda: 'default'
  1074     >>> b.branch = b
  1076     >>> b.branch = b
  1075     >>> formatspec('branch(%b)', b)
  1077     >>> formatspec('branch(%b)', b)
  1109                 arg += 1
  1111                 arg += 1
  1110             elif d == 'l':
  1112             elif d == 'l':
  1111                 # a list of some type
  1113                 # a list of some type
  1112                 pos += 1
  1114                 pos += 1
  1113                 d = expr[pos]
  1115                 d = expr[pos]
  1114                 lv = ' or '.join(argtype(d, e) for e in args[arg])
  1116                 if args[arg]:
       
  1117                     lv = ' or '.join(argtype(d, e) for e in args[arg])
       
  1118                 else:
       
  1119                     lv = '0-0' # a minimal way to represent an empty set
  1115                 ret += '(%s)' % lv
  1120                 ret += '(%s)' % lv
  1116                 arg += 1
  1121                 arg += 1
  1117             else:
  1122             else:
  1118                 raise util.Abort('unexpected revspec format character %s' % d)
  1123                 raise util.Abort('unexpected revspec format character %s' % d)
  1119         else:
  1124         else: