summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjmg <jmg@FreeBSD.org>2014-08-27 18:56:12 +0000
committerjmg <jmg@FreeBSD.org>2014-08-27 18:56:12 +0000
commit68cdc022fe47fa173a7510245cc569a7e23c6547 (patch)
tree83f46069ca9fce6dc000140a427addce7adc1972 /tools
parent5b6f86660b1027969001eb178b29994c1896b046 (diff)
downloadFreeBSD-src-68cdc022fe47fa173a7510245cc569a7e23c6547.zip
FreeBSD-src-68cdc022fe47fa173a7510245cc569a7e23c6547.tar.gz
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...
Diffstat (limited to 'tools')
-rwxr-xr-xtools/tools/perforce/awkdiff42
-rwxr-xr-xtools/tools/perforce/p4diffbranch19
2 files changed, 61 insertions, 0 deletions
diff --git a/tools/tools/perforce/awkdiff b/tools/tools/perforce/awkdiff
new file mode 100755
index 0000000..380d6fa
--- /dev/null
+++ b/tools/tools/perforce/awkdiff
@@ -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
+ }
+}
diff --git a/tools/tools/perforce/p4diffbranch b/tools/tools/perforce/p4diffbranch
new file mode 100755
index 0000000..9d29f23
--- /dev/null
+++ b/tools/tools/perforce/p4diffbranch
@@ -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"
OpenPOWER on IntegriCloud