Perforce Synchronization : (P4 SYNC Command)
Workspace is now ready and we can start work on perforce. The next step after configuring a workspace and making it the current workspace is to synchronize it.
During synchronization perforce does two things.
1. It copies files from the depot to the workspace/local disk.
2. It makes an internal record of the file revisions you have on disk.
Perforce can sync as often as you like, it's just refreshes only the files that have changed. It naver makes recopy of files that are already present in workspace.
1. How to syncronize the entire workspace
#p4 sync
Without argument sync command synchronizes entire workspace. It copies latest version of depot files to their corresponding locations on your local disk/workspace.
2. How to list unsynchronized files
#p4 sync -n
-n causes sync not to update the client workspace, but to display what would be updated.
Used if you want the preview of files you need to synchronize, or if you just want to know which depot files have been updated since the last time you synchronized.
3. How to synchronize particular module/directory
#p4 sync //depot/Release2-2010-HA/bbc/...
Normally command sync operates on entrire workspace. But by providing file spec to sync command it will sync only that piece of directory from depot.
4. How to synchronize specific type of files from the depot.
#p4 sync "//.../*.c"
This synchronizes only the *.c files rather than the entire workspace
5. How do i know when did I last synchronize
Perfoce can't actually tell you when you last ran the sync command, but it can give a clue.
#p4 change -m 1 "#have"
Change 15273 on 2010/06/18 by applications_rnd@vinod.patel.linux 'BUGID: CLITE-3 554. Some of the '
Here, this commands tells that your workspace was probably last synchronized with depot revision 15273 on 2010/06/18. The #have filespec is a shorthand for all the files in the workspace.
-m parameter to changes command limits output to the single most recent change.
We say probably last synchronized because all changes is really telling us is that 18 Jun 2010 is the date of latest revision of the files in workspace.
6. How do i know what is new in the depot.
changes command can be used that gets an idea of the changes that have occured in the depot since your last synchronized
first get your have version and then again view changes newer then that.
#p4 changes -m 1 "#have"
Change 15273 on 2010/06/18 by applications_rnd@vinod.patel.linux 'BUGID: CLITE-3 554. Some of the '
#p4 changes "@>15273"
"@15273" is undocumented syntax that means revisions after 15273.
7. How can i get help of undocumented syntax of perforce.
#p4 help undoc
8. How to sync with the older version of the depot.
Normaly, perforce copies the head revision of files to the workspace. To sync with older revisions, we need to supply a revision identifier. For example,
#p4 sync //depot/Release2-2010-HA/...@2010/03/30
Here, 30 March 2010 revision of //depot/Release2-2010-HA directory tree will be copied to the workspace.
9. How to list files those are in workspace
#p4 have //depot/Release2-2010-HA/...
This lists the files perforce thinks that you have with have command.
10. How to detect how many files are missing in workspace
In perforce the list of files in workspace is called have list. The have list is actually inventory of files that have been synchronized, not an invenroty of files actually in workspace because it may include files that have since gone missing, and it doen't include files that come from the depot.
#p4 diff -sd
-sd flage lists unopened files that are missing on client
11. How to replace missing files.
workspace files are under users control and there is nothing to stop him to erasing files perforce put there. Also perforce thinks that you have already those files and you won't be able to replace them with simple sync command.
To force perforce to recopy file it thinks you already have, -f paramater used with sync command
#p4 sync -f //depot/...
This will recopy whole depot to the workspace. Its also possible to only make recopy of files that have been missing by,
#p4 diff -sd | p4 -x- sync -f
-x instructs p4 to read arguments one per line from the named file. If the file is named '-', then standard input as read
-f makes recopy of the file in workspace even though perforce thinks you already have them
12. How to detect files that not come from depot.
#ls --format=single-column | p4 -x- have > /tmp/have.txt 2>/tmp/havenot.txt
The ls command generates list of files in current directory in single column format and p4 with -x- flag gets that file as parameter and checks for its have version
Files those are from depot are redirected to /tmp/have.txt and those not are redirected to /tmp/havenot.txt
Workspace is now ready and we can start work on perforce. The next step after configuring a workspace and making it the current workspace is to synchronize it.
During synchronization perforce does two things.
1. It copies files from the depot to the workspace/local disk.
2. It makes an internal record of the file revisions you have on disk.
Perforce can sync as often as you like, it's just refreshes only the files that have changed. It naver makes recopy of files that are already present in workspace.
1. How to syncronize the entire workspace
#p4 sync
Without argument sync command synchronizes entire workspace. It copies latest version of depot files to their corresponding locations on your local disk/workspace.
2. How to list unsynchronized files
#p4 sync -n
-n causes sync not to update the client workspace, but to display what would be updated.
Used if you want the preview of files you need to synchronize, or if you just want to know which depot files have been updated since the last time you synchronized.
3. How to synchronize particular module/directory
#p4 sync //depot/Release2-2010-HA/bbc/...
Normally command sync operates on entrire workspace. But by providing file spec to sync command it will sync only that piece of directory from depot.
4. How to synchronize specific type of files from the depot.
#p4 sync "//.../*.c"
This synchronizes only the *.c files rather than the entire workspace
5. How do i know when did I last synchronize
Perfoce can't actually tell you when you last ran the sync command, but it can give a clue.
#p4 change -m 1 "#have"
Change 15273 on 2010/06/18 by applications_rnd@vinod.patel.linux 'BUGID: CLITE-3 554. Some of the '
Here, this commands tells that your workspace was probably last synchronized with depot revision 15273 on 2010/06/18. The #have filespec is a shorthand for all the files in the workspace.
-m parameter to changes command limits output to the single most recent change.
We say probably last synchronized because all changes is really telling us is that 18 Jun 2010 is the date of latest revision of the files in workspace.
6. How do i know what is new in the depot.
changes command can be used that gets an idea of the changes that have occured in the depot since your last synchronized
first get your have version and then again view changes newer then that.
#p4 changes -m 1 "#have"
Change 15273 on 2010/06/18 by applications_rnd@vinod.patel.linux 'BUGID: CLITE-3 554. Some of the '
#p4 changes "@>15273"
"@15273" is undocumented syntax that means revisions after 15273.
7. How can i get help of undocumented syntax of perforce.
#p4 help undoc
8. How to sync with the older version of the depot.
Normaly, perforce copies the head revision of files to the workspace. To sync with older revisions, we need to supply a revision identifier. For example,
#p4 sync //depot/Release2-2010-HA/...@2010/03/30
Here, 30 March 2010 revision of //depot/Release2-2010-HA directory tree will be copied to the workspace.
9. How to list files those are in workspace
#p4 have //depot/Release2-2010-HA/...
This lists the files perforce thinks that you have with have command.
10. How to detect how many files are missing in workspace
In perforce the list of files in workspace is called have list. The have list is actually inventory of files that have been synchronized, not an invenroty of files actually in workspace because it may include files that have since gone missing, and it doen't include files that come from the depot.
#p4 diff -sd
-sd flage lists unopened files that are missing on client
11. How to replace missing files.
workspace files are under users control and there is nothing to stop him to erasing files perforce put there. Also perforce thinks that you have already those files and you won't be able to replace them with simple sync command.
To force perforce to recopy file it thinks you already have, -f paramater used with sync command
#p4 sync -f //depot/...
This will recopy whole depot to the workspace. Its also possible to only make recopy of files that have been missing by,
#p4 diff -sd | p4 -x- sync -f
-x instructs p4 to read arguments one per line from the named file. If the file is named '-', then standard input as read
-f makes recopy of the file in workspace even though perforce thinks you already have them
12. How to detect files that not come from depot.
#ls --format=single-column | p4 -x- have > /tmp/have.txt 2>/tmp/havenot.txt
The ls command generates list of files in current directory in single column format and p4 with -x- flag gets that file as parameter and checks for its have version
Files those are from depot are redirected to /tmp/have.txt and those not are redirected to /tmp/havenot.txt
No comments:
Post a Comment