mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-18 10:35:55 +00:00
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...
This commit is contained in:
parent
3419bf0107
commit
d1522a3ba7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=270727
42
tools/tools/perforce/awkdiff
Executable file
42
tools/tools/perforce/awkdiff
Executable file
@ -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
|
||||||
|
}
|
||||||
|
}
|
19
tools/tools/perforce/p4diffbranch
Executable file
19
tools/tools/perforce/p4diffbranch
Executable file
@ -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"
|
Loading…
Reference in New Issue
Block a user