Saturday 18 December 2010

Changing File Case

Change the case of a file on a Perforce Server.

The solution to changing the case of files depends on the native case-handling behavior of your platform. For platforms with case-sensitive file systems (for example, Linux), the case change operation is a straightforward rename. On Windows, additional steps have to be taken to account for the fact that the NTFS file system largely ignores case differences; it is case-aware, but case-insensitive.

Because Windows uses a case-insensitive file system, references to files that differ only by case are ignored. In order to get the Perforce Server to change the case of a file on a Windows Server, the file must first be deleted and then re-added to Perforce using the correct case. Additionally, the internal Perforce "have list" references to the old case name must be eliminated by removing the file from case-insensitive workspaces and then re-syncing the file using the correct case.

Windows Example

In this example, file "foo" has three revisions and you want to change the file name to use all upper-case, from "foo" to "FOO".

Delete the existing file p4 delete foop4 submitRecreate the file in your local file system with the correct case. Then, use the p4 sync command to re-create the file in your workspace using the correct case. p4 sync FOO#3Remove the internal "have list" reference. The p4 flush command (sync -k, in recent versions) removes the have list reference without removing the file from your workspace. p4 flush FOO#noneRe-add the file in the correct case. As with the sync command, the p4 add command uses the case of the file argument provided at the command line, so it is important to provide the correct case. p4 add FOOp4 submit

Notes

To obtain the newly case-changed file, all users who use workspaces on case-insenstive file systems (such as Windows NTFS or MacOS X HFS) must remove the old file from their workspace and then re-sync the renamed file with the correct case to replace it in their workspace.

For the example above, this means:

p4 sync foo#none
p4 sync FOO#head

On Unix, simply integrate the file and delete the original file.

Unix example

Use p4 integrate to change the old name to the new name. $ p4 integrate kiwi.txt Kiwi.txt//depot/Kiwi.txt#1 - branch/sync from //depot/kiwi.txt#1,#9Delete the original name. $ p4 delete kiwi.txt//depot/kiwi.txt#9 - opened for deleteSubmit the changes. $ p4 submitChange 12681 created with 2 open file(s).Submitting change 12681.Locking 2 files ...branch //depot/Kiwi.txt#1delete //depot/kiwi.txt#10Change 12681 submitted.

Verify the results

Use the p4 files command to check that the Perforce metadata is in the proper case.

$ p4 files Kiwi.txt//depot/Kiwi.txt#1 - branch change 12681 (text)

Note that "Kiwi.txt" is now in the proper case.

11 users have rated this article 2.7 out of 5

View the original article here

No comments:

Post a Comment