Mercurial > hg
view tests/pdiff @ 31950:cc70c6dbac30
util: add a way to issue deprecation warning without a UI object
Our current deprecation warning mechanism relies on ui object. They are case
where we cannot have access to the UI object. On a general basis we avoid using
the python mechanism for deprecation warning because up to Python 2.6 it is
exposing warning to unsuspecting user who cannot do anything to deal with them.
So we build a "safe" strategy to hide this warnings behind a flag in an
environment variable. The test runner set this flag so that tests show these
warning. This will help us marker API as deprecated for extensions to update
their code.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 04 Apr 2017 11:03:29 +0200 |
parents | 869e65e68aee |
children | a2b55ee62803 |
line wrap: on
line source
#!/bin/sh # Script to get stable diff output on any platform. # # Output of this script is almost equivalent to GNU diff with "-Nru". # # Use this script as "hg pdiff" via extdiff extension with preparation # below in test scripts: # # $ cat >> $HGRCPATH <<EOF # > [extdiff] # > pdiff = sh "$RUNTESTDIR/pdiff" # > EOF filediff(){ # USAGE: filediff file1 file2 [header] # compare with /dev/null if file doesn't exist (as "-N" option) file1="$1" if test ! -f "$file1"; then file1=/dev/null fi file2="$2" if test ! -f "$file2"; then file2=/dev/null fi if cmp -s "$file1" "$file2" 2> /dev/null; then # Return immediately, because comparison isn't needed. This # also avoids redundant message of diff like "No differences # encountered" (on Solaris) return fi if test -n "$3"; then # show header only in recursive case echo "$3" fi # replace "/dev/null" by corresponded filename (as "-N" option) diff -u "$file1" "$file2" | sed "s@^--- /dev/null\(.*\)\$@--- $1\1@" | sed "s@^\+\+\+ /dev/null\(.*\)\$@+++ $2\1@" } if test -d "$1" -o -d "$2"; then # ensure comparison in dictionary order ( if test -d "$1"; then (cd "$1" && find . -type f); fi if test -d "$2"; then (cd "$2" && find . -type f); fi ) | sed 's@^\./@@g' | sort | uniq | while read file; do filediff "$1/$file" "$2/$file" "diff -Nru $1/$file $2/$file" done else filediff "$1" "$2" fi