opnsense-src/tools/tools/perforce/awkdiff
John-Mark Gurney d1522a3ba7 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...
2014-08-27 18:56:12 +00:00

42 lines
1,005 B
Awk
Executable file

#!/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
}
}