Date: Wed, 27 Aug 2014 18:56:12 +0000 (UTC) From: John-Mark Gurney <jmg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r270727 - head/tools/tools/perforce Message-ID: <201408271856.s7RIuCL9023312@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jmg Date: Wed Aug 27 18:56:12 2014 New Revision: 270727 URL: http://svnweb.freebsd.org/changeset/base/270727 Log: add scripts for generating a diff from p4... awkdiff is the script from scottl that he got from ken a long time ago... It no longer lives in his home dir, so give it a new home... This does simple massaging of p4 output to create a useful diff... The script p4diffbranch will create a diff that includes new and deleted files unlike the normal diff2 -b command... So will be useful for extracting patches from p4... It does take a changeset that will be used to diff against... Added: head/tools/tools/perforce/ head/tools/tools/perforce/awkdiff (contents, props changed) head/tools/tools/perforce/p4diffbranch (contents, props changed) Added: head/tools/tools/perforce/awkdiff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/tools/perforce/awkdiff Wed Aug 27 18:56:12 2014 (r270727) @@ -0,0 +1,42 @@ +#!/usr/bin/awk -f +# +# $FreeBSD$ +# + +BEGIN { + #parentpath = "//depot/vendor/freebsd/src/sys/" + #childpath = "//depot/projects/opencrypto/" +} +$1 == "====" { + last_line = $0 + last_filename = $2 + #gsub(parentpath, "", last_filename) + gsub(/#[0-9]*$/, "", last_filename) + did_sub = 0 +} +$1 == "====" && $2 == "<none>" { + new_file = $4 + gsub(childpath, "", new_file) + gsub(/#[0-9]*$/, "", new_file) + cmd = "p4 print \"" $4 "\" | sed '/^\\/\\/depot/d' | diff -u /dev/null /dev/stdin | sed s@/dev/stdin@" new_file "@" + #print "x" cmd "x" + system(cmd) +} +$1 == "====" && $4 == "<none>" { + del_file = $2 + gsub(parentpath, "", del_file) + gsub(/#[0-9]*$/, "", del_file) + cmd = "p4 print \"" $2 "\" | sed '/^\\/\\/depot/d' | diff -u /dev/stdin /dev/null | sed s@/dev/stdin@" del_file "@" + #print "x" cmd "x" + system(cmd) +} +$1 != "====" { + if (!did_sub && (($1 == "***************") || ($1 == "@@"))) { + print "--- ", last_filename ".orig" + print "+++ ", last_filename + print $0 + did_sub = 1 + } else { + print $0 + } +} Added: head/tools/tools/perforce/p4diffbranch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/tools/perforce/p4diffbranch Wed Aug 27 18:56:12 2014 (r270727) @@ -0,0 +1,19 @@ +#!/bin/sh - +# +# $FreeBSD$ +# + +if [ x"$#" != x"2" ]; then + echo "Usage: $0 <branch> <changesetnum>" + exit 1 +fi + +basescript="$(realpath "$0")" +awkdiff="${basescript%/*}/awkdiff" + +branch="$1" +changenum="$2" + +p4 branch -o "$branch" | + awk ' /^View:/ { doview = 1; next; } /^[^ ]/ {doview = 0; next; } $1 && $2 && doview == 1 { system("p4 diff2 -du " $1 "@" changenum " " $2) }' changenum="$changenum" | + "$awkdiff"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408271856.s7RIuCL9023312>