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:
- Files are copied to the new location.
- Can be done again to refresh copied files (if the original files change).
- Can be used to propagate changes in the new locatation back to the original location.
- Provides a record of what happened (as a branchspec).
In P4V
- Determine where in the depot where the original files are. Example place:
//depot/common/boost
- Determine where in the depot you want the files to be branched to (copied to). Example place:
//depot/workInProgress/projectA/boost
- Create a branchspec that describes the operation Specs | New | Branchspec...
- Provide a descriptive name for the branchspec
- 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.
- 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.
- It is best to do a Preview now to verify the branchspec does what you expect.
- To do the branch, click on Integrate
- You can now look and see that the files are on your system where you expect them to be
- 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
- Determine the destination path in the depot
- Your current workspace must contain the destination path (you will have to create this in most circumstances)
- You can either Create a banchspec for the moving, or just type in the branch information as you integrate
- To create a brancspec Specs | New | Branchspec... and fill in the mappings from original position to the new position
- Do an integrate on some depot directory that contains both the source and destination directories
- If you created a branchspec, choose it on the Branch Specification page
- If not using a branchspec choose File Specification page and just type in the source and dest information
- Optional: do a preview before integrating, to make sure it does what you expect
- Press the Integrate button to copy the files
- ? is a resync needed?
- The files are now copied (with memory of where they came from, so history can be seen)
- Delete the files from there original location by using Perforces Open for Delete option
- Do a resync to remove the original files
Deleting a Workspace
In P4V
- Make the Workspace you want to delete be the current one
- Select the Workspace you want to delete in the Client Workspace view View | Client Workspaces
- Then delete it via Specs | Delete Workspace 'Name of Workspace'
Loading a Workspace
In P4V
- In the combo box above the view of the Depot or Workspace, choose
Browse Workspaces ...
- Choose the workspace you want to load
- The combo should now show the name of the workspace you want to load
- Sync to head and Perforce will get the files
Copying a Workspace
In P4V
- Make sure the Workspace you want to copy is sync'd
- Find the workspace you want to copy and highlight it.
- Do the copy via: Specs | Create new workspace from 'name of one to copy'
Directory Mapping from Depot to Workspace
- Mapping rules for the Workspace operate on subdirectories of the directory you specify by "Root"
(ex. Root could be "C:\project1"
- Later rules _ALWAYS_ override earlier rules. You may want to exclude all the files except a few from some place
- Format is
DEPOT_PATH WORKSPACE_PATH
- Remapping of various types can happen, see table below.
Components of Mapping Strings
| Component | Description |
... | 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
| Example | Description |
| //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.h | The 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).
- Warning: This only lets you back out of the head revision(s)
- Sync to Previous revision of the file(s).
- Open for edit the file(s) you want to revert
- Submit and only check the file(s) you want to back out changes on.
- Sync | All Unsynched Files in Changelist
- Resolve
- 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.
- Warning: This only lets you back out of the head change list
- Sync to Previous Change list
- Open for edit the files you want to revert
- Submit
- Sync | All Unsynched Files in Changelist
- Resolve
- 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
- Make sure you have the file is "Open for Edit"
- Look at the changelist
- Find the file you want to set the attributes on
- Do it {context menu} | Change Attributes ...
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 Diff | Client | Action |
| Change Lists | P4V |
Depot Pane context on directory | Folder History
shows the history, drag and drop 2 changelists to see the differences
|
| File Revisions | P4V |
|
Ranges, specifying
? Is using a comma always the way to do it ?
| Type | Example |
| Changelist | 50,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)
- Make sure you are in the workspace directory tree (this may be optional)
- Use
p4 info to see what your settings are.
- The entry
Client name: shows the name of your current workspace.
- To set the current workspace set the environment variable
P4CLIENT to the name of the workspace you want to use.
- 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
| Command | Info |
| p4 help |
| p4 help {command} |
| p4 client |
| p4 client -d {clientWorkspaceName} | delete specified client workspace |
| p4 opened | Shows the files that are marked being edited |
| p4 sync |
| p4 sync #none | Do this before changing the workspace paths (removes all the files) |