comparison mercurial/patch.py @ 4107:226df1808f16

merge with crew-stable
author Thomas Arendsen Hein <thomas@intevation.de>
date Tue, 20 Feb 2007 20:55:23 +0100
parents 49237d6ae97d 797dbdd4d7e1
children ef4c1cd6f4e4
comparison
equal deleted inserted replaced
4101:e2ed92f4c0f7 4107:226df1808f16
410 i = 0 410 i = 0
411 while i < l: 411 while i < l:
412 yield text[i:i+csize] 412 yield text[i:i+csize]
413 i += csize 413 i += csize
414 414
415 if to == tn: 415 tohash = gitindex(to)
416 return 416 tnhash = gitindex(tn)
417 if tohash == tnhash:
418 return ""
419
417 # TODO: deltas 420 # TODO: deltas
418 l = len(tn) 421 ret = ['index %s..%s\nGIT binary patch\nliteral %s\n' %
419 fp.write('index %s..%s\nGIT binary patch\nliteral %s\n' % 422 (tohash, tnhash, len(tn))]
420 (gitindex(to), gitindex(tn), len(tn))) 423 for l in chunk(zlib.compress(tn)):
421 424 ret.append(fmtline(l))
422 tn = ''.join([fmtline(l) for l in chunk(zlib.compress(tn))]) 425 ret.append('\n')
423 fp.write(tn) 426 return ''.join(ret)
424 fp.write('\n')
425 427
426 def diff(repo, node1=None, node2=None, files=None, match=util.always, 428 def diff(repo, node1=None, node2=None, files=None, match=util.always,
427 fp=None, changes=None, opts=None): 429 fp=None, changes=None, opts=None):
428 '''print diff of changes to files between two nodes, or node and 430 '''print diff of changes to files between two nodes, or node and
429 working directory. 431 working directory.
576 addmodehdr(header, omode, nmode) 578 addmodehdr(header, omode, nmode)
577 if util.binary(to) or util.binary(tn): 579 if util.binary(to) or util.binary(tn):
578 dodiff = 'binary' 580 dodiff = 'binary'
579 r = None 581 r = None
580 header.insert(0, 'diff --git a/%s b/%s\n' % (a, b)) 582 header.insert(0, 'diff --git a/%s b/%s\n' % (a, b))
581 if dodiff == 'binary': 583 if dodiff:
582 fp.write(''.join(header)) 584 if dodiff == 'binary':
583 b85diff(fp, to, tn) 585 text = b85diff(fp, to, tn)
584 elif dodiff: 586 else:
585 text = mdiff.unidiff(to, date1, 587 text = mdiff.unidiff(to, date1,
586 # ctx2 date may be dynamic 588 # ctx2 date may be dynamic
587 tn, util.datestr(ctx2.date()), 589 tn, util.datestr(ctx2.date()),
588 f, r, opts=opts) 590 f, r, opts=opts)
589 if text or len(header) > 1: 591 if text or len(header) > 1:
590 fp.write(''.join(header)) 592 fp.write(''.join(header))
591 fp.write(text) 593 fp.write(text)
592 594
593 def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False, 595 def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False,