RE: [p4] the problems of migrating due to competing keywords ...
Jay Glanville <jay.glanville <at> naturalconvergence.com>
2004-12-01 19:12:11 GMT
> Hello all.
>
> I'm in the process of migrating my code from my old SCM to Perforce
> (yea!). What I'm doing is taking about a dozen important
> snapshots from
> my old system, and then adding them to perforce.
>
> The problem is in the keyword substitution. I don't know if I can
> explain it, so I'll example it.
>
> Lets say I've got too files a.c and b.c. Both have the
> Revision keyword
> in their comments. Now, in the first snapshot that I export
> from my old
> system, both a.c and b.c are version 10. So, I check them into
> Perforce. In P4, they now have revision 1. This makes sense to me.
> Now, I check out my second snapshot from the old SCM. In
> this snapshot,
> a.c hasn't changed (revision 10) and b.c has (revision 11).
> Now, when I
> ask P4 to find the files that have changed, of course it thinks that
> both a.c and b.c have changed. (It thinks a.c has changed due to the
> fact that a diff performed on it returns a delta.)
>
> Should I just resign myself to the fact that perforce is
> going to think
> that in every snapshot I'm migrating that everything has changed? Or,
> is there a way to tell perforce that if a file's contents have changed
> only in the area of it's keyword substitution area, that it really
> hasn't changed?
>
> Thanks.
Well, with all your help, I've come up with a workable solution.
Basically, it's a script that parses the output of the 'p4 diff -se'
command, then performs an external diff on the file ignoring anything
that matches the regular expression "$(Id|Revision|Date|Author).*$".
The files that are remaining are files that actually have a difference.
I've attached my script below in case others might find it useful in the
future.
Again, thanks for all your suggestions.
----------------- find_p4_diff ------------------------
#!/usr/bin/bash
#
# Tries to find all commands that have been modified but are not
existing
# in a change list, where the changes are more then just revision number
# changes.
#
# note: the P4DIFF variable needs to be set to the GNU diff command,
using
# the 'ignore reg ex' parameter. Something like this:
# p4 set P4DIFF="diff --ignore-matching-lines=$Revision:"
p4 set P4DIFF="diff
--ignore-matching-lines='\$\(Header\|Revision\|Author\|Date\|Id\).*\$'"
# find all files that have been modified but are not in the change list
for filename in `p4 diff -se`
do
# for a specific file ...
# diff the file and ignore the P4 diff header (starting with "====")
diff_output=`p4 diff -f ${filename} | grep -v "^===="`
# if the resulting output of the diff command is not empty ...
if [ -n "$diff_output" ]
then
# open this file for editing
p4 edit $filename
#echo "opening for edit $filename"
#echo "${diff_output}"
else
echo "skipping $filename as it's only revision different"
fi
done
----------------- find_p4_diff ------------------------
--
Jay Glanville
_______________________________________________
perforce-user mailing list - perforce-user <at> perforce.com
http://maillist.perforce.com/mailman/listinfo/perforce-user