# HG changeset patch # User Alexis S. L. Carvalho # Date 1171608886 7200 # Node ID 4ced663bebf0ddf55161474c9463fe7e3ca0adc3 # Parent 3d7480ada3e5090bd7ff29c1706ed153a90ea7c8 git patches: handle renames of binary files diff -r 3d7480ada3e5 -r 4ced663bebf0 mercurial/patch.py --- a/mercurial/patch.py Thu Feb 15 08:49:20 2007 -0200 +++ b/mercurial/patch.py Fri Feb 16 04:54:46 2007 -0200 @@ -412,6 +412,8 @@ yield text[i:i+csize] i += csize + if to == tn: + return # TODO: deltas l = len(tn) fp.write('index %s..%s\nGIT binary patch\nliteral %s\n' % @@ -593,8 +595,8 @@ to = getfile(a).read(arev) else: header.append('new file mode %s\n' % mode) - if util.binary(tn): - dodiff = 'binary' + if util.binary(tn): + dodiff = 'binary' elif f in removed: if f in srcs: dodiff = False diff -r 3d7480ada3e5 -r 4ced663bebf0 tests/test-git-export --- a/tests/test-git-export Thu Feb 15 08:49:20 2007 -0200 +++ b/tests/test-git-export Fri Feb 16 04:54:46 2007 -0200 @@ -61,6 +61,11 @@ cmp binfile.bin $TESTDIR/binfile.bin echo +echo '% rename binary file' +hg mv binfile.bin renamed.bin +hg diff --git + +echo echo '% diff across many revisions' hg mv dst dst2 hg ci -m 'mv dst dst2' -d '0 0' diff -r 3d7480ada3e5 -r 4ced663bebf0 tests/test-git-export.out --- a/tests/test-git-export.out Thu Feb 15 08:49:20 2007 -0200 +++ b/tests/test-git-export.out Fri Feb 16 04:54:46 2007 -0200 @@ -66,6 +66,11 @@ % import binary diff applying b.diff +% rename binary file +diff --git a/binfile.bin b/renamed.bin +rename from binfile.bin +rename to renamed.bin + % diff across many revisions diff --git a/dst2 b/dst3 rename from dst2