[PATCH] diff: fix binary file removals in git mode
Sean Farley
sean.michael.farley at gmail.com
Fri Mar 22 17:54:02 CDT 2013
Sent this patch on behalf of Johan (forgot to cc him with the original
patch) with some minor fix ups. Apparently, his patch triggered this
bug in patch.py:
http://markmail.org/message/b5fgo7iourvxzrag
On Fri, Mar 22, 2013 at 5:49 PM, Sean Farley
<sean.michael.farley at gmail.com> wrote:
> # HG changeset patch
> # User Johan Bjork <jbjoerk at gmail.com>
> # Date 1362436451 0
> # Mon Mar 04 22:34:11 2013 +0000
> # Node ID 61208f15fe3d5f28de7c5c75858c180f033024b5
> # Parent ac0336471ba766cc3c1234473e75d4478819e50d
> diff: fix binary file removals in git mode.
>
> With the previous version, a binary file removal diff generated with
> diff --git would not apply with 'git apply' with the error
> "
> error: removal patch leaves file contents
> error: <file>: patch does not apply
> "
Nitpick: For some reason the quotations look oddly positioned to me.
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -1754,10 +1754,12 @@
> and copy[copyto[f]] == f)):
> dodiff = False
> else:
> header.append('deleted file mode %s\n' %
> gitmode[man1.flags(f)])
> + if util.binary(to):
> + dodiff = 'binary'
> elif not to or util.binary(to):
> # regular diffs cannot represent empty file deletion
> losedatafn(f)
> else:
> oflag = man1.flags(f)
> diff --git a/tests/test-diff-upgrade.t b/tests/test-diff-upgrade.t
> --- a/tests/test-diff-upgrade.t
> +++ b/tests/test-diff-upgrade.t
> @@ -198,20 +198,25 @@
> deleted file mode 100644
>
> % git=auto: git diff for rmbinary
> diff --git a/rmbinary b/rmbinary
> deleted file mode 100644
> - Binary file rmbinary has changed
> + index f76dd238ade08917e6712764a16a22005a50573d..0000000000000000000000000000000000000000
> + GIT binary patch
> + literal 0
> + Hc$@<O00001
> +
>
> % git=auto: git diff for bintoregular
> diff --git a/bintoregular b/bintoregular
> index f76dd238ade08917e6712764a16a22005a50573d..9c42f2b6427d8bf034b7bc23986152dc01bfd3ab
> GIT binary patch
> literal 13
> Uc$`bh%qz(+N=+}#Ni5<5043uE82|tP
>
>
> +
Hmm, I couldn't quickly figure out why your dodiff='binary' changed
this second test (by adding a new line). Does anyone else know why?
More information about the Mercurial-devel
mailing list