I already posted an article about the same thing some time ago: Moving a model to another layer. The difference is that it was about Team Foundation Server, but this time I needed to move a model to another layer while using MorphX VCS.
MorphX VCS doesn’t support synchronization, therefore my original approach can’t be used. What you need is to move all objects to the target layer by export/import and update data in tables that form MorphX VCS repository. The following code will help you with the latter step:
str oldLayer = 'usr'; str newLayer = 'cus'; str 10 searchPattern = strFmt(@'\\%1\\*', oldLayer); SysVersionControlMorphXItemTable item; SysVersionControlMorphXRevisionTable rev; SysVersionControlMorphXLockTable lock; str replaceLayer(str path) { return strFmt(@'\%1\%2', newLayer, subStr(path, 6, strLen(path))); } ttsBegin; while select forUpdate item where item.ItemPath like searchPattern { item.ItemPath = replaceLayer(item.ItemPath); item.update(); } while select forUpdate rev where rev.ItemPath like searchPattern { rev.ItemPath = replaceLayer(rev.ItemPath); rev.update(); } while select forUpdate lock where lock.ItemPath like searchPattern { lock.ItemPath = replaceLayer(lock.ItemPath); lock.update(); } ttsCommit;