External Sync / How to... / Resolving conflicts / Name Space Conflicts / Same Template Type With Identical UID
Simultaneous creation of a page template with different content, same UID
Table of contents |
This scenario demonstrates how to resolve a conflict that occurs when multiple developers create templates with the same UID in their own local working versions of the project.
During conventional project development – using just one working instance of the project – FirstSprint's internal automatic resolution is normally used for UID conflicts: If a page template with the UID page_template is created and this UID has already been used for another page template, a numerical suffix is automatically added to the UID, e.g., page_template_1).
During distributed development, FirstSpirit’s internal UID conflict resolution function cannot be used as the working instances of the project are synchronized using Git.
In each working instance, one template with the same UID but different content can be created. When synchronizing the project data between the two project instances, the conflict must be resolved outside of FirstSpirit. In this case, the user must decide which version of the page template (the one transferred into the repository first or the local version) should be kept.
How the conflict occurs
Developer A
- Creating a FirstSpirit element
In the “Page templates” folder in the Template Store, Developer A creates a new page template with the UID page_new and adds the following content to the HTML presentation channel: New page template A - Exporting changes into the file system
Developer A uses fs-cli to export the current version of the project into the local file system (Git repository)
fs-cli -p DevProject -sd "D:\Git\DevProject" export templatestore - Transferring changes to the Git repository
Developer A transfers the changes to the Git repository
git commit -a -m "created page_new"
git push
Developer B
- Creating a FirstSpirit element
In the “Page templates” folder in the Template Store, Developer B also creates a new page template with the UID page_new but adds different content to the HTML presentation channel: New page template B - Exporting changes into the file system
Developer B uses fs-cli to export the current version of the project into the local file system
fs-cli -p DevProject -sd "D:\Git\DevProject" export templatestore - Transferring changes to the Git repository
Developer B transfers the changes to the Git repository
git commit -a -m "created page_new"
git push
He receives the following log report:
$ git push
To ssh://firstspirit.example/externalsync
! [rejected] myBranch -> ts/sync-test (non-fast-forward)
error: failed to push some refs to 'ssh://fsgit@ssh://test.domain.com/git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
This report warns Developer B that the repository already contains newer data than the local data. In this case, the push cannot be performed until the local working version has been updated with a pull.
Conflict resolution
Update
Updating the working directory against the Git repository
Developer B updates the local working version so that it is in line with the repository:
git pull
When attempting to update the working version, Developer B receives the following messages:
$ git pull
Auto-merging TemplateStore/PageTemplates/page_new/StoreElement.xml
CONFLICT (add/add): Merge conflict in TemplateStore/PageTemplates/page_new/StoreElement.xml
Auto-merging TemplateStore/PageTemplates/page_new/FS_References.txt
CONFLICT (add/add): Merge conflict in TemplateStore/PageTemplates/page_new/FS_References.txt
Auto-merging TemplateStore/PageTemplates/page_new/ChannelSource_HTML_html.html
CONFLICT (add/add): Merge conflict in TemplateStore/PageTemplates/page_new/ChannelSource_HTML_html.html
Automatic merge failed; fix conflicts and then commit the result.
Resolving the Git conflict
The resolution of this conflict requires manual intervention as the Git client is unable to decide which of the two versions of the page template it should keep. In this case, the two developers must work together to decide how to resolve the conflict (Which version should be kept? Can the content be merged?).
At this point Developer B decides, for example, to keep his version of the page template. To do this, he performs a check-out using the Git client so that the local versions of the files are kept for the conflicting case:
git checkout --ours *
The affected files in the Store TemplateStore/PageTemplates/page_new with the changes made by Developer B are therefore seen as definitive and transferred into the repository. As a result, the changes that Developer A made to these page template files are overwritten.
Import
Importing out of the file system
After the conflict has been resolved at file system level (Git), Developer B must complete the validation steps. In the next step, the version from the file system is imported to FirstSpirit
fs-cli -p DevProject -sd "D:\Git\DevProject" import´
Export
Exporting changes into the file system
In the next step, Developer B uses fs-cli to export the current version of the project into the local file system
fs-cli -p DevProject -sd "D:\Git\DevProject" export templatestore
Commit / Push
Transferring changes to the Git repository
Developer B has resolved the conflict and can now transfer the changes to the Git repository
git commit -a -m "replaced page_new"
git push
Next steps
The conflict is resolved. Developer B does not have to do anything else at this point; the version of the project on his FirstSpirit Server matches the one in the repository.
If Developer A restarts development work later on, then he should complete the following:
Update
Updating the local Git repository
Developer A
Update the local working version so that it is in line with the repository:
git pull
Git reports that several files were updated during the pull process:
$ git pull
TemplateStore/PageTemplates/page_new/ChannelSource_HTML_html.html | 2 +-
TemplateStore/PageTemplates/page_new/FS_References.txt | 2 +-
TemplateStore/PageTemplates/page_new/StoreElement.xml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
Import
Importing the contents from the file system to the FirstSpirit project
Developer A
fs-cli -p DevProject -sd "D:\Git\DevProject" import
Here, fs-cli notifies Developer A that identifiers (UUIDs) used by External Synchronization for the page templates in the project have been updated with the UUIDs defined by Developer B:
Importing...
Updating UUID for element 648015: 3f20be42-d29a-498f-ad59-df917d28aef6 (old UUID was f69fe264-7a55-4f65-833c-34ec8bc741ef)
Import operation successful
updated elements: 1
created elements: 0
deleted elements: 0
moved elements: 0
created entities: 0
lost and found elements: 0
problems: 0
Import done.
updated elements: 1
created elements: 0
deleted elements: 0
Both Developer A's local project and Developer B's local project now contain the page template page_new in the version that contains the HTML presentation channel defined by Developer B:
New page template B
Developer A now has to check his local project instance to see whether any uses in his first version of the page template have been affected by the replacement with Developer B's version.