Hi I am trying to write a batch script that copies same set of configuration files from one application in depot to another application (trigger for copying those files once checked into first application). The idea in my mind is:
Add files from first application to client using p4 add
use p4 copy
p4 submit
Is this the right approach? Please help. Please provide any sample scripts available.
After trying for sometime, I was able to figure it out. The method I used is
create a new workspace
sync the files to workspace
copy the files using p4 copy and
submit the changes.
Related
I have never used P4 version control system before, and just come across with following problem:
I was submitted a project to server with lots of redundant files and have been working on the project actively. Now I have my project working and clean, and want to synchronize with depot. The problem is that I have deleted lots of files manually in windows file explorer(from my workspace),ignoring the rules of p4(mark for deletion, submit etc.).
How can I synchronize my project with depot? With another word, how can I delete files from depot that I have manually deleted from local folder, which are not shown in "workspace" tab.
Run the command:
p4 reconcile
This will automatically scan your entire workspace for added/deleted/modified/renamed files and open them for the appropriate actions. Once you've run reconcile you can just p4 submit as normal, and everything you did in your workspace should get submitted to the depot.
If you're using P4V, I think there's a "Reconcile..." menu command that will do something similar.
I have synced files around 1 Tb from one server to another and set up P4, but I have a different workspace in the new server so if i initiate a p4 sync in new server, Will it add only the difference or will it duplicate the files?(source remains the same)
If the workspace map is the same as the old client, and there have been no changes, you can do a p4 sync -k. This updates the metadata on the server, without doing the file transfers. If there have been changes, you'll have to force sync those files to get the correct revision.
Since you created a new workspace, and P4 doesn't know that you have the files already existing on your new environment, it will pull over all of those files.
If you kept the same workspace name, (by default) it would pull over only "new" files (because it thinks you already have the files you previously synced).
I am trying to automate access to Perforce via it's command line utility.
Creating a new client workspace with p4 client and syncing works ok.
Now I am allowing users to overwrite user, host, port, stream, revision.
From the docs it is not clear to me when I have to execute which commands to get the client workspace files in sync with an edited client workspace spec.
What I currently do is once p4 client is through search for
Client mymachine not changed
in stdout and do a p4 sync -f should the message not appear.
Is there a better or more sane way to do this?
I tried executing e.g. p4 sync -s in hope that it would fail should local data be deleted but it seems that I misunderstood the option?
It is not clear to me how this relates to your question about workspaces:
Now I am allowing users to overwrite user, host, port, stream,
revision.
since only one of those is a property of a workspace. I'm going to disregard that statement for now but if it was significant I'd encourage you to post a follow-up clarifying what you mean by "overwriting" each of these properties.
To your question:
From the docs it is not clear to me when I have to execute which
commands to get the client workspace files in sync with an edited
client workspace spec.
If the client View is updated, all you need to do is:
p4 sync
If the client Root is updated, or any of the other options that globally affect how files are written to the workspace, such as allwrite or modtime, you will need to re-sync the entire client. Ideally this is done by doing:
p4 sync #none
prior to changing the workspace in one of these ways. The other option would be to do something like the following sequence:
p4 sync #none
p4 sync
p4 clean
to make sure that everything is rewritten, and that any stragglers (e.g. anything that the "sync #none" couldn't locate because the Root had changed but that are still mapped in the client view) are removed from the workspace.
I tried executing e.g. p4 sync -s in hope that it would fail should
local data be deleted but it seems that I misunderstood the option?
Deleting local data is a separate issue from editing the client spec, but for that the command you want is p4 clean rather than p4 sync -- you use sync to tell the server you want it to send you new revisions, you use clean to bring your workspace back in line with what the server already sent you.
The recommended/supported workflow is to always use p4 commands to manipulate the read-only files in your workspace -- so if you want to delete a local file, use either p4 sync FILE#none (to remove it from your workspace but not affect the depot) or p4 delete FILE (to open it for delete so that it will be deleted for everyone when you submit).
I am writing a build script that gets all the source code for a particular changelist and builds it. I would like to be able to run the script at any time, without having to shelve local changes or move files to a temporary location. The script will be used by others who have their own workspaces defined.
I thought it would be easiest just to get all the source code from Perforce at a temporary location and build from there. Unfortunately p4 sync does not seem to support this, it will only put files into the client view as specified by the workspace, meaning it would overwrite local changes before I could copy the files to the temporary location.
Is there any way to use p4 to copy files from Perforce into an arbitrary location?
You could create a dedicated workspace for the build script and then have the build script sync to it by using
p4 -c [workspace name] sync [depot path]
This is what a continuous build system would typically do. Be sure to blank out the Host: section of the workspace spec in this case so that it can be used on multiple systems.
An alternative might be to use p4 print with the -o option to dump the files to an arbitrary location without syncing them.
P4 sync can be done only to a client spec. Possibly, you need to create another client spec and sync to that client spec.
I am new to Perforce and have some experience using ClearCase earlier. I am using a Windows XP client and trying to set up my perforce client/workspace.
The Perforce view I have has mappings of type:
//depot/path/to/folder/... //my_workspace/depot/path/to/folder/...
However, I have not attempted the "Get latest revision" action (in p4v) for this workspace. That means, I don't have a local copy of the folder in question.
My question is: How do I populate the workspace with contents of the folder from the command line when the folder isn't present in the workspace ? The manual for p4 sync talks about getting a certain revision when the file is present in the workspace.
In terms of ClearCase, when the config spec for a snapshot view is having loadrules too, then cleartool can be told to pick the config spec from a text file and also load the contents of the view. I am trying to achieve a similar thing for Perforce.
Thanks in advance,
Parag Doke
Running the sync command will populate the workspace. If a file or folder isn't already present, it will be created during the sync operation.
With no additional flags specified, p4 sync will populate your workspace with the latest contents at the time the command is started.