mercurial/revset.py
changeset 15266 8bea39ca9acb
parent 15153 fa0a464e4ca5
child 15268 bd5103819c2e
equal deleted inserted replaced
15265:460135339d74 15266:8bea39ca9acb
  1053     escapes arguments appropriately. Aliases are intentionally ignored
  1053     escapes arguments appropriately. Aliases are intentionally ignored
  1054     so that intended expression behavior isn't accidentally subverted.
  1054     so that intended expression behavior isn't accidentally subverted.
  1055 
  1055 
  1056     Supported arguments:
  1056     Supported arguments:
  1057 
  1057 
       
  1058     %r = revset expression, parenthesized
  1058     %d = int(arg), no quoting
  1059     %d = int(arg), no quoting
  1059     %s = string(arg), escaped and single-quoted
  1060     %s = string(arg), escaped and single-quoted
  1060     %b = arg.branch(), escaped and single-quoted
  1061     %b = arg.branch(), escaped and single-quoted
  1061     %n = hex(arg), single-quoted
  1062     %n = hex(arg), single-quoted
  1062     %% = a literal '%'
  1063     %% = a literal '%'
  1063 
  1064 
  1064     Prefixing the type with 'l' specifies a list of that type.
  1065     Prefixing the type with 'l' specifies a parenthesized list of that type.
  1065 
  1066 
       
  1067     >>> formatspec('%d:: and %lr', 10, ("this()", "that()"))
       
  1068     '10:: and ((this()) or (that()))'
  1066     >>> formatspec('%d:: and not %d::', 10, 20)
  1069     >>> formatspec('%d:: and not %d::', 10, 20)
  1067     '10:: and not 20::'
  1070     '10:: and not 20::'
  1068     >>> formatspec('keyword(%s)', 'foo\\xe9')
  1071     >>> formatspec('keyword(%s)', 'foo\\xe9')
  1069     "keyword('foo\\\\xe9')"
  1072     "keyword('foo\\\\xe9')"
  1070     >>> b = lambda: 'default'
  1073     >>> b = lambda: 'default'
  1081     def argtype(c, arg):
  1084     def argtype(c, arg):
  1082         if c == 'd':
  1085         if c == 'd':
  1083             return str(int(arg))
  1086             return str(int(arg))
  1084         elif c == 's':
  1087         elif c == 's':
  1085             return quote(arg)
  1088             return quote(arg)
       
  1089         elif c == 'r':
       
  1090             parse(arg) # make sure syntax errors are confined
       
  1091             return '(%s)' % arg
  1086         elif c == 'n':
  1092         elif c == 'n':
  1087             return quote(node.hex(arg))
  1093             return quote(node.hex(arg))
  1088         elif c == 'b':
  1094         elif c == 'b':
  1089             return quote(arg.branch())
  1095             return quote(arg.branch())
  1090 
  1096