Home   Notes   Contact Me

Perforce


Linux Version

# make sure to set P4VResources, for example export P4VResources=/usr/bin/P4VResources

Copy files to another branch with history

What this accomplishes:

In P4V

  1. Determine where in the depot where the original files are. Example place: //depot/common/boost
  2. Determine where in the depot you want the files to be branched to (copied to). Example place: //depot/workInProgress/projectA/boost
  3. Create a branchspec that describes the operation Specs | New | Branchspec...
  4. Provide a descriptive name for the branchspec
  5. Describe the branch operation to the branchspec by filling in the View: field. Example
    //depot/common/boost/... //depot/workInProgress/projectA/boost/...
    Note that it uses standard Perforce wildcard rules.
  6. Execute the branch to copy the files to the new location, by doing the following
    In the workspace tree view (TODO: what happens if this is done on the Depot tree view ???), at a directory that is above the directory to copy to,
    Context Menu | Integrate | Branch Specification then use Browse to choose the branchspec you made.
  7. It is best to do a Preview now to verify the branchspec does what you expect.
  8. To do the branch, click on Integrate
  9. You can now look and see that the files are on your system where you expect them to be
  10. You must commit your pending changelist to commit the changes back to the repository

Note: I bet that if you do this on the depot (instead of a workspace), that it copies the files on the depot side, and you don't get them in your workspace until you sync it again. This would bypass the commit step.

I expect you can run the branchspec again to migrate changes from the original location to the destination location whenever needed.

AND that you could run it again in reverse to migrate changes back to the original location.


Moving files

In P4V

  1. Determine the destination path in the depot
  2. Your current workspace must contain the destination path (you will have to create this in most circumstances)
  3. You can either Create a banchspec for the moving, or just type in the branch information as you integrate
  4. To create a brancspec Specs | New | Branchspec... and fill in the mappings from original position to the new position
  5. Do an integrate on some depot directory that contains both the source and destination directories
  6. If you created a branchspec, choose it on the Branch Specification page
  7. If not using a branchspec choose File Specification page and just type in the source and dest information
  8. Optional: do a preview before integrating, to make sure it does what you expect
  9. Press the Integrate button to copy the files
  10. ? is a resync needed?
  11. The files are now copied (with memory of where they came from, so history can be seen)
  12. Delete the files from there original location by using Perforces Open for Delete option
  13. Do a resync to remove the original files

Deleting a Workspace

In P4V

  1. Make the Workspace you want to delete be the current one
  2. Select the Workspace you want to delete in the Client Workspace view View | Client Workspaces
  3. Then delete it via Specs | Delete Workspace 'Name of Workspace'

Loading a Workspace

In P4V

  1. In the combo box above the view of the Depot or Workspace, choose
    Browse Workspaces ...
  2. Choose the workspace you want to load
  3. The combo should now show the name of the workspace you want to load
  4. Sync to head and Perforce will get the files

Copying a Workspace

In P4V

  1. Make sure the Workspace you want to copy is sync'd
  2. Find the workspace you want to copy and highlight it.
  3. Do the copy via: Specs | Create new workspace from 'name of one to copy'

Directory Mapping from Depot to Workspace

Components of Mapping Strings

ComponentDescription
...All files and sub directories from here down
*Dual purpose, it is both a wildcard, and prevents the matching from going into sub directories
-This prefix causes whatever comes next to be excluded
%%1
%%2
%%{n}
Wildcards for remapping

Examples of Mappings

ExampleDescription
//depot/src/... /work/src/...Basic Mapping of files and directories in "//depot/src/" to same named files and directorys in "$ROOT/work/src"
//depot/src/%%1.h //work/src/headers/%%1.hThe headers (files ending in .h) in the depot now get placed into the local directory "$Root/work/src/headers. Note that %%1 is the wildcard string.
//depot/....CC //work/....cpp Renames the depot files with the extension .CC to local files with the extension .cpp
-//depot/src/tests/... //work/src/tests the - makes the files that match the Depot path be excluded. The Workspace path is not relavent in this case (? is it optional though ?, I doubt it)
//depot/doc/%%2/%%1/... //work/%%1/doc%%2/... Depot files get placed on the local system in a different directory whose name is created by rearraging the path components in the postions of the wildcards and prefixing doc on to part of the new directory.

Backing out of file changes

This does _NOT_ delete the bad file(s), but makes a new revision(s) without the change(s).

  1. Warning: This only lets you back out of the head revision(s)
  2. Sync to Previous revision of the file(s).
  3. Open for edit the file(s) you want to revert
  4. Submit and only check the file(s) you want to back out changes on.
  5. Sync | All Unsynched Files in Changelist
  6. Resolve
  7. In the Auto-resolve dialog Accept yours (-ay)

Backing out of a change list

This does _NOT_ delete the bad list, but makes a new list without the bad stuff in it.

  1. Warning: This only lets you back out of the head change list
  2. Sync to Previous Change list
  3. Open for edit the files you want to revert
  4. Submit
  5. Sync | All Unsynched Files in Changelist
  6. Resolve
  7. In the Auto-resolve dialog Accept yours (-ay)

Multiple Change Lists

Useful for when you are in the middle of coding, and you need to do a quick fix on a subset of files in(??) or out of your set of changes.


Changing Repository Attributes for a file

With P4V


Removing files locally (but leaving them in the repository)

[P4V] In workspace, select the files or their directory and then {context} | Remove from Workspace


Differences

What to DiffClientAction
Change ListsP4V Depot Pane context on directory | Folder History shows the history, drag and drop 2 changelists to see the differences
File RevisionsP4V

Ranges, specifying

? Is using a comma always the way to do it ?

TypeExample
Changelist50,250

Undeleting a file

[P4V] While looking at files, click on the filter dropdown button and choose Show Deleted Depot Files


Reverting local changes at Submit time

On the pending changelist {context menu} | Revert Unchanged Files


Determining which local files have changes

? flags to command line diff ?


Submit a changelist via the Command Line

Note: This assumes that you have already created a changelist to submit (probably through a gui tool). These instructions exist because the gui crashes with submits of large changelists (of over 100k files)

  1. Make sure you are in the workspace directory tree (this may be optional)
  2. Use p4 info to see what your settings are.
  3. The entry Client name: shows the name of your current workspace.
  4. To set the current workspace set the environment variable P4CLIENT to the name of the workspace you want to use.
  5. Submit the current changelist through the command p4 submit

Changelists via the command line

# create one that includes all 'p4 opened' files p4 change # see what changelists files are in p4 opened # change the changelist comment p4 change {changelist number} # submitting a changelist p4 submit -c {changelist number}

Command Line usage

Command Line Recipes

CommandInfo
p4 help
p4 help {command}
p4 client
p4 client -d {clientWorkspaceName}delete specified client workspace
p4 openedShows the files that are marked being edited
p4 sync
p4 sync #noneDo this before changing the workspace paths (removes all the files)