mercurial/mdiff.py
changeset 17940 c84ef0047a94
parent 17939 d587925680d9
child 17941 9a6e4d5d7ea8
equal deleted inserted replaced
17939:d587925680d9 17940:c84ef0047a94
   154         parts.append('b/%s' % b)
   154         parts.append('b/%s' % b)
   155     else:
   155     else:
   156         parts.append(a)
   156         parts.append(a)
   157     return ' '.join(parts) + '\n'
   157     return ' '.join(parts) + '\n'
   158 
   158 
   159 def unidiff(a, ad, b, bd, fn1, fn2, r=None, opts=defaultopts):
   159 def unidiff(a, ad, b, bd, fn1, fn2, opts=defaultopts):
   160     def datetag(date, fn=None):
   160     def datetag(date, fn=None):
   161         if not opts.git and not opts.nodates:
   161         if not opts.git and not opts.nodates:
   162             return '\t%s\n' % date
   162             return '\t%s\n' % date
   163         if fn and ' ' in fn:
   163         if fn and ' ' in fn:
   164             return '\t\n'
   164             return '\t\n'
   204         l.insert(1, "+++ b/%s%s" % (fn2, datetag(bd, fn2)))
   204         l.insert(1, "+++ b/%s%s" % (fn2, datetag(bd, fn2)))
   205 
   205 
   206     for ln in xrange(len(l)):
   206     for ln in xrange(len(l)):
   207         if l[ln][-1] != '\n':
   207         if l[ln][-1] != '\n':
   208             l[ln] += "\n\ No newline at end of file\n"
   208             l[ln] += "\n\ No newline at end of file\n"
   209 
       
   210     if r:
       
   211         l.insert(0, diffline(r, fn1, fn2, opts))
       
   212 
   209 
   213     return "".join(l)
   210     return "".join(l)
   214 
   211 
   215 # creates a headerless unified diff
   212 # creates a headerless unified diff
   216 # t1 and t2 are the text to be diffed
   213 # t1 and t2 are the text to be diffed