mercurial/revset.py
changeset 12408 78a97859b90d
parent 12401 4cdaf1adafc8
child 12615 64db820c66a2
equal deleted inserted replaced
12407:5bfab61c2fee 12408:78a97859b90d
    46         elif c == '.' and program[pos:pos + 2] == '..': # look ahead carefully
    46         elif c == '.' and program[pos:pos + 2] == '..': # look ahead carefully
    47             yield ('..', None, pos)
    47             yield ('..', None, pos)
    48             pos += 1 # skip ahead
    48             pos += 1 # skip ahead
    49         elif c in "():,-|&+!": # handle simple operators
    49         elif c in "():,-|&+!": # handle simple operators
    50             yield (c, None, pos)
    50             yield (c, None, pos)
    51         elif c in '"\'': # handle quoted strings
    51         elif (c in '"\'' or c == 'r' and
       
    52               program[pos:pos + 2] in ("r'", 'r"')): # handle quoted strings
       
    53             if c == 'r':
       
    54                 pos += 1
       
    55                 c = program[pos]
       
    56                 decode = lambda x: x
       
    57             else:
       
    58                 decode = lambda x: x.decode('string-escape')
    52             pos += 1
    59             pos += 1
    53             s = pos
    60             s = pos
    54             while pos < l: # find closing quote
    61             while pos < l: # find closing quote
    55                 d = program[pos]
    62                 d = program[pos]
    56                 if d == '\\': # skip over escaped characters
    63                 if d == '\\': # skip over escaped characters
    57                     pos += 2
    64                     pos += 2
    58                     continue
    65                     continue
    59                 if d == c:
    66                 if d == c:
    60                     yield ('string', program[s:pos].decode('string-escape'), s)
    67                     yield ('string', decode(program[s:pos]), s)
    61                     break
    68                     break
    62                 pos += 1
    69                 pos += 1
    63             else:
    70             else:
    64                 raise error.ParseError(_("unterminated string"), s)
    71                 raise error.ParseError(_("unterminated string"), s)
    65         elif c.isalnum() or c in '._' or ord(c) > 127: # gather up a symbol/keyword
    72         elif c.isalnum() or c in '._' or ord(c) > 127: # gather up a symbol/keyword