how to Implement batch file command in p4.net api - perforce

i want to implement below p4 commands in a batch file.
Now i want to implement everything in a job service of .net using p4.net api.
To do in .net using p4.net api:
1)First sync files or latest files at workspace path.
2)Create a new Change List
3)Revert all files if there is any change in above changelist
4)Now actually opening files for edit at destination workspace path of particular file format in above changelist
5)Copy files from server source path to local workspace destination path and copy should happen recursively from server source path to destination path of particular file format like gp*.* files from source to destination
6)Revert unchanged files in above changelist
7)Now run perl command using above changelist.
Batch File:
SET P4CLIENT=deep_abc
SET P4PORT=p4ww:2012
SET SRC="\\ServerPath"
SET DEST="\\LocalPath\resources"
SET DPATH=D:
SET AS2="D:\as2\beta_0.4\bin"
%DPATH%
cd %DEST%
pause
p4 revert -c 19239674 file ...
pause
p4 edit -c 19239674 GP100*.*
pause
robocopy %SRC% %DEST% *.rom
pause
p4 revert -a 19239674 file ...
pause
%DPATH%
cd %AS2%
pause
perl as2.pl -c %P4CLIENT% submit -t -c 19239674
pause

Related

perforce sync no such files

I am trying to setup perforce. I installed p4v and setup workspace.
Then I ran
C:\"Program Files"\Perforce\p4 -p perforce-test:1500 -u test-user -c test-user_test sync //test-folder/test/
But I get error //test-folder/test/ no such files(s)
I can see files and folder exist in p4v depo.
Use the path:
//test-folder/test/...
Directories aren't objects in Perforce, they're just part of the file name -- so you don't sync a directory called "//test-folder/test/", you sync all the files whose paths match the pattern "//test-folder/test/...".
Use the “...” in the end
e.g.
Wrong : p4 sync //test-folder/test/
Right : p4 sync //test-folder/test/...

Perforce - Specify target directory path for sync

Is it possible to specify the folder name where depot needs to be synced ?
I tried syncing the depot to my specified path using following command but it does not work.
p4sync -d "c:\my\path" sync //depot//branch/file
Note : My aim is just to copy the file from depot to my specified location.
Looks like sync is not the command I should be using. Is there any other command or way I can do this ?
sync - gets files from depot to your workspace, which must be already customized. To get files without workspace you need to make some hack with command "print":
p4 print -o filename //path/on/depot/filename
This command (above) gets filename and store it in "filename". Also, you can make some another workaround to get all files from some directory, probably with "p4 -x - command" ( -x stands for xargs in unix-world)

how to sync the perforce client only with the files of a particular change list using p4 sync command

I'm trying to sync only the files modified in a particular change list to p4v.
Suppose in a perforce directory //demo/test I have 10 files out of which only 3 are modified as part of change list number 1234. I want only 3 files to be synced up. I have tried below options but it did not work.
p4 sync //demo/test...#1234;
This command says the files are updated but i don't see the files synced up.
p4 sync -f //demo/test...#1234;
This command is syncing all 10 files in the directory.
Use
p4 sync //demo/test...#1234,1234
or
p4 sync //demo/test...#=1234
When running tests like these, remember that 'p4 sync' won't sync a file that you already have, which is why you found the need to run 'p4 sync -f' to force the files to be sent even though the server knows you already have them. If you want to clear the server's memory of the files that you have, you can run
p4 sync //demo/test...#none
which will remove all the (p4-managed) files matching '//demo/test...' from your workspace, and then 'p4 sync' will bring them back the next time.
Oh, and since 'test' is a directory, the pattern
//demo/test/...
is preferred to
//demo/test...
since '//demo/test/...' matches only the files in the test directory, while '//demo/test...' will also match the files in the '//demo/test1', '//demo/test-and-set', and '//demo/testarossa' directories (if those should happen to exist).

p4 status -A only to sub directory of perforce workspace

I have folders like this in my perforce workspace view.
//depot/... //rajesh_ws/...
where //depot/... has all the source code and the compiled code will be copied to bin sub directory. I am syncing //depot/... & Building it and copying the binary file in bin sub directoryr.
Now I want to submit the bin folder (//rajesh_ws/bin/...) in Perforce instead of all (//rajesh_ws/...) which has many other files generated during the build.
When i use "p4 status -A" & "p4 submit", it submit all the files which includes //rajesh_ws/... but i want to only submit the files from bin folder. Any idea on this?
I am using p4python api for the same
Script snippet
p4.run("status", "-A")
p4.run_submit( "-d", "Modifying bin folders")
Please suggest
Provide the path as an argument to at least one of the commands:
p4 status -A //rajesh_ws/bin/...
p4 submit -d "Modifying bin folders" //rajesh_ws/bin/...
"p4 status" will only open files matching the file argument (leaving other unopen files in an unopen state); "p4 submit" will only submit open files matching the file argument (leaving other open files in an open state).

P4 changes on a specific folder/file

I am trying to get the last checkin on a particular folder structure on perforce, I know "p4 changes -m1 'filepath" does the job, but the problem is the filepath has to be the depot file-path. What I have on the other hand is the local filepath something like "C:\Android\Version10.2\MyApp\" and not "//depot/Andoid/Version10.2/MyApp".
I tried using commands like "p4 fstat", "p4 where" and "p4 files", but for all of them it works fine with the depot file path, if I give the local file path, it keeps complaining file(s) not on client/no such file(s).
The other issue is I dont have rights to change the p4client on the machine. How do I get this to work?
Basic question then to sum up is being able to get the last change on a folder/file for which I have the local filepath.
Regards
If you're going to run any commands on files those files have to be in the workspace. The problem is probably that p4 on Windows defaults to the machine name as the workspace name if you don't supply one.
So you either have to run set P4CLIENT=<clientname> then run p4 changes -m1 <filename>,
or p4 -c <clientname> changes -m1 <filepath> where <filepath> can be the file on your local file system, so C:\Android\Version10.2\MyApp\ would be acceptable.
Does p4 filelog -m 1 <filename> give you what you want? You can add the -l (lowercase L, not one) switch to get more information.
If you have a local file (as opposed to the depot-path), then you also should have a client-spec. You need to specify this with the -c option:
p4 -c <name-of-client-spec> changes -m1 <filepath>

Resources