Renaming workspace root path in perforce

11,870

Solution 1

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.

Solution 2

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.

Share:
11,870
aman
Author by

aman

don't know much about myself. novice programmer trying to work up the staircase.

Updated on September 07, 2022

Comments

  • aman
    aman over 1 year

    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?

  • aman
    aman almost 7 years
    I do not get the entire picture here, Should I rename the folder in the file system first and then make the changes to the workspace root from P4V? Or the other way around?
  • Bartek Kobyłecki
    Bartek Kobyłecki almost 7 years
    The order of these steps shouldn't matter as long as you sync at the end. Move/rename your directories, change workspace root, then p4 sync.
  • aman
    aman almost 7 years
    There lies my problem. I do not want to sync again (the workspace sizes are to the tune of about 40GB each!). I just want to ensure that all future actions will not be affected if I rename the root folder. Really want to be sure, because otherwise it'll add up to 2 days of work on rebuilding the workspaces if something goes wrong.
  • Bartek Kobyłecki
    Bartek Kobyłecki almost 7 years
    If you rename folders and workspace root accordingly you should not need to transfer any data from perforce server, all revisions will be already in the workspace. The sync command allows you to verify that you don't mistyped the root name.
  • Bartek Kobyłecki
    Bartek Kobyłecki almost 7 years
    I renamed few workspace roots in the past and I didn't have any problems with it.
  • Samwise
    Samwise almost 7 years
    The "p4 sync -n" will do nothing here. I'd recommend doing a "p4 status" or similar -- if it shows that all your files have been deleted, something is wrong!