Mercurial > hg
comparison mercurial/patch.py @ 4106:797dbdd4d7e1
git binary patches: don't print the header for identical files
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Sat, 17 Feb 2007 09:55:00 -0200 |
parents | ed46895aa38c |
children | 226df1808f16 da0588996ecc 24c22a3f2ef8 |
comparison
equal
deleted
inserted
replaced
4105:ed46895aa38c | 4106:797dbdd4d7e1 |
---|---|
413 i += csize | 413 i += csize |
414 | 414 |
415 tohash = gitindex(to) | 415 tohash = gitindex(to) |
416 tnhash = gitindex(tn) | 416 tnhash = gitindex(tn) |
417 if tohash == tnhash: | 417 if tohash == tnhash: |
418 return | 418 return "" |
419 | |
419 # TODO: deltas | 420 # TODO: deltas |
420 fp.write('index %s..%s\nGIT binary patch\nliteral %s\n' % | 421 ret = ['index %s..%s\nGIT binary patch\nliteral %s\n' % |
421 (tohash, tnhash, len(tn))) | 422 (tohash, tnhash, len(tn))] |
422 | 423 for l in chunk(zlib.compress(tn)): |
423 tn = ''.join([fmtline(l) for l in chunk(zlib.compress(tn))]) | 424 ret.append(fmtline(l)) |
424 fp.write(tn) | 425 ret.append('\n') |
425 fp.write('\n') | 426 return ''.join(ret) |
426 | 427 |
427 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, |
428 fp=None, changes=None, opts=None): | 429 fp=None, changes=None, opts=None): |
429 '''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 |
430 working directory. | 431 working directory. |
613 addmodehdr(header, omode, nmode) | 614 addmodehdr(header, omode, nmode) |
614 if util.binary(to) or util.binary(tn): | 615 if util.binary(to) or util.binary(tn): |
615 dodiff = 'binary' | 616 dodiff = 'binary' |
616 r = None | 617 r = None |
617 header.insert(0, 'diff --git a/%s b/%s\n' % (a, b)) | 618 header.insert(0, 'diff --git a/%s b/%s\n' % (a, b)) |
618 if dodiff == 'binary': | 619 if dodiff: |
619 fp.write(''.join(header)) | 620 if dodiff == 'binary': |
620 b85diff(fp, to, tn) | 621 text = b85diff(fp, to, tn) |
621 elif dodiff: | 622 else: |
622 text = mdiff.unidiff(to, date1, tn, date2(f), f, r, opts=opts) | 623 text = mdiff.unidiff(to, date1, tn, date2(f), f, r, opts=opts) |
623 if text or len(header) > 1: | 624 if text or len(header) > 1: |
624 fp.write(''.join(header)) | 625 fp.write(''.join(header)) |
625 fp.write(text) | 626 fp.write(text) |
626 | 627 |
627 def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False, | 628 def export(repo, revs, template='hg-%h.patch', fp=None, switch_parent=False, |