mercurial/patch.py
branchstable
changeset 46375 33350debb480
parent 46246 416ecdaa12df
child 46379 a9887f9e87aa
equal deleted inserted replaced
46374:df44bac9413d 46375:33350debb480
    18 import zlib
    18 import zlib
    19 
    19 
    20 from .i18n import _
    20 from .i18n import _
    21 from .node import (
    21 from .node import (
    22     hex,
    22     hex,
       
    23     nullhex,
    23     short,
    24     short,
    24 )
    25 )
    25 from .pycompat import open
    26 from .pycompat import open
    26 from . import (
    27 from . import (
    27     copies,
    28     copies,
  3097     it and use the file content directly.
  3098     it and use the file content directly.
  3098     """
  3099     """
  3099 
  3100 
  3100     ctx1, fctx1, path1, flag1, content1, date1 = data1
  3101     ctx1, fctx1, path1, flag1, content1, date1 = data1
  3101     ctx2, fctx2, path2, flag2, content2, date2 = data2
  3102     ctx2, fctx2, path2, flag2, content2, date2 = data2
       
  3103     index1 = _gitindex(content1) if path1 in ctx1 else nullhex
       
  3104     index2 = _gitindex(content2) if path2 in ctx2 else nullhex
  3102     if binary and opts.git and not opts.nobinary:
  3105     if binary and opts.git and not opts.nobinary:
  3103         text = mdiff.b85diff(content1, content2)
  3106         text = mdiff.b85diff(content1, content2)
  3104         if text:
  3107         if text:
  3105             header.append(
  3108             header.append(
  3106                 b'index %s..%s' % (_gitindex(content1), _gitindex(content2))
  3109                 b'index %s..%s' % (index1, index2)
  3107             )
  3110             )
  3108         hunks = ((None, [text]),)
  3111         hunks = ((None, [text]),)
  3109     else:
  3112     else:
  3110         if opts.git and opts.index > 0:
  3113         if opts.git and opts.index > 0:
  3111             flag = flag1
  3114             flag = flag1
  3112             if flag is None:
  3115             if flag is None:
  3113                 flag = flag2
  3116                 flag = flag2
  3114             header.append(
  3117             header.append(
  3115                 b'index %s..%s %s'
  3118                 b'index %s..%s %s'
  3116                 % (
  3119                 % (
  3117                     _gitindex(content1)[0 : opts.index],
  3120                     index1[0 : opts.index],
  3118                     _gitindex(content2)[0 : opts.index],
  3121                     index2[0 : opts.index],
  3119                     _gitmode[flag],
  3122                     _gitmode[flag],
  3120                 )
  3123                 )
  3121             )
  3124             )
  3122 
  3125 
  3123         uheaders, hunks = mdiff.unidiff(
  3126         uheaders, hunks = mdiff.unidiff(