2
votes

I have two perforce workspace roots in the same directory on Windows. For example:

C:\Perforce_windows_workspaces\wkspc1

C:\Perforce_windows_workspaces\wkspc2

I need to rename the folder "Perforce_windows_workspaces" to something smaller (say p4wkspcs), so that the new paths to the roots will be:

C:\p4wkspcs\wkspc1

C:\p4wkspcs\wkspc2

respectively.

Will renaming the folder directly in the file system lead to any issues in the root mappings? If so, how can I go about reflecting those changes in the P4V application?

2
I do not want to mess up my workspaces as too many files are synced there . - aman

2 Answers

8
votes

Definition form of Perforce workspace contains root directory field that can be changed.

To change the workspace root without transferring all data from perforce do following steps:

  1. Go to P4V, View > Workspaces. Then right-click on the workspace and pick "Edit workspace '...'". Change the workspace root and confirm the change without synchronizing the workspace. (You will be prompt to sync the workspace; cancel that operation)
  2. Rename the directory on the file system
  3. Perform synchronization check to verify that everything is all right.

    p4 sync -n //client.name/...

  4. P4V will still show the old path in the workspace view. Go to "Search->Filter Workspace->Workspace Root" and it will be updated.

The order of step 1 and 2 doesn't matter.

1
votes

From the command line:

p4 -c wkspc1 --field Root=C:\p4wkspcs\wkspc1 client -o | client -i
p4 -c wkspc2 --field Root=C:\p4wkspcs\wkspc2 client -o | client -i
ren C:\Perforce_windows_workspaces C:\p4wkspcs

This handles the actual renaming -- if you had a large number of workspaces this is obviously pretty easy to script. If you're using an old client and --field doesn't work, you can do the first two commands as just:

p4 -c wkspc1 client
p4 -c wkspc2 client

and edit the "Root:" field manually.

To double-check you didn't make a typo and that the rename worked right, do:

p4 -c wkspc1 diff -sd
p4 -c wkspc2 diff -sd

These should both return no output (they're checking to see if any files you've previously synced are no longer present in their expected locations).


From P4V, you will need to switch to each workspace individually and edit the workspace to change the Root field. You can't rename the folder itself from P4V; open an Explorer window and do the rename there. You can use "Reconcile" or "Folder Diff" to verify correctness once everything is done.