Irina has posted 29 posts at DZone. View Full User Profile

IntelliJ IDEA's Perforce Integration Lets Work Offline

04.08.2008
| 8051 views |
  • submit to reddit

Consider a rather typical case, when connection to your Perforce server breaks down just in the middle of editing... Or you want to speed up your work, avoiding unnecessary calls to the server… What will you do with the files in your local working copy – can you edit, delete or create them? What happens, if you terminate your IntelliJ IDEA session while offline? Let’s see how IntelliJ IDEA helps resolve these situations.

You can continue your regular activities with the files under Perforce version control regardless of the connection state, using offline mode. When the Perforce integration is in offline mode, IntelliJ IDEA keeps the log of changes in the *.iws file of your project. The entries in this log are preserved, when you restart IntelliJ IDEA.

In offline mode you can edit, create, copy, rename or move files, revert changes, view cached information in the Incoming and Repository tabs, create or delete changelists and move changes between them. All these changes are replayed when you return to online mode. While offline, you cannot perform the operations that require immediate connection to the server, which includes update, commit, integrate etc.

You can enter the offline mode in two ways. First, if connection to the server is lost, IntelliJ IDEA suggests you to continue your work offline. The other way lies with choosing offline mode on the Version Control menu (Version Control | Perforce | Work Offline)

 

 

 

 

 

 

 

 

In both cases, the result is the same - any changes in your local working copy that do not require server connection, go to changelist and are displayed in the Local tab of the Changes tool window. When you are back in online mode, you can commit the changes made while offline.

Now, let us consider an example, when in offline mode, you edit an existing file, and create a new file. First, let’s change color in a CSS file: press Ctrl+Space, and choose color from the suggestion list:

 

 

 

 

 

Note the change marker that appears in the left gutter of the editor: as in all files under version control, the changes are color-coded: the blue stripe is for the changed lines, grey triangle - for deleted lines, and the green stripe – for added lines.

The modified file is immediately added to the Default changelist. You can easily recognize the offline mode by the disabled Commit Changes icon:

 

 

 

Now, create a new class in the src directory (in the Project view, right-click the directory and choose New | Class on the context menu):

 

 

 

 

 

 

IntelliJ IDEA prompts you to put the new class under version control, or do it later. If you choose to put a new class under version control, it is immediately added to the Default changelist. If you choose to leave the new file unversioned, it does not appear in the Changes tool window at all, but when you return online, you will see the new changelist named “Unversioned Files” with the class added in offline mode:

 

 

 

 

Enjoy!

Published at DZone with permission of its author, Irina Megorskaya.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

amit singh replied on Mon, 2009/02/16 - 12:11pm

hi i want to join you

amit singh replied on Mon, 2009/02/16 - 12:12pm

i want to join you

Talk Shak replied on Thu, 2012/04/26 - 1:18am in response to: amit singh

A good blog always comes-up with new and exciting information and while reading I have feel that this blog is really have all those quality that qualify a blog to be a good one Testking 70-450 Testking 156-215.71 Testking 1z0-052 Testking 642-427

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.