mercurial/patch.py
changeset 35328 4937db58b663
parent 35311 12ce62c72c24
child 35366 dce761558329
equal deleted inserted replaced
35327:777cb4497d8d 35328:4937db58b663
  2508             if head:
  2508             if head:
  2509                 prefixes = headprefixes
  2509                 prefixes = headprefixes
  2510             for prefix, label in prefixes:
  2510             for prefix, label in prefixes:
  2511                 if stripline.startswith(prefix):
  2511                 if stripline.startswith(prefix):
  2512                     if diffline:
  2512                     if diffline:
  2513                         for token in tabsplitter.findall(stripline):
  2513                         if i in matches:
  2514                             if '\t' == token[0]:
  2514                             for t, l in _inlinediff(lines[i].rstrip(),
  2515                                 yield (token, 'diff.tab')
  2515                                                     lines[matches[i]].rstrip(),
  2516                             else:
  2516                                                     label):
  2517                                 if i in matches:
  2517                                 yield (t, l)
  2518                                     for t, l in _inlinediff(
  2518                         else:
  2519                                                   lines[i].rstrip(),
  2519                             for token in tabsplitter.findall(stripline):
  2520                                                   lines[matches[i]].rstrip(),
  2520                                 if '\t' == token[0]:
  2521                                                   label):
  2521                                     yield (token, 'diff.tab')
  2522                                         yield (t, l)
       
  2523                                 else:
  2522                                 else:
  2524                                     yield (token, label)
  2523                                     yield (token, label)
  2525                     else:
  2524                     else:
  2526                         yield (stripline, label)
  2525                         yield (stripline, label)
  2527                     break
  2526                     break
  2579         raise error.ProgrammingError("Case not expected, operation = %s" %
  2578         raise error.ProgrammingError("Case not expected, operation = %s" %
  2580                                      operation)
  2579                                      operation)
  2581 
  2580 
  2582     s = difflib.ndiff(re.split(br'(\W)', s2), re.split(br'(\W)', s1))
  2581     s = difflib.ndiff(re.split(br'(\W)', s2), re.split(br'(\W)', s1))
  2583     for part in s:
  2582     for part in s:
  2584         if part[0] in operation_skip:
  2583         if part[0] in operation_skip or len(part) == 2:
  2585             continue
  2584             continue
  2586         l = operation + '.highlight'
  2585         l = operation + '.highlight'
  2587         if part[0] in ' ':
  2586         if part[0] in ' ':
  2588             l = operation
  2587             l = operation
       
  2588         if part[2:] == '\t':
       
  2589             l = 'diff.tab'
  2589         if l == label: # contiguous token with same label
  2590         if l == label: # contiguous token with same label
  2590             token += part[2:]
  2591             token += part[2:]
  2591             continue
  2592             continue
  2592         else:
  2593         else:
  2593             buff.append((token, label))
  2594             buff.append((token, label))