#!/usr/bin/awk -f BEGIN { # Change these to the parent and child paths in the repo parentpath = "//depot/vendor/freebsd/" childpath = "//depot/user/rwatson/tcp/" } $1 == "====" { last_line = $0 last_filename = $2 gsub(parentpath, "", last_filename) gsub(/#[0-9]*$/, "", last_filename) did_sub = 0 } $1 == "====" && $2 == "" { new_file = $4 gsub(childpath, "", new_file) gsub(/#[0-9]*$/, "", new_file) old_sep=OFS OFS="" print "#!/bin/sh" > "/tmp/awkdiff_make_diff" print "p4 print ", $4, " | sed '/^\\/\\/depot/d' > /tmp/awkdiff_foo" >> "/tmp/awkdiff_make_diff" print "diff -u /dev/null /tmp/awkdiff_foo | sed s@/tmp/awkdiff_foo@", new_file, "@" >> "/tmp/awkdiff_make_diff" close("/tmp/awkdiff_make_diff") OFS=old_seP system("sh /tmp/awkdiff_make_diff") # print $0 } $1 == "====" && $2 == "<" && $3 == "none" && $4 == ">" { new_file = $6 gsub(childpath, "", new_file) gsub(/#[0-9]*$/, "", new_file) old_sep=OFS OFS="" print "#!/bin/sh" > "/tmp/awkdiff_make_diff" print "p4 print ", $6, " | sed '/^\\/\\/depot/d' > /tmp/awkdiff_foo" >> "/tmp/awkdiff_make_diff" print "diff -u /dev/null /tmp/awkdiff_foo | sed s@/tmp/awkdiff_foo@", new_file, "@" >> "/tmp/awkdiff_make_diff" close("/tmp/awkdiff_make_diff") OFS=old_seP system("sh /tmp/awkdiff_make_diff") # print $0 } $1 == "====" && $4 == "" { del_file = $2 gsub(parentpath, "", del_file) gsub(/#[0-9]*$/, "", del_file) old_sep=OFS OFS="" print "#!/bin/sh" > "/tmp/awkdiff_make_diff" print "p4 print ", $2, " | sed '/^\\/\\/depot/d' > /tmp/awkdiff_foo" >> "/tmp/awkdiff_make_diff" print "diff -u /tmp/awkdiff_foo /dev/null | sed s@/tmp/awkdiff_foo@", del_file, "@" >> "/tmp/awkdiff_make_diff" close("/tmp/awkdiff_make_diff") OFS=old_seP system("sh /tmp/awkdiff_make_diff") # print $0 } $1 == "====" && $4 == "<" && $5 == "none" && $6 == ">" { del_file = $2 gsub(parentpath, "", del_file) gsub(/#[0-9]*$/, "", del_file) old_sep=OFS OFS="" print "#!/bin/sh" > "/tmp/awkdiff_make_diff" print "p4 print ", $2, " | sed '/^\\/\\/depot/d' > /tmp/awkdiff_foo" >> "/tmp/awkdiff_make_diff" print "diff -u /tmp/awkdiff_foo /dev/null | sed s@/tmp/awkdiff_foo@", del_file, "@" >> "/tmp/awkdiff_make_diff" close("/tmp/awkdiff_make_diff") OFS=old_seP system("sh /tmp/awkdiff_make_diff") # print $0 } $1 != "====" { if (!did_sub && (($1 == "***************") || ($1 == "@@"))) { print "--- ", last_filename ".orig" print "+++ ", last_filename print $0 did_sub = 1 } else { print $0 } } END { system("rm /tmp/awkdiff_foo") system("rm /tmp/awkdiff_make_diff") }