Introduction
This post is the third in my series about working on Flare projects that are bound to Perforce source control. It explains how to move and rename files in your Flare project. Previous posts explain how to bind your Flare project to Perforce and how to work with Flare projects that are bound to Perforce.
Before I go any further, I must say an enormous and heart-felt “Thank You” to Thomas Bro-Rasmussen, who very generously wrote a short paper on how he uses Perforce with Flare, in response to queries from several of us on a LinkedIn thread about Flare and Perforce. Without his input, this post would be far, far more complicated. It was going to start by suggesting that you found yourself somewhere quiet and free from distractions, read through all the instructions, then worked through them carefully one step at a time. Thanks to Thomas, these extreme authoring techniques aren’t necessary any more, and my instructions are quite simple after all.
Prerequisites
As before, you do need a basic understanding of Perforce, as we will be carrying out some operations directly in Perforce rather than Flare. I’m assuming you’re familiar with the concepts of checking in and checking out files, and the Perforce depot, workspaces and changelists. I’m also assuming you are using the Perforce Windows client, P4V.
Thomas states that there are known issues with some versions of Perforce, and recommends that you use Perforce Visual Client 2011.1/373647, as he knows this works as required. I have used Perforce Visual Client/NTX86/2011.1/405081, and have just upgraded to Perforce Visual Client/NTX64/2013.4/760166, and I have had no problems so far.
To follow these instructions, you need to be work in a Flare project that is not bound to Perforce, even if, like me, you normally work with a bound project. When I described how to bind your Flare project to Perforce, I suggested that you kept a copy of the unbound project file as well. If you did that, you will need it now. Otherwise, the simplest way to make one is to take a copy of your bound .flprj file, then open the file with a text editor. Locate the binding string, which will look something like this:
SourceControlBound="true"
SourceControlDatabase="Perforce Project"
SourceControlProviderType="Perforce SCM"
ProjectGuid="1166a5ab-0bf4-4605-9dd4-80c53351a685
and replace it with this:
SourceControlBound="false"
This file is now your unbound project, and you can open it instead of the bound one as required. Check this into Perforce now so you have it available for the next time you need it.
Background to moving and renaming Perforce files in Flare
Moving and renaming Perforce files in Flare is difficult because:
- You have to use Flare to move and rename files, or face the prospect of updating all your broken links manually afterwards.
- In a bound project, Flare doesn’t send Perforce the correct instructions when moving or renaming files, so you have to complete the operation directly in Perforce afterwards. This is why you need an unbound project for this bit, as if you let Flare try to tell Perforce what to do, the result is simply wrong and adds to the mess.
- Perforce doesn’t allow you to move or rename a file unless the old file is still in your workspace and the new file is not yet in your workspace. If you have moved or renamed a file in Flare, this won’t be the case, so before you can do the operation directly in Perforce, you need to take a safe copy of the new file, reinstate the old one, do the move or rename in Perforce, then overwrite the Perforce-renamed file with the safe copy you took earlier. Before Thomas came into my life, I was going to talk you through this painful and error-prone process.
Perforce’s wonder command – Reconcile Offline Work
Fortunately, Perforce includes the Reconcile Offline Work command. This allows you to work on your files outside Perforce, then select a file or folder and ask Perforce to reconcile your changes with the depot. The resultant dialog displays three types of file:
- files in Perforce that you have changed in your workspace but are not checked out of the depot
- files in your workspace that are not in the depot (these may be completely new files, or the moved or renamed versions of existing files)
- files in the depot that are no longer in your workspace (these may have been intentionally deleted, or they may have been moved or renamed).
You can inspect the files shown in the dialog, deselect any files you don’t want to include in the reconciliation, then perform the reconciliation. This adds the selected files to a changelist of your choice. Any changed files are checked out and marked in the changelist for check in. New files are marked to be added, and missing files are marked to be deleted.
There is a small problem with this approach (but, believe me, it’s far smaller than the tedium and likelihood of errors with any alternative method). When you move or rename a file directly in Perforce, the action is saved as a linked deletion/addition pair. That means the file is still effectively the same file, and the move or rename is visible in the Perforce change history. If you do the move or rename in Flare then use Reconcile Offline Work to update Perforce, no direct link is maintained in Perforce between the old and new files. But if you are disciplined about your use of changelists, you can easily ensure that your changelist contains deletion/addition pairs, so maintaining the link in the changelist. The steps below explain how to do this.
Controlling Perforce’s Wonder Command – the Ignore list
There is other small problem with Reconcile Offline Work. It will offer to reconcile everything in your project folder that isn’t already in Perforce. By default, this will include all the Output files, the temporary files, the Analyzer files etc. You can easily stop this by creating a Perforce ignore list for each project. This may have already been done for your Flare project, but if not, it’s easy and I recommend that you do it. If you don’t have an ignore list, you will have to check the list of reconciled files extra carefully, and manually remove anything that doesn’t need to be in Perforce. These instructions assume you’ve set up an ignore list.
Using Reconcile Offline Work to action moves and renames
I strongly recommend that before moving or renaming files in Flare, you start with no checkouts in the project you are working on, and with your Flare project in as clean a state as possible. This will help maintain a clear and accurate audit trail of the operation, which could be useful to those working on the project in the future. So, if at all possible:
- Check in any files in your project that are currently checked out. When you do the move/rename, Flare may change many other files in your project to adjust links, and if the file is already checked out, it won’t show in the list of files to be reconciled, so won’t get included in the same changelist as the other changes related to the move or rename .
- If you have created any new project files that aren’t yet in Perforce, but should be, add them to Perforce now.
- Delete any unnecessary files in your project area that are not in Perforce and are no longer required, unless they are in your Perforce ignore list.
Ready to go?
- In Flare, action the moves or renames as required, accepting Flare’s request to update links as necessary. Try to restrict your Flare changes to just the move or rename and related changes, as this will make it easier to understand the change history for these files later on. You can always do any additional changes in another changelist immediately afterwards.
- In Perforce, select the root folder for the project that contains the changes, right-click and select Reconcile Offline Work.
- Review the files shown in the Reconcile Offline Work dialog box and make sure you are happy with the actions that will be taken.
- The first section (Modified files) contains files that weren’t moved or renamed themselves, but Flare has needed to update as a result of the move or rename. If you have project files checked out elsewhere, and Flare has had to update links in any of these files as part of the rename sequence, they will not show up here. This won’t stop you completing the move/rename operation, but it will mean that not all files affected by the move/rename are in a single change list.
- The second section (Local files not in depot) lists the files that need to be added to Perforce. These will include the new files that were created as a result of the move/rename. If you don’t have a Perforce ignore list for this project, you will also see a large number of Flare working files in this list, and if you have other files in your project that have not yet been added to Perforce for any reason, you will see them here too. You can manually deselect the files that aren’t applicable, although I prefer to work in a way that ensures all files here are relevant, as this avoids errors and helps maintain a clean audit trail of changes.
- The third section (Depot files missing from workspace) lists the files that need to be deleted from Perforce. These will include the old versions of the files that were moved/renamed, and may also include other files that are in Perforce and no longer in your workspace. Again, you can manually deselect the files that aren’t applicable to the move/rename if necessary. In any case, you should end up with the same number of selected files in this section as in the second section as every addition should correspond to a deletion.
- When you are happy with your selections, select the drop-down by Add files to pending changelist and select New, then click Reconcile. This creates a changelist called Reconciled offline work which contains the Perforce changes for this move/rename operation.
- Review the changelist, change the description to something meaningful, and submit it. Job done!
- If you normally work in a bound Flare project, close the unbound project and re-open your bound project.
If this has helped you, please let me know. If you have any questions, I’ll try to answer them. If you have an even better way to handle moves and renames in Flare projects that are stored in Perforce, I’d love to hear about them.
© Marjorie Jones February 2014