IntelliJ IDEA's Perforce Integration Lets Work Offline
Join the DZone community and get the full member experience.
Join For FreeConsider 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)
[img_assist|nid=2298|title=|desc=|link=none|align=left|width=388|height=221]
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:
[img_assist|nid=2299|title=|desc=|link=none|align=left|width=294|height=128]
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:
[img_assist|nid=2300|title=|desc=|link=none|align=left|width=212|height=70]
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):
[img_assist|nid=2301|title=|desc=|link=none|align=left|width=434|height=151]
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:
[img_assist|nid=2302|title=|desc=|link=none|align=left|width=282|height=97]
Opinions expressed by DZone contributors are their own.
Trending
-
Integration Architecture Guiding Principles, A Reference
-
A Data-Driven Approach to Application Modernization
-
What I Learned From Crawling 100+ Websites
-
Fun Is the Glue That Makes Everything Stick, Also the OCP
Comments