Re: patchfs update



OK an even better patchfs update :-)
It calls diffstat if present to display summary.
Also other cleanups.
Also attached patch to mc.ext so users
can browse patches by default.

Padraig.
#! /bin/sh

# Peter Daum    <gator cs tu-berlin de> (Jan 1998, mc-4.1.22)
#
#    Initial implementation.
#
# Padraig Brady <padraig linux ie>      (May 2002, mc-4.5.51)
#
#    Added support for unified diffs of files and not just directories,
#    i.e. when there is no "diff date file1 file2" line. Note patchfs
#    does not fully support context or "default" format diffs at present,
#    and will only display a SUMMARY of these type if diffstat is present.
#    I cleaned things up a lot and added support for viewing the SUMMARY
#    (previously called FILELIST) using diffstat if present.
#
# override any locale for dates. But LANG override LC_TIME (at least in glibc)
# unset LC_ALL
# LC_TIME=C
# export LC_TIME
LC_ALL=C
export LC_ALL

patchfs_list ()
{
    date=`date +"%b %d %H:%M"`
    perm="-r--r--r--"
    uid=00000000
    gid=00000000
    size=00000000
    nlink="  1"

    echo "$perm $nlink $uid $gid $size $date SUMMARY"
    $cat $1 | 
    sed -n "s/^+++ \([^ 	]*\).*/$perm $nlink $uid $gid $size $date \1/gp"
}

patchfs_copyout ()
{
    if [ "$2" = SUMMARY ]; then  # list of all affected files
	if diffstat -V >/dev/null 2>&1; then
            $cat $1 | diffstat 2>/dev/null > $3
        else
            sed -n "s/^+++ \([^ 	]*\).*/\1/gp" > $3
        fi
	exit 0
    fi
    
    fn=`echo $2 | sed 's|/|\\\/|g'`   # escape '/' in filename
    $cat $1 |
    sed -e '/^diff /d' |
    sed -ne "/^+++ .*$fn/,/^--- /{
                  /^--- /d
                  p
              }" > $3
}

patchfs_run ()
{
    exit 0
}

type=`file $2`
case $type in
    *bzip*) cat="bzip2 -dc" ;;
    *gzip*) cat="gzip -dc" ;;
    *text*) cat="cat" ;;
    *) exit 1
esac

umask 077
case "$1" in
    list) patchfs_list $2; exit 0;;
    copyout) patchfs_copyout $2 $3 $4; exit 0;;
    run) patchfs_run; exit 0;;
esac

exit 1
--- mc.ext.in.old	Fri May 31 13:10:38 2002
+++ mc.ext.in	Fri May 31 13:12:31 2002
@@ -388,6 +388,10 @@
 regex/\.(rexx|rex|cmd)$
        Open=rexx %f %{Enter parameters};echo "Press ENTER";read y
 
+# Patches
+regex/\.(patch|diff)\.*(gz|bz2)*$
+       Open=%cd %p#patchfs
+
 
 ### Archives ###
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]