[p4ruby] diff output

Here is an example of overlaying a "run_describe" to make it more usable for
a situation specific to my application. This might be general enough for
someone else, and might not, but shows a very reasonable way to overlap a
p4.run("describe"............) call. Note that p4.run_describe(.......) does
the postprocessing but p4.run('describe'.......) does not.
Again, use the interface to make it right - the P4Perl intention, as Tony
explained it when he did it, was that you could build on top of this as you
needed but that it would get out of your way if you wanted.
I have done similar things for "p4.run_depots" (to call 'p4.run("depots")
once, and then cache the results for the rest of the run of the application)
and "p4.run_print" (since the output of 'p4.run("print".....)' gives me
chunks of the file that need to be reassembled.
-Jeff Bowles
require "P4"
# vim: set ts=4:
class P4
def run_describe(*args)
#
# Like 'run_filelog', we use this to get
# useful information back from 'p4 describe'.
#
# The result is a hash:
# user / time / client /desc /change
# are like output of "p4.run('describe')", but
# also included in the hash is:
# revisions
# These are of type P4Revision and have some
# redundant information, but have parsed the
# 'p4 describe' nonsense into meaningful sets
# of (file, revision, action, type) rows.
#
raw = self.run('describe', args.flatten)
results = raw.collect do
|h|
result = {}
['time', 'user', 'client', 'desc', 'change'].each do
|s|
result[s] = h[s]
end
result['revisions'] = []
next if h['rev'] == nil
h['rev'].each_index do
|i|
df = P4DepotFile.new(h['depotFile'][i])
r = df.new_revision
r.revno = h['rev'][i]
r.action = h['action'][i]
r.type = h['type'][i]
r.desc = h['desc']
r.time = h['time'].to_i
r.user = h['user']
r.client = h['client']
r.change = h['change'].to_i
result['revisions'].push(r)
end
result
end
results
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://maillist.perforce.com/pipermail/p4ruby/attachments/20080312/1802a4c0/attachment-0001.html>