my_question
my_question

Reputation: 3235

perforce: how to find the changelist which deletes a line for a file?

So I just found that someone removed a line from a "global" file and the removal is very likely wrong. I need to trace which changelist did the removal, but it is a global file, everyone edits it from many branches. I randomly picked a couple, they both have that line. Any suggestion to do this more systematically?

Upvotes: 1

Views: 124

Answers (2)

Grzegorz
Grzegorz

Reputation: 3335

I would suggest collecting all change# of the file, then using binary search, grabbing each of the change, and grepping for specific line you are looking for, and the character '-' or '<' (depends on your du setting) in the first line.

The line below will give you all the changes:

p4 filelog yourfile.cpp | egrep "^... \#[0-9]+ change" | cut '-d ' -f 4

If you do not want to do binary search manually or write a code to do that in shell or anything else, then I would suggest a brute force, and scan all changes in search for that line. For example:

p4 filelog yourfile.cpp | egrep "^... \#[0-9]+ change" | cut '-d ' -f 4 | while read change ; do
    p4 describe $change | egrep "^<.*your line that was deleted"
    [ $? = 0 ] && echo $change
done

Output in my example: < /* remove the confirmation record for the outstanding write if found */ 234039

Where 234039 is the change number that contains your deletion.

I hope it will help.

Upvotes: 0

Mike O&#39;Connor
Mike O&#39;Connor

Reputation: 3813

Time-lapse view is a really good tool for this. You can check out this video for a better idea of how it works.

Upvotes: 2

Related Questions