SmexyyWeby

Scripting for Fun and Passion

Category Archives: Learning Series

Useful Perforce Commands Series: 1


I have recently started using perforce at my work place as our version control system. Before this  I have had experience using SVN on google code and GIT for github. Perforce is an enterprise level version control system which uses the concept of depot and workspaces on each perforce clients. Its very easy to set up and even comes with a GUI interface [Perforce Visual Client ] where you can easily see file histories, diffs and other code check-in details.

To read more about how perforce organizes files and changes you can read the official perforce introduction documentation at: http://www.perforce.com/perforce/doc.current/manuals/intro/01_intro.html#1093183

So here are some useful perforce commands:

1. Setup Perforce Workspace:

export P4PORT=<p4depotIP>:<PORT>
export P4USER=<username>
mkdir <workspace_folder>
cd <workspace_folder>
export P4CLIENT=<clientname>
p4 client

On doing p4 client a file will open in your default editor. In that file fill in the following details:

View:
 //depot/<folderpath_to_sync>/... //<workspace_folder>/<folder_to_sync_to>/...

Now save the file and your client will be configured.

To sync your current folder with the depot code fire the following command:

p4 sync ...

If you feel that the sync was not done properly you can run p4 sync … again till it gives the message “there are no more files to sync”

Also if you want to force a file to sync again you can type:

p4 sync -f ...

2. Get to know your perforce clients:

 If you have multiple clients configured you can see the brief details of all your clients by typing

p4 clients -u &lt;username&gt;

To delete a client:

p4 client -d &lt;clientname&gt;

3. Edit/Add files for change:

All synced files in a perforce workspace are in readonly mode by default. So if you want to edit any file you should first add an edit status to it in the perforce workspace. This will notify the main depot that the file is opened for editing in your workspace which can be used by other users who are making changes to same file.

p4 edit &lt;file_name/relative_file_path&gt;

Similarly, you can add a newly created file by you to the perforce workspace, which again will notify the depot about the change.

p4 edit &lt;file_name/relative_file_path&gt;

4. Creating changelists:

All changes in perforce are saved as changelists. If you want to submit any of your changes to the main depot then you need to create a changelist number. All files which are opened for edit or are added are by default the part of the “default” changelist. If you have created the changelist you will see a number next to your file which will denote the changelist to which the file is added.

To see all the files opened on your workspace:

p4 opened ... # for all files opened for change in workspace.
//depot/&lt;folderpath_to_sync&gt;/&lt;relative_file_path&gt;#&lt;change_number&gt; - edit default change (ktext) #This file is a part of default changelist
//depot/&lt;folderpath_to_sync&gt;/&lt;relative_file_path&gt;#&lt;file_change_number&gt; - edit change &lt;changelist_number&gt;(ktext) #This file is a part of changelist with changelist number =&lt;changelist_number&gt;

To create a changelist:

p4 change #it will open a file where you need to fill the Description, Reviewer and BUGID for the change, Save the file and you will get the changelist number

To see all the changelists by a specific user/client:

p4 changes -u &lt;username&gt; #lists all changes by that user
p4 changes -c &lt;clientname&gt; #lists all changes by that client
p4 changes -c &lt;clientname&gt; -l #displays the changes by that client with their full description texts
p4 changes -c &lt;clientname&gt; -L #displays the changes by that client with their short description texts truncated to 250 words.
p4 changes -s &lt;fixed|opened|...&gt; -c &lt;clientname&gt; #displays all changes by the client which are

5. Submitting changes:

Once you have made all changes you need to submit it to the depot. The change submission usually follows the following process:

Viewing the change diff w.r.t. depot:

p4 diff ... # will present the diff of your change files with the recent files in the depot
#if you want to see the changes in vimdiff you need to make the p4diff editor to be vimdiff
export P4DIFF=vimdiff
p4 diff ... # will show the diff in vimdiff

Marking the bug fixed by the change:

p4 fix -s fixed -c &lt;changelist_number&gt; &lt;space separated list of BUGIDs&gt;

Submitting the change:

p4 submit -c &lt;changelist_number&gt; #usually if other people are working on the same file this command will result in an error

Resolve the changes & submit:

p4 resolve ... #This will present you will a prompt to resolve the changes. It will have options to either merge the changes or edit the file manually
p4 submit -c &lt;changelist_number&gt; #Submits your changelist with resolved changes
p4 sync ... #sync your workspace so that it reflects the recent changes in the depot

An Introduction to Web Development : Installation, PHP, MySQL and your 1st Script.


Well I was thinking about this for a long time … Its been 4 years in my life since I was first introduced to this beautiful world of internet and its been 10 years now that I have felt and am still fascinated by how the world of computers work.

The world of computing has made rapid advancements in the last one decade or so and most of them have been in the field of the ever evolving INTERNET .The internet has evolved like a fast growing Macrocystis pyrifera . Well I used the name because this is the fastest linearly growing organism on this planet.(Search wiki for that .. :P) .But Internet has not grown linearly it has evolved in different domains completely indepent of other stuff but all liking towards the same cloud of TCP/IP and other Protocols.

Web has been a revelation is human beings life. Through it you can find any information on this planet by just a click of your mouse and a KeyPunch on your keyboard.The information available on the internet is huge and people are still adding to it every second (like me … writing this blog entry … :P) in the forms of wikis , tweets , applications , and god knows what not. People are just a click away… life is governed by protocols like HTTP, TCP , FTP …

So you guys might be thinking now what goes behind all this … how are we able to provide all the information over the web how are we able to connect ourselves to the internet.The answer lies in the Web Server . A small program that even you, me and anyone can run on his personal computers and open to ourselves the portal towards sharing our information to the people. Read more of this post

%d bloggers like this: