[PATCH] Add 'shelltools': diff tool detection (try to find GNU diff)

Mads Kiilerich mads at kiilerich.com
Mon Jul 6 03:10:30 CDT 2009


David Champion wrote, On 07/06/2009 04:33 AM:
> # HG changeset patch
> # User David Champion<dgc at uchicago.edu>
> # Date 1246847552 18000
> # Node ID b662b90acf147e5d264a083ed6302b3fc6ea82c3
> # Parent  95046688f80fbe481241ed3affeed205ce378b7e
> Add 'shelltools': diff tool detection (try to find GNU diff).
>
> diff -r 95046688f80f -r b662b90acf14 tests/shelltools
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/tests/shelltools	Sun Jul 05 21:32:32 2009 -0500
> @@ -0,0 +1,9 @@
> +#!/bin/sh
> +#
> +# Detect some shell programs.  This file is sourced from other shells,
> +# so it should do nothing to irreversibly affect the current process.
> +#
> +
> +# Detect and use GNU diff as diff, if available as 'gdiff'.
> +_diff=`gdiff>/dev/null 2>&1&&  echo gdiff || which diff`
> +diff () { "$_diff" "$@"; }
>    

runtests.py already checks for the existence of "diff" (but doesn't 
notice that sun diff isn't good enough). To silently use gdiff on 
runtime would be confusing for the next guy with diff problems.

Perhaps it would be better if your detection functionality could be 
integrated with runtests.py and set a DIFF environment variable?

And it seems like both test-convert-hg-sink and test-hardlinks-safety 
and test-keyword and test-rename uses diff too - but apparently without 
problems?

BUT I don't think this is the right approach. gdiff might be better than 
diff on your platform, but on other platforms it might be the opposite. 
It would be better to make "diff must be available and sufficiently 
similar to GNU diff" a prerequisite. Obviously, that is how it de facto 
is now - it just has to made explicit.

/Mads



More information about the Mercurial-devel mailing list