Show More
@@ -0,0 +1,25 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | hg init a | |||
|
4 | cd a | |||
|
5 | cp $TESTDIR/binfile.bin . | |||
|
6 | hg add binfile.bin | |||
|
7 | hg ci -m 'add binfile.bin' -d '0 0' | |||
|
8 | ||||
|
9 | echo >> binfile.bin | |||
|
10 | hg ci -m 'change binfile.bin' -d '0 0' | |||
|
11 | ||||
|
12 | hg revert -r 0 binfile.bin | |||
|
13 | hg ci -m 'revert binfile.bin' -d '0 0' | |||
|
14 | ||||
|
15 | echo % diff -r 0 -r 1 | |||
|
16 | hg diff --nodates -r 0 -r 1 | |||
|
17 | ||||
|
18 | echo % diff -r 0 -r 2 | |||
|
19 | hg diff --nodates -r 0 -r 2 | |||
|
20 | ||||
|
21 | echo % diff --git -r 0 -r 1 | |||
|
22 | hg diff --git -r 0 -r 1 | |||
|
23 | ||||
|
24 | echo % diff --git -r 0 -r 2 | |||
|
25 | hg diff --git -r 0 -r 2 |
@@ -0,0 +1,23 b'' | |||||
|
1 | % diff -r 0 -r 1 | |||
|
2 | diff -r 48b371597640 -r acea2ab458c8 binfile.bin | |||
|
3 | Binary file binfile.bin has changed | |||
|
4 | % diff -r 0 -r 2 | |||
|
5 | % diff --git -r 0 -r 1 | |||
|
6 | diff --git a/binfile.bin b/binfile.bin | |||
|
7 | index 37ba3d1c6f17137d9c5f5776fa040caf5fe73ff9..58dc31a9e2f40f74ff3b45903f7d620b8e5b7356 | |||
|
8 | GIT binary patch | |||
|
9 | literal 594 | |||
|
10 | zc$@)J0<HatP)<h;3K|Lk000e1NJLTq000mG000mO0ssI2kdbIM00009a7bBm000XU | |||
|
11 | z000XU0RWnu7ytkO2XskIMF-Uh9TW;VpMjwv0005-Nkl<ZD9@FWPs=e;7{<>W$NUkd | |||
|
12 | zX$nnYLt$-$V!?uy+1V%`z&Eh=ah|duER<4|QWhju3gb^nF*8iYobxWG-qqXl=2~5M | |||
|
13 | z*IoDB)sG^CfNuoBmqLTVU^<;@nwHP!1wrWd`{(mHo6VNXWtyh{alzqmsH*yYzpvLT | |||
|
14 | zLdY<T=ks|woh-`&01!ej#(xbV1f|pI*=%;d-%F*E*X#ZH`4I%6SS+$EJDE&ct=8po | |||
|
15 | ziN#{?_j|kD%Cd|oiqds`xm@;oJ-^?NG3Gdqrs?5u*zI;{nogxsx~^|Fn^Y?Gdc6<; | |||
|
16 | zfMJ+iF1J`LMx&A2?dEwNW8ClebzPTbIh{@$hS6*`kH@1d%Lo7fA#}N1)oN7`gm$~V | |||
|
17 | z+wDx#)OFqMcE{s!JN0-xhG8ItAjVkJwEcb`3WWlJfU2r?;Pd%dmR+q@mSri5q9_W- | |||
|
18 | zaR2~ECX?B2w+zELozC0s*6Z~|QG^f{3I#<`?)Q7U-JZ|q5W;9Q8i_=pBuSzunx=U; | |||
|
19 | z9C)5jBoYw9^?EHyQl(M}1OlQcCX>lXB*ODN003Z&P17_@)3Pi=i0wb04<W?v-u}7K | |||
|
20 | zXmmQA+wDgE!qR9o8jr`%=ab_&uh(l?R=r;Tjiqon91I2-hIu?57~@*4h7h9uORK#= | |||
|
21 | gQItJW-{SoTm)8|5##k|m00000NkvXXu0mjf3JwksH2?qr | |||
|
22 | ||||
|
23 | % diff --git -r 0 -r 2 |
@@ -5,7 +5,7 b'' | |||||
5 | # This software may be used and distributed according to the terms |
|
5 | # This software may be used and distributed according to the terms | |
6 | # of the GNU General Public License, incorporated herein by reference. |
|
6 | # of the GNU General Public License, incorporated herein by reference. | |
7 |
|
7 | |||
8 | import bdiff, mpatch, re, struct, util |
|
8 | import bdiff, mpatch, re, struct, util, md5 | |
9 |
|
9 | |||
10 | def splitnewlines(text): |
|
10 | def splitnewlines(text): | |
11 | '''like str.splitlines, but only split on newlines.''' |
|
11 | '''like str.splitlines, but only split on newlines.''' | |
@@ -57,6 +57,11 b' def unidiff(a, ad, b, bd, fn, r=None, op' | |||||
57 | epoch = util.datestr((0, 0)) |
|
57 | epoch = util.datestr((0, 0)) | |
58 |
|
58 | |||
59 | if not opts.text and (util.binary(a) or util.binary(b)): |
|
59 | if not opts.text and (util.binary(a) or util.binary(b)): | |
|
60 | def h(v): | |||
|
61 | # md5 is used instead of sha1 because md5 is supposedly faster | |||
|
62 | return md5.new(v).digest() | |||
|
63 | if a and b and len(a) == len(b) and h(a) == h(b): | |||
|
64 | return "" | |||
60 | l = ['Binary file %s has changed\n' % fn] |
|
65 | l = ['Binary file %s has changed\n' % fn] | |
61 | elif not a: |
|
66 | elif not a: | |
62 | b = splitnewlines(b) |
|
67 | b = splitnewlines(b) |
@@ -412,16 +412,18 b' def b85diff(fp, to, tn):' | |||||
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): | |
@@ -578,14 +580,14 b' def diff(repo, node1=None, node2=None, f' | |||||
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 |
|
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) |
@@ -33,7 +33,7 b" hg --traceback --cwd a commit -Amb -d '1" | |||||
33 |
|
33 | |||
34 | echo '% pull (minimal config)' |
|
34 | echo '% pull (minimal config)' | |
35 | hg --traceback --cwd b pull ../a 2>&1 | sed -e 's/\(Message-Id:\).*/\1/' \ |
|
35 | hg --traceback --cwd b pull ../a 2>&1 | sed -e 's/\(Message-Id:\).*/\1/' \ | |
36 |
-e 's/changeset \([0-9a-f]* \) |
|
36 | -e 's/changeset \([0-9a-f]* \)*in .*test-notif/changeset \1in test-notif/' \ | |
37 | -e 's/^details: .*test-notify/details: test-notify/' |
|
37 | -e 's/^details: .*test-notify/details: test-notify/' | |
38 |
|
38 | |||
39 | cat <<EOF >> $HGRCPATH |
|
39 | cat <<EOF >> $HGRCPATH |
General Comments 0
You need to be logged in to leave comments.
Login now