[p4] How to handle refactoring ?

Jonathan Biggar jon at floorboard.com
Sun Oct 21 19:23:18 PDT 2001

Tal Dayan wrote:
> Hello,
> We are using IDEA as a Java IDE and as a refactoring tool
> (www.refactoring.com)
> and are not sure how to use Perforce for best results.
> Here is an example, we have a class /a/b/class1.java checked in Perforce.
> Now we use the Refactoring tool to rename the class from 'class1' to
> 'class2. IDEA
> deletes class1.java, creates class2.java and changes the source code of
> class2.java
> to reflect the name change (e.g. it renames the constructors).
> At this point, the file class1.java is gone and the file class2.java
> contains the
> modified code.
> Now we want to check this change back into Perforce such that we don't loose
> the history relation between class1 and class2 (that is, 'p4 integrate').
> Any idea how to handle this ?

Off the top of my head for UNIX:

mv class2.java class2.java.save		# save the modified code
p4 sync -f class1.java			# fetch back the old code
p4 integrate class1.java class2.java	# integrate old file to new file
p4 delete class1.java			# remove old file
p4 edit class2.java			# reopen new file for edit
mv class2.java.save class2.java		# restore modified code
p4 submit				# submit to p4

There might be something a bit simpler, and this is obvious fodder for a
script, probably without the submit so you can do multiple changes like

Jon Biggar
Floorboard Software
jon at floorboard.com
jon at biggar.org

More information about the perforce-user mailing list