Re: p4 diff notes..

2001-08-07 Thread Kenneth D. Merry

On Tue, Aug 07, 2001 at 09:36:01 -0700, John Baldwin wrote:
> 
> On 07-Aug-01 Julian Elischer wrote:
> > 
> > I have pushed the thread pointers down through most of the code
> > though there are still many many places that assume that there is only one
> > thread per process. (no multithreading yet, but getting closer..)
> > 
> > At this stage diffs must be pushing close to 1MB (maybe more)
> > (I don't know as I don't know yet how to get p4 to generate diffs :-)
> 
> It's not too hard.  I have the smpng and jhb_preemption batches updating
> diff's on freefall via cron. :)
> 
> To do a diff of files against files you have checked out, you use 'p4 diff'
> such as 'p4 diff -du ...' to get a unified diff.  Unfortunately, p4's diff
> format isn't too patch friendly.  There is also a 'p4 diff2' which does a
> diff of files in the depot.  p4 diff2 has an undocumented (well, it's
> documented in 'p4 help undoc') option -u that will produce a unified diff that
> patch can grok (albeit, it has the full depot path, so you'll have to use -p6
> or some such to apply it).  If you had a julian_kse branch off of the kse
> branch you would use 'p4 diff2 -u -b julian_kse' to get a diff of the entire
> branch.  You can use 'p4 diff2 -u -b kse' to get a diff of the kse branch
> against the head, but unfortunately it does a diff against the head of the
> -current vendor import rather than against the latest files you last integrated
> from.

According to the docs, p4 diff2 -u only produces diffs on files that are in
both paths and differ.  So files that are added in one branch won't be
shown.

Attached is an awk script that was originally written by Justin (hacked up
by me somewhat) that I use on my zero copy branch to fix up the perforce
diff output.  It will produce diffs for files that are only in one branch.

So basically I use it like this:

p4 diff2 -dc //depot/FreeBSD-current/src/... //depot/FreeBSD-zero/src/... > foo

cat foo | awk -f awkdiff.zero > diffs.fixed

Ken
-- 
Kenneth Merry
[EMAIL PROTECTED]


$1 == ""{
last_line = $0
last_filename = $2
gsub(/\/\/depot\/FreeBSD-zero\/src/, "src", last_filename)
gsub(/\/\/depot\/FreeBSD-current\/src/, "src", last_filename)
gsub(/#[0-9]*$/, "", last_filename)
did_sub = 0
}
$1 == ""  && $2 == "<" && $3 == "none" && $4 == ">" {
new_file = $6
gsub(/\/\/depot\/FreeBSD-zero\/src/, "src", new_file)
gsub(/\/\/depot\/FreeBSD-current\/src/, "src", new_file)
#   gsub(/\/usr\/home\/ken\/perforce\/cam/, "src", new_file)
gsub(/#[0-9]*$/, "", new_file)
old_sep=OFS
OFS=""
print "#!/bin/sh" > "/tmp/make_diff"
print "p4 print ", $6, " | sed '/^\\/\\/depot/d' > /tmp/foo" >> 
"/tmp/make_diff"
print "diff -c /dev/null /tmp/foo | sed s@/tmp/foo@", new_file, "@" >> 
"/tmp/make_diff"
close("/tmp/make_diff")
OFS=old_sep
system("sh /tmp/make_diff")
#   print $0
}
$1 != ""{
if (!did_sub && $1 == "***") {
print "***", last_filename ".orig"
print "---", last_filename
print $1
did_sub = 1
} else {
print $0
}
}



p4 diff notes..

2001-08-07 Thread John Baldwin


On 07-Aug-01 Julian Elischer wrote:
> 
> I have pushed the thread pointers down through most of the code
> though there are still many many places that assume that there is only one
> thread per process. (no multithreading yet, but getting closer..)
> 
> At this stage diffs must be pushing close to 1MB (maybe more)
> (I don't know as I don't know yet how to get p4 to generate diffs :-)

It's not too hard.  I have the smpng and jhb_preemption batches updating
diff's on freefall via cron. :)

To do a diff of files against files you have checked out, you use 'p4 diff'
such as 'p4 diff -du ...' to get a unified diff.  Unfortunately, p4's diff
format isn't too patch friendly.  There is also a 'p4 diff2' which does a
diff of files in the depot.  p4 diff2 has an undocumented (well, it's
documented in 'p4 help undoc') option -u that will produce a unified diff that
patch can grok (albeit, it has the full depot path, so you'll have to use -p6
or some such to apply it).  If you had a julian_kse branch off of the kse
branch you would use 'p4 diff2 -u -b julian_kse' to get a diff of the entire
branch.  You can use 'p4 diff2 -u -b kse' to get a diff of the kse branch
against the head, but unfortunately it does a diff against the head of the
-current vendor import rather than against the latest files you last integrated
from.

To make the diff relative to when you last branched, you can use a revision
specification to refer to the state of the -current tree when you last did your
integrate.  To do this, look up the change number of your last integrate from
-current, (right now 448 was your last MFC for example).  You then generate a
diff between -current as of that change number and the head revision of your
branch (see 'p4 help revisions' or the revisions section of the quickstart
guide) like so:

> p4 diff2 -u -b kse @448 #head

However, having to look up the change number for diff's is a minor pain, and
makes it harder to automate things (like generating diff's in crontabs).
What you can do is create a label that tracks -current and is the last
branch point.  First, you want to create a label whose View is the same as the
files your branch branches from.  For example:

> p4 branch -o smpng
...
Branch: smpng
...
View:
//depot/vendor/freebsd/sys/... //depot/projects/smpng/sys/...
> p4 label -o smpng_base
Label:  smpng_base
...
Description:
Label that tracks the smpng branch's 'base', i.e. the last
change imported from the FreeBSD current branch.
...
View:
//depot/vendor/freebsd/sys/...

You use 'p4 label' to create a label (set its View, description, etc.)  You use
'p4 labelsync' to actually determine what revisions of what files the label
applies to.  If you created a kse_base label, then you would start off by
specifying it as the last change you integrated from (448) like so:

> p4 labelsync -l kse_base @448

You can then do diff's like so:

> p4 diff2 -u -b kse @kse_base #head

Keeping the label up to date is fairly easy.  When you want to do an integrate,
simply follow these steps:

> p4 labelsync -l kse_base #head
> p4 integrate -b kse @kse_base
> p4 resolve -a
> p4 resolve
> p4 submit

Note that you can update the label of individual files as well if you wish. 
For example, my last integrate into smpng just brought across a commit to
sys/i386/isa/ipl.s rather than updating the entire tree:

> p4 integrate -b smpng sys/i386/isa/ipl.s
> p4 resolve -a
> p4 submit

I then updated the label on just that file like so:

> p4 labelsync -l smpng_base //depot/vendor/freebsd/sys/i386/isa/ipl.s#head

I usually keep my work trees off of the smpng branch up to date with the smpng
branch, so I don't have to bother with label's on those.  This allows you to
get things working on a stable snapshot of current, and later do an integrate
to catch up.

Note that you could of done the MFC of one file as so:

> p4 labelsync -l smpng_base //depot/vendor/freebsd/sys/i386/isa/ipl.s#head
> p4 integrate -b smpng @smpng_base
> p4 resolve -a
> p4 submit

HTH.

-- 

John Baldwin <[EMAIL PROTECTED]> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.baldwin.cx/~john/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message